]> git.ipfire.org Git - thirdparty/git.git/commit
t/chainlint: add more chainlint.pl self-tests
authorEric Sunshine <sunshine@sunshineco.com>
Thu, 1 Sep 2022 00:29:52 +0000 (00:29 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Sep 2022 17:07:41 +0000 (10:07 -0700)
commit56066523ed3ebd16b455e99ce954ec19b6ac5ada
treed288b24ba20d4ffc2571565289cfc81599af2b3a
parentae0c55abf8217bb06422f9eafcd7a30b2c8f9e8b
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>
34 files changed:
t/chainlint/blank-line-before-esac.expect [new file with mode: 0644]
t/chainlint/blank-line-before-esac.test [new file with mode: 0644]
t/chainlint/block.expect
t/chainlint/block.test
t/chainlint/chained-block.expect [new file with mode: 0644]
t/chainlint/chained-block.test [new file with mode: 0644]
t/chainlint/chained-subshell.expect [new file with mode: 0644]
t/chainlint/chained-subshell.test [new file with mode: 0644]
t/chainlint/command-substitution-subsubshell.expect [new file with mode: 0644]
t/chainlint/command-substitution-subsubshell.test [new file with mode: 0644]
t/chainlint/double-here-doc.expect [new file with mode: 0644]
t/chainlint/double-here-doc.test [new file with mode: 0644]
t/chainlint/dqstring-line-splice.expect [new file with mode: 0644]
t/chainlint/dqstring-line-splice.test [new file with mode: 0644]
t/chainlint/dqstring-no-interpolate.expect [new file with mode: 0644]
t/chainlint/dqstring-no-interpolate.test [new file with mode: 0644]
t/chainlint/empty-here-doc.expect [new file with mode: 0644]
t/chainlint/empty-here-doc.test [new file with mode: 0644]
t/chainlint/exclamation.expect [new file with mode: 0644]
t/chainlint/exclamation.test [new file with mode: 0644]
t/chainlint/for-loop-abbreviated.expect [new file with mode: 0644]
t/chainlint/for-loop-abbreviated.test [new file with mode: 0644]
t/chainlint/function.expect [new file with mode: 0644]
t/chainlint/function.test [new file with mode: 0644]
t/chainlint/here-doc-indent-operator.expect [new file with mode: 0644]
t/chainlint/here-doc-indent-operator.test [new file with mode: 0644]
t/chainlint/if-condition-split.expect [new file with mode: 0644]
t/chainlint/if-condition-split.test [new file with mode: 0644]
t/chainlint/one-liner-for-loop.expect [new file with mode: 0644]
t/chainlint/one-liner-for-loop.test [new file with mode: 0644]
t/chainlint/sqstring-in-sqstring.expect [new file with mode: 0644]
t/chainlint/sqstring-in-sqstring.test [new file with mode: 0644]
t/chainlint/token-pasting.expect [new file with mode: 0644]
t/chainlint/token-pasting.test [new file with mode: 0644]