diff options
| author | Eric Sunshine <sunshine@sunshineco.com> | 2022-09-01 00:29:52 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-09-01 10:07:41 -0700 |
| commit | 56066523ed3ebd16b455e99ce954ec19b6ac5ada (patch) | |
| tree | d288b24ba20d4ffc2571565289cfc81599af2b3a /t/chainlint/function.test | |
| parent | ae0c55abf8217bb06422f9eafcd7a30b2c8f9e8b (diff) | |
| download | git-56066523ed3ebd16b455e99ce954ec19b6ac5ada.tar.gz | |
t/chainlint: add more chainlint.pl self-tests
During the development of chainlint.pl, numerous new self-tests were
created to verify correct functioning beyond the checks already
represented by the existing self-tests. The new checks fall into several
categories:
* behavior of the lexical analyzer for complex cases, such as line
splicing, token pasting, entering and exiting string contexts inside
and outside of test script bodies; for instance:
test_expect_success 'title' '
x=$(echo "something" |
sed -e '\''s/\\/\\\\/g'\'' -e '\''s/[[/.*^$]/\\&/g'\''
'
* behavior of the parser for all compound grammatical constructs, such
as `if...fi`, `case...esac`, `while...done`, `{...}`, etc., and for
other legal shell grammatical constructs not covered by existing
chainlint.sed self-tests, as well as complex cases, such as:
OUT=$( ((large_git 1>&3) | :) 3>&1 ) &&
* detection of problems, such as &&-chain breakage, from top-level to
any depth since the existing self-tests do not cover any top-level
context and only cover subshells one level deep due to limitations of
chainlint.sed
* address blind spots in chainlint.sed (such as not detecting a broken
&&-chain on a one-line for-loop in a subshell[1]) which chainlint.pl
correctly detects
* real-world cases which tripped up chainlint.pl during its development
[1]: https://lore.kernel.org/git/dce35a47012fecc6edc11c68e91dbb485c5bc36f.1661663880.git.gitgitgadget@gmail.com/
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/chainlint/function.test')
| -rw-r--r-- | t/chainlint/function.test | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/t/chainlint/function.test b/t/chainlint/function.test new file mode 100644 index 0000000000..5ee59562c9 --- /dev/null +++ b/t/chainlint/function.test @@ -0,0 +1,13 @@ +# LINT: "()" in function definition not mistaken for subshell +sha1_file() { + echo "$*" | sed "s#..#.git/objects/&/#" +} && + +# LINT: broken &&-chain in function and after function +remove_object() { + file=$(sha1_file "$*") && + test -e "$file" + rm -f "$file" +} + +sha1_file arg && remove_object arg |
