View | Details | Raw Unified | Return to bug 21892
Collapse All | Expand All

(-)a/QohA/File.pm (-1 / +31 lines)
Lines 96-105 sub check_forbidden_patterns { Link Here
96
        : 1;
96
        : 1;
97
}
97
}
98
98
99
sub codespell_has_L_option {
100
    my $cmd = q{codespell --help | grep "\-L" | wc -l};
101
    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 );
102
    my $result = $full_buf->[0];
103
    return $result + 0;
104
}
105
106
sub remove_codespell {
107
    my $cmd = q{sudo apt remove -y codespell};
108
    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 );
109
    $cmd = q{sudo -H pip uninstall -y codespell};
110
    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 );
111
}
112
113
sub install_codespell {
114
    my $cmd = q{sudo -H pip install codespell};
115
    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 );
116
}
117
118
sub tell_bash_to_unhash_codespell {
119
    my $cmd = q{hash -d codespell};
120
    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 );
121
}
122
99
sub check_spelling {
123
sub check_spelling {
100
    my ($self) = @_;
124
    my ($self) = @_;
101
125
102
    my $cmd = q{codespell -L Sheat -d } . $self->path;
126
    if (! codespell_has_L_option()) {
127
        print STDERR "\nCodespell missing required -L option!\n";
128
        remove_codespell;
129
        install_codespell;
130
        tell_bash_to_unhash_codespell;
131
    }
132
    my $cmd = q{codespell -L sheat -d } . $self->path;
103
    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 );
133
    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 );
104
134
105
    return 0 unless @$full_buf;
135
    return 0 unless @$full_buf;
(-)a/koha-qa.pl (-2 / +6 lines)
Lines 41-48 BEGIN { Link Here
41
}
41
}
42
42
43
our @tests_to_skip = ();
43
our @tests_to_skip = ();
44
# Check for codespell
45
my $have_codespell = 0;
46
if ( -f '/usr/bin/codespell' || -f '/usr/local/bin/codespell' ) {
47
    $have_codespell = 1;
48
}
44
# Assuming codespell is in /usr/bin
49
# Assuming codespell is in /usr/bin
45
unless ( -f '/usr/bin/codespell' ) {
50
if (! $have_codespell ) {
46
    warn "You should install codespell\n";
51
    warn "You should install codespell\n";
47
    push @tests_to_skip, 'spelling';
52
    push @tests_to_skip, 'spelling';
48
}
53
}
49
- 

Return to bug 21892