 56066523ed
			
		
	
	56066523ed
	
	
	
		
			
			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>
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			981 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			981 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| # LINT: single token; composite of multiple strings
 | |
| git config filter.rot13.smudge ./rot13.sh &&
 | |
| git config filter.rot13.clean ./rot13.sh &&
 | |
| 
 | |
| {
 | |
|     echo "*.t filter=rot13"
 | |
|     echo "*.i ident"
 | |
| } >.gitattributes &&
 | |
| 
 | |
| {
 | |
|     echo a b c d e f g h i j k l m
 | |
|     echo n o p q r s t u v w x y z
 | |
| # LINT: exit/enter string context and escaped-quote outside of string
 | |
|     echo '\''$Id$'\''
 | |
| } >test &&
 | |
| cat test >test.t &&
 | |
| cat test >test.o &&
 | |
| cat test >test.i &&
 | |
| git add test test.t test.i &&
 | |
| rm -f test test.t test.i &&
 | |
| git checkout -- test test.t test.i &&
 | |
| 
 | |
| echo "content-test2" >test2.o &&
 | |
| # LINT: exit/enter string context and escaped-quote outside of string
 | |
| echo "content-test3 - filename with special characters" >"test3 '\''sq'\'',\$x=.o"
 | |
| 
 | |
| # LINT: single token; composite of multiple strings
 | |
| downstream_url_for_sed=$(
 | |
| 	printf "%s\n" "$downstream_url" |
 | |
| # LINT: exit/enter string context; "&" inside string not command terminator
 | |
| 	sed -e '\''s/\\/\\\\/g'\'' -e '\''s/[[/.*^$]/\\&/g'\''
 | |
| )
 |