diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2021-12-09 00:11:05 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-12-13 10:29:48 -0800 |
commit | 0849541268a3aca9381591aed87b6864a203709b (patch) | |
tree | 00aa5e565425fd234928d17ad17e91c521d01d38 /t/t0020-crlf.sh | |
parent | tests: simplify construction of large blocks of text (diff) | |
download | tgif-0849541268a3aca9381591aed87b6864a203709b.tar.xz |
tests: use test_write_lines() to generate line-oriented output
Take advantage of test_write_lines() to generate line-oriented output
rather than using for-loops or a series of `echo` commands. Not only is
test_write_lines() a natural fit for such a task, but there is less
opportunity for a broken &&-chain.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0020-crlf.sh')
-rwxr-xr-x | t/t0020-crlf.sh | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh index f25ae8b5e1..0bd6ff21c8 100755 --- a/t/t0020-crlf.sh +++ b/t/t0020-crlf.sh @@ -22,10 +22,10 @@ test_expect_success setup ' git config core.autocrlf false && - for w in Hello world how are you; do echo $w; done >one && + test_write_lines Hello world how are you >one && mkdir dir && - for w in I am very very fine thank you; do echo $w; done >dir/two && - for w in Oh here is NULQin text here; do echo $w; done | q_to_nul >three && + test_write_lines I am very very fine thank you >dir/two && + test_write_lines Oh here is NULQin text here | q_to_nul >three && git add . && git commit -m initial && @@ -35,7 +35,7 @@ test_expect_success setup ' two=$(git rev-parse HEAD:dir/two) && three=$(git rev-parse HEAD:three) && - for w in Some extra lines here; do echo $w; done >>one && + test_write_lines Some extra lines here >>one && git diff >patch.file && patched=$(git hash-object --stdin <one) && git read-tree --reset -u HEAD @@ -46,7 +46,7 @@ test_expect_success 'safecrlf: autocrlf=input, all CRLF' ' git config core.autocrlf input && git config core.safecrlf true && - for w in I am all CRLF; do echo $w; done | append_cr >allcrlf && + test_write_lines I am all CRLF | append_cr >allcrlf && test_must_fail git add allcrlf ' @@ -55,7 +55,7 @@ test_expect_success 'safecrlf: autocrlf=input, mixed LF/CRLF' ' git config core.autocrlf input && git config core.safecrlf true && - for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >mixed && + test_write_lines Oh here is CRLFQ in text | q_to_cr >mixed && test_must_fail git add mixed ' @@ -64,7 +64,7 @@ test_expect_success 'safecrlf: autocrlf=true, all LF' ' git config core.autocrlf true && git config core.safecrlf true && - for w in I am all LF; do echo $w; done >alllf && + test_write_lines I am all LF >alllf && test_must_fail git add alllf ' @@ -73,7 +73,7 @@ test_expect_success 'safecrlf: autocrlf=true mixed LF/CRLF' ' git config core.autocrlf true && git config core.safecrlf true && - for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >mixed && + test_write_lines Oh here is CRLFQ in text | q_to_cr >mixed && test_must_fail git add mixed ' @@ -82,10 +82,10 @@ test_expect_success 'safecrlf: print warning only once' ' git config core.autocrlf input && git config core.safecrlf warn && - for w in I am all LF; do echo $w; done >doublewarn && + test_write_lines I am all LF >doublewarn && git add doublewarn && git commit -m "nowarn" && - for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >doublewarn && + test_write_lines Oh here is CRLFQ in text | q_to_cr >doublewarn && git add doublewarn 2>err && grep "CRLF will be replaced by LF" err >err.warnings && test_line_count = 1 err.warnings @@ -103,7 +103,7 @@ test_expect_success 'safecrlf: no warning with safecrlf=false' ' git config core.autocrlf input && git config core.safecrlf false && - for w in I am all CRLF; do echo $w; done | append_cr >allcrlf && + test_write_lines I am all CRLF | append_cr >allcrlf && git add allcrlf 2>err && test_must_be_empty err ' @@ -351,9 +351,9 @@ test_expect_success 'setting up for new autocrlf tests' ' git config core.autocrlf false && git config core.safecrlf false && rm -rf .????* * && - for w in I am all LF; do echo $w; done >alllf && - for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >mixed && - for w in I am all CRLF; do echo $w; done | append_cr >allcrlf && + test_write_lines I am all LF >alllf && + test_write_lines Oh here is CRLFQ in text | q_to_cr >mixed && + test_write_lines I am all CRLF | append_cr >allcrlf && git add -A . && git commit -m "alllf, allcrlf and mixed only" && git tag -a -m "message" autocrlf-checkpoint |