Merge branch 'es/test-lint-one-shot-export'
Look for broken use of "VAR=VAL shell_func" in test scripts as part of test-lint. * es/test-lint-one-shot-export: t/check-non-portable-shell: detect "FOO=bar shell_func" t/check-non-portable-shell: make error messages more compact t/check-non-portable-shell: stop being so polite t6046/t9833: fix use of "VAR=VAL cmd" with a shell functionmaint
commit
d1cd2205c2
|
@ -7,22 +7,43 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my $exit_code=0;
|
my $exit_code=0;
|
||||||
|
my %func;
|
||||||
|
|
||||||
sub err {
|
sub err {
|
||||||
my $msg = shift;
|
my $msg = shift;
|
||||||
|
s/^\s+//;
|
||||||
|
s/\s+$//;
|
||||||
|
s/\s+/ /g;
|
||||||
print "$ARGV:$.: error: $msg: $_\n";
|
print "$ARGV:$.: error: $msg: $_\n";
|
||||||
$exit_code = 1;
|
$exit_code = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# glean names of shell functions
|
||||||
|
for my $i (@ARGV) {
|
||||||
|
open(my $f, '<', $i) or die "$0: $i: $!\n";
|
||||||
|
while (<$f>) {
|
||||||
|
$func{$1} = 1 if /^\s*(\w+)\s*\(\)\s*{\s*$/;
|
||||||
|
}
|
||||||
|
close $f;
|
||||||
|
}
|
||||||
|
|
||||||
while (<>) {
|
while (<>) {
|
||||||
chomp;
|
chomp;
|
||||||
|
# stitch together incomplete lines (those ending with "\")
|
||||||
|
while (s/\\$//) {
|
||||||
|
$_ .= readline;
|
||||||
|
chomp;
|
||||||
|
}
|
||||||
|
|
||||||
/\bsed\s+-i/ and err 'sed -i is not portable';
|
/\bsed\s+-i/ and err 'sed -i is not portable';
|
||||||
/\becho\s+-[neE]/ and err 'echo with option is not portable (please use printf)';
|
/\becho\s+-[neE]/ and err 'echo with option is not portable (use printf)';
|
||||||
/^\s*declare\s+/ and err 'arrays/declare not portable';
|
/^\s*declare\s+/ and err 'arrays/declare not portable';
|
||||||
/^\s*[^#]\s*which\s/ and err 'which is not portable (please use type)';
|
/^\s*[^#]\s*which\s/ and err 'which is not portable (use type)';
|
||||||
/\btest\s+[^=]*==/ and err '"test a == b" is not portable (please use =)';
|
/\btest\s+[^=]*==/ and err '"test a == b" is not portable (use =)';
|
||||||
/\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (please use test_line_count)';
|
/\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (use test_line_count)';
|
||||||
/\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (please use FOO=bar && export FOO)';
|
/\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)';
|
||||||
|
/^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
|
||||||
|
err '"FOO=bar shell_func" assignment extends beyond "shell_func"';
|
||||||
# this resets our $. for each file
|
# this resets our $. for each file
|
||||||
close ARGV if eof;
|
close ARGV if eof;
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,7 +366,9 @@ test_expect_success '2c-check: Modify b & add c VS rename b->c' '
|
||||||
|
|
||||||
git checkout A^0 &&
|
git checkout A^0 &&
|
||||||
|
|
||||||
GIT_MERGE_VERBOSITY=3 test_must_fail git merge -s recursive B^0 >out 2>err &&
|
GIT_MERGE_VERBOSITY=3 &&
|
||||||
|
export GIT_MERGE_VERBOSITY &&
|
||||||
|
test_must_fail git merge -s recursive B^0 >out 2>err &&
|
||||||
|
|
||||||
test_i18ngrep "CONFLICT (rename/add): Rename b->c" out &&
|
test_i18ngrep "CONFLICT (rename/add): Rename b->c" out &&
|
||||||
test_i18ngrep ! "Skipped c" out &&
|
test_i18ngrep ! "Skipped c" out &&
|
||||||
|
|
|
@ -26,7 +26,9 @@ test_expect_success 'error handling' '
|
||||||
) &&
|
) &&
|
||||||
p4 passwd -P newpassword &&
|
p4 passwd -P newpassword &&
|
||||||
(
|
(
|
||||||
P4PASSWD=badpassword test_must_fail git p4 clone //depot/foo 2>errmsg &&
|
P4PASSWD=badpassword &&
|
||||||
|
export P4PASSWD &&
|
||||||
|
test_must_fail git p4 clone //depot/foo 2>errmsg &&
|
||||||
grep -q "failure accessing depot.*P4PASSWD" errmsg
|
grep -q "failure accessing depot.*P4PASSWD" errmsg
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
Loading…
Reference in New Issue