t7004: modernize the style
v3 cover t7004: modernize the style
- remove whitespace after the redirect operators.
- move number of expect files prepared outside of test_expect_success to be inside the tests that use it.
- split some lines that have two commands into two lines one command each.
- turn some "<<\EOF" into "<<-\EOF" and indent their body.
- avoid using pipes in the output from "test-tool ref-store" and write the output to a file.
- change test_expect_success that are seperated from its name to be on the same line.
AbdAlRahman Gad (6):
[Newcomer] t7004-tag: redirection operator [Newcomer] t7004-tag: do not lose exit status to pipe [Newcomer] t7004-tag: one command per line [Newcomer] t7004-tag: do not prepare except outside
test_expect_success
[Newcomer] t7004-tag: here-doc modernization [Newcomer] t7004-tag: description on the same line as
test_expect_success
t/t7004-tag.sh | 584 +++++++++++++++++++++++-------------------------- 1 file changed, 274 insertions(+), 310 deletions(-)
base-commit: 406f326d271e0bacecdb00425422c5fa3f314930
Signature · 1 line
2.43.0
PATCH v3 1/6 t7004-tag: redirection operator
Modernaize 't7004-tag.sh' by removing whitespace
after the redirect operators.
--- t/t7004-tag.sh | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-)
t/t7004-tag.sh +25 -25
@@ -213,9 +213,9 @@ mytag EOF test_expect_success \ 'trying to delete tags without params should succeed and do nothing' ' - git tag -l > actual && test_cmp expect actual && + git tag -l >actual && test_cmp expect actual && git tag -d && - git tag -l > actual && test_cmp expect actual + git tag -l >actual && test_cmp expect actual ' test_expect_success \
@@ -269,9 +269,9 @@ test_expect_success 'listing all tags should print them ordered' ' git tag a1 && git tag v1.0 && git tag t210 && - git tag -l > actual && + git tag -l >actual && test_cmp expect actual && - git tag > actual && + git tag >actual && test_cmp expect actual '
@@ -283,7 +283,7 @@ EOF test_expect_success \ 'listing tags with substring as pattern must print those matching' ' rm *a* && - git tag -l "*a*" > current && + git tag -l "*a*" >current && test_cmp expect current '
@@ -293,7 +293,7 @@ v1.0.1 EOF test_expect_success \ 'listing tags with a suffix as pattern must print those matching' ' - git tag -l "*.1" > actual && + git tag -l "*.1" >actual && test_cmp expect actual '
@@ -303,7 +303,7 @@ t211 EOF test_expect_success \ 'listing tags with a prefix as pattern must print those matching' ' - git tag -l "t21*" > actual && + git tag -l "t21*" >actual && test_cmp expect actual '
@@ -312,7 +312,7 @@ a1 EOF test_expect_success \ 'listing tags using a name as pattern must print that one matching' ' - git tag -l a1 > actual && + git tag -l a1 >actual && test_cmp expect actual '
@@ -321,7 +321,7 @@ v1.0 EOF test_expect_success \ 'listing tags using a name as pattern must print that one matching' ' - git tag -l v1.0 > actual && + git tag -l v1.0 >actual && test_cmp expect actual '
@@ -331,13 +331,13 @@ v1.1.3 EOF test_expect_success \ 'listing tags with ? in the pattern should print those matching' ' - git tag -l "v1.?.?" > actual && + git tag -l "v1.?.?" >actual && test_cmp expect actual ' test_expect_success \ 'listing tags using v.* should print nothing because none have v.' ' - git tag -l "v.*" > actual && + git tag -l "v.*" >actual && test_must_be_empty actual '
@@ -349,7 +349,7 @@ v1.1.3 EOF test_expect_success \ 'listing tags using v* should print only those having v' ' - git tag -l "v*" > actual && + git tag -l "v*" >actual && test_cmp expect actual '
@@ -1171,7 +1171,7 @@ test_expect_success GPG \ git tag -v emptyfile-signed-tag ' -printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile +printf '\n\n \n\t\nLeading blank lines\n' >sigblanksfile printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
@@ -1569,7 +1569,7 @@ test_expect_success \ test_expect_success \ 'message in editor has initial comment' ' - ! (GIT_EDITOR=cat git tag -a initial-comment > actual) + ! (GIT_EDITOR=cat git tag -a initial-comment >actual) ' test_expect_success 'message in editor has initial comment: first line' '
@@ -1587,7 +1587,7 @@ test_expect_success \ ' get_tag_header reuse $commit commit $time >expect -echo "An annotation to be reused" >> expect +echo "An annotation to be reused" >>expect test_expect_success \ 'overwriting an annotated tag should use its previous body' ' git tag -a -m "An annotation to be reused" reuse &&
@@ -1639,7 +1639,7 @@ hash3=$(git rev-parse HEAD) # simple linear checks of --continue -cat > expected <<EOF +cat >expected <<EOF v0.2.1 v1.0 v1.0.1
@@ -1679,7 +1679,7 @@ test_expect_success 'checking that first commit is in all tags (relative)' " test_must_be_empty actual " -cat > expected <<EOF +cat >expected <<EOF v2.0 EOF
@@ -1688,7 +1688,7 @@ test_expect_success 'checking that second commit only has one tag' " test_cmp expected actual " -cat > expected <<EOF +cat >expected <<EOF v0.2.1 v1.0 v1.0.1
@@ -1705,7 +1705,7 @@ test_expect_success 'checking that third commit has no tags' " test_must_be_empty actual " -cat > expected <<EOF +cat >expected <<EOF v0.2.1 v1.0 v1.0.1
@@ -1723,14 +1723,14 @@ test_expect_success 'conversely --no-contains on the third commit lists all tags test_expect_success 'creating simple branch' ' git branch stable v2.0 && git checkout stable && - echo foo-3.0 > foo && + echo foo-3.0 >foo && git commit foo -m fourth && git tag v3.0 ' hash4=$(git rev-parse HEAD) -cat > expected <<EOF +cat >expected <<EOF v3.0 EOF
@@ -1739,7 +1739,7 @@ test_expect_success 'checking that branch head only has one tag' " test_cmp expected actual " -cat > expected <<EOF +cat >expected <<EOF v0.2.1 v1.0 v1.0.1
@@ -1757,7 +1757,7 @@ test_expect_success 'merging original branch into this branch' ' git tag v4.0 ' -cat > expected <<EOF +cat >expected <<EOF v4.0 EOF
@@ -1766,7 +1766,7 @@ test_expect_success 'checking that original branch head has one tag now' " test_cmp expected actual " -cat > expected <<EOF +cat >expected <<EOF v0.2.1 v1.0 v1.0.1
@@ -1780,7 +1780,7 @@ test_expect_success 'checking that original branch head with --no-contains lists test_cmp expected actual " -cat > expected <<EOF +cat >expected <<EOF v0.2.1 v1.0 v1.0.1
Signature · 1 line
2.43.0
Re: [PATCH v3 1/6] [Newcomer] t7004-tag: redirection operator
Quoted 1 line · AbdAlRahman Gad
Modernaize '
t7004-tag.sh' by removing whitespace
s/Modernaize/Modernize.
Quoted 1 line
after the redirect operators.
Also, please note that we typically wrap commit messages after 72 characters.
It would also be helpful to make the commit subject a bit more informative. Right now you only say "redirection operation", which doesn't really give the reader much of a clue what the commit does to those. Better would be something like
t7004: remove space after redirect operator
This gives the reader a much better signal of what the patch does.
Patrick
PATCH v3 2/6 t7004-tag: do not lose exit status to pipe
In reply to AbdAlRahman Gadsplit "test-tool ... | sed" pipeline into two commands to avoid losing exit status from test-tool
--- t/t7004-tag.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
t/t7004-tag.sh +4 -2
@@ -97,7 +97,8 @@ test_expect_success 'creating a tag with --create-reflog should create reflog' ' test_when_finished "git tag -d tag_with_reflog1" && git tag --create-reflog tag_with_reflog1 && git reflog exists refs/tags/tag_with_reflog1 && - test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 | sed -e "s/^.* //" >actual && + test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 >actual.body && + sed -e "s/^.* //" actual.body >actual && test_cmp expected actual '
@@ -108,7 +109,8 @@ test_expect_success 'annotated tag with --create-reflog has correct message' ' test_when_finished "git tag -d tag_with_reflog2" && git tag -m "annotated tag" --create-reflog tag_with_reflog2 && git reflog exists refs/tags/tag_with_reflog2 && - test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog2 | sed -e "s/^.* //" >actual && + test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog2 >actual.body && + sed -e "s/^.* //" actual.body >actual && test_cmp expected actual '
Signature · 1 line
2.43.0
Re: [PATCH v3 2/6] [Newcomer] t7004-tag: do not lose exit status to pipe
Quoted 2 lines · AbdAlRahman Gad
split "test-tool ... | sed" pipeline into two commands to avoid losing exit status from test-tool
The commit body should be a full sentence and thus should start with an upper-case letter and end with punctuation.
I'd also drop the "-tag" from "t7004-tag" in the commit subject, as we typically only mention the tag number.
Patrick
PATCH v3 3/6 t7004-tag: one command per line
In reply to AbdAlRahman Gadfix lines like these:
git tag -l >actual && test_cmp expect actual &&
to
git tag -l >actual &&test_cmp expect actual &&
--- t/t7004-tag.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
t/t7004-tag.sh +4 -2
@@ -215,9 +215,11 @@ mytag EOF test_expect_success \ 'trying to delete tags without params should succeed and do nothing' ' - git tag -l >actual && test_cmp expect actual && + git tag -l >actual && + test_cmp expect actual && git tag -d && - git tag -l >actual && test_cmp expect actual + git tag -l >actual && + test_cmp expect actual ' test_expect_success \
Signature · 1 line
2.43.0
Re: [PATCH v3 3/6] [Newcomer] t7004-tag: one command per line
Quoted 8 lines · AbdAlRahman Gad
fix lines like these:
git tag -l >actual &&
test_cmpexpect actual &&to
git tag -l >actual &&
test_cmpexpect actual &&
Same remark here regarding the style of this commit message. I also think that the message is both overly verbose and not telling enough at the same point in time, because you require the reader to implicitly derive what the change is that you are doing. Proposal:
One of the tests in t7004 has multiple commands on a single line, which is discouraged. Adapt these by splitting up these into one line per command.
Patrick
PATCH v3 4/6 t7004-tag: do not prepare except outside test_expect_success
In reply to AbdAlRahman Gaddo not prepare expect outside test_expect_success
--- t/t7004-tag.sh | 224 +++++++++++++++++++++++++++---------------------- 1 file changed, 123 insertions(+), 101 deletions(-)
t/t7004-tag.sh +123 -101
@@ -131,10 +131,10 @@ test_expect_success 'listing all tags if one exists should succeed' ' git tag ' -cat >expect <<EOF -mytag -EOF test_expect_success 'Multiple -l or --list options are equivalent to one -l option' ' + cat >expect <<-\EOF && + mytag + EOF git tag -l -l >actual && test_cmp expect actual && git tag --list --list >actual &&
@@ -209,12 +209,12 @@ test_expect_success 'trying to delete an unknown tag should fail' ' test_must_fail git tag -d unknown-tag ' -cat >expect <<EOF -myhead -mytag -EOF test_expect_success \ 'trying to delete tags without params should succeed and do nothing' ' + cat >expect <<-\EOF && + myhead + mytag + EOF git tag -l >actual && test_cmp expect actual && git tag -d &&
@@ -252,18 +252,18 @@ test_expect_success 'trying to delete an already deleted tag should fail' \ # listing various tags with pattern matching: -cat >expect <<EOF -a1 -aa1 -cba -t210 -t211 -v0.2.1 -v1.0 -v1.0.1 -v1.1.3 -EOF test_expect_success 'listing all tags should print them ordered' ' + cat >expect <<-\EOF && + a1 + aa1 + cba + t210 + t211 + v0.2.1 + v1.0 + v1.0.1 + v1.1.3 + EOF git tag v1.0.1 && git tag t211 && git tag aa1 &&
@@ -279,62 +279,62 @@ test_expect_success 'listing all tags should print them ordered' ' test_cmp expect actual ' -cat >expect <<EOF -a1 -aa1 -cba -EOF test_expect_success \ 'listing tags with substring as pattern must print those matching' ' + cat >expect <<-\EOF && + a1 + aa1 + cba + EOF rm *a* && git tag -l "*a*" >current && test_cmp expect current ' -cat >expect <<EOF -v0.2.1 -v1.0.1 -EOF test_expect_success \ 'listing tags with a suffix as pattern must print those matching' ' + cat >expect <<-\EOF && + v0.2.1 + v1.0.1 + EOF git tag -l "*.1" >actual && test_cmp expect actual ' -cat >expect <<EOF -t210 -t211 -EOF test_expect_success \ 'listing tags with a prefix as pattern must print those matching' ' + cat >expect <<-\EOF && + t210 + t211 + EOF git tag -l "t21*" >actual && test_cmp expect actual ' -cat >expect <<EOF -a1 -EOF test_expect_success \ 'listing tags using a name as pattern must print that one matching' ' + cat >expect <<-\EOF && + a1 + EOF git tag -l a1 >actual && test_cmp expect actual ' -cat >expect <<EOF -v1.0 -EOF test_expect_success \ 'listing tags using a name as pattern must print that one matching' ' + cat >expect <<-\EOF && + v1.0 + EOF git tag -l v1.0 >actual && test_cmp expect actual ' -cat >expect <<EOF -v1.0.1 -v1.1.3 -EOF test_expect_success \ 'listing tags with ? in the pattern should print those matching' ' + cat >expect <<-\EOF && + v1.0.1 + v1.1.3 + EOF git tag -l "v1.?.?" >actual && test_cmp expect actual '
@@ -345,19 +345,25 @@ test_expect_success \ test_must_be_empty actual ' -cat >expect <<EOF -v0.2.1 -v1.0 -v1.0.1 -v1.1.3 -EOF test_expect_success \ 'listing tags using v* should print only those having v' ' + cat >expect <<-\EOF && + v0.2.1 + v1.0 + v1.0.1 + v1.1.3 + EOF git tag -l "v*" >actual && test_cmp expect actual ' test_expect_success 'tag -l can accept multiple patterns' ' + cat >expect <<-\EOF && + v0.2.1 + v1.0 + v1.0.1 + v1.1.3 + EOF git tag -l "v1*" "v0*" >actual && test_cmp expect actual '
@@ -371,6 +377,12 @@ test_expect_success 'tag -l can accept multiple patterns' ' # out if we're going to break this long-documented form of taking # multiple patterns. test_expect_success 'tag -l <pattern> -l <pattern> works, as our buggy documentation previously suggested' ' + cat >expect <<-\EOF && + v0.2.1 + v1.0 + v1.0.1 + v1.1.3 + EOF git tag -l "v1*" -l "v0*" >actual && test_cmp expect actual '
@@ -1683,23 +1695,21 @@ test_expect_success 'checking that first commit is in all tags (relative)' " test_must_be_empty actual " -cat >expected <<EOF -v2.0 -EOF - test_expect_success 'checking that second commit only has one tag' " + cat >expected <<-\EOF && + v2.0 + EOF git tag -l --contains $hash2 v* >actual && test_cmp expected actual " -cat >expected <<EOF -v0.2.1 -v1.0 -v1.0.1 -v1.1.3 -EOF - test_expect_success 'inverse of the last test, with --no-contains' " + cat >expected <<-\EOF && + v0.2.1 + v1.0 + v1.0.1 + v1.1.3 + EOF git tag -l --no-contains $hash2 v* >actual && test_cmp expected actual "
@@ -1709,15 +1719,14 @@ test_expect_success 'checking that third commit has no tags' " test_must_be_empty actual " -cat >expected <<EOF -v0.2.1 -v1.0 -v1.0.1 -v1.1.3 -v2.0 -EOF - test_expect_success 'conversely --no-contains on the third commit lists all tags' " + cat >expected <<-\EOF && + v0.2.1 + v1.0 + v1.0.1 + v1.1.3 + v2.0 + EOF git tag -l --no-contains $hash3 v* >actual && test_cmp expected actual "
@@ -1734,24 +1743,22 @@ test_expect_success 'creating simple branch' ' hash4=$(git rev-parse HEAD) -cat >expected <<EOF -v3.0 -EOF - test_expect_success 'checking that branch head only has one tag' " + cat >expected <<-\EOF && + v3.0 + EOF git tag -l --contains $hash4 v* >actual && test_cmp expected actual " -cat >expected <<EOF -v0.2.1 -v1.0 -v1.0.1 -v1.1.3 -v2.0 -EOF - test_expect_success 'checking that branch head with --no-contains lists all but one tag' " + cat >expected <<-\EOF && + v0.2.1 + v1.0 + v1.0.1 + v1.1.3 + v2.0 + EOF git tag -l --no-contains $hash4 v* >actual && test_cmp expected actual "
@@ -1761,50 +1768,65 @@ test_expect_success 'merging original branch into this branch' ' git tag v4.0 ' -cat >expected <<EOF -v4.0 -EOF - test_expect_success 'checking that original branch head has one tag now' " + cat >expected <<-\EOF && + v4.0 + EOF git tag -l --contains $hash3 v* >actual && test_cmp expected actual " -cat >expected <<EOF -v0.2.1 -v1.0 -v1.0.1 -v1.1.3 -v2.0 -v3.0 -EOF - test_expect_success 'checking that original branch head with --no-contains lists all but one tag now' " + cat >expected <<-\EOF && + v0.2.1 + v1.0 + v1.0.1 + v1.1.3 + v2.0 + v3.0 + EOF git tag -l --no-contains $hash3 v* >actual && test_cmp expected actual " -cat >expected <<EOF -v0.2.1 -v1.0 -v1.0.1 -v1.1.3 -v2.0 -v3.0 -v4.0 -EOF - test_expect_success 'checking that initial commit is in all tags' " + cat >expected <<-\EOF && + v0.2.1 + v1.0 + v1.0.1 + v1.1.3 + v2.0 + v3.0 + v4.0 + EOF git tag -l --contains $hash1 v* >actual && test_cmp expected actual " test_expect_success 'checking that --contains can be used in non-list mode' ' + cat >expected <<-\EOF && + v0.2.1 + v1.0 + v1.0.1 + v1.1.3 + v2.0 + v3.0 + v4.0 + EOF git tag --contains $hash1 v* >actual && test_cmp expected actual ' test_expect_success 'checking that initial commit is in all tags with --no-contains' " + cat >expected <<-\EOF && + v0.2.1 + v1.0 + v1.0.1 + v1.1.3 + v2.0 + v3.0 + v4.0 + EOF git tag -l --no-contains $hash1 v* >actual && test_must_be_empty actual "
Signature · 1 line
2.43.0
Re: [PATCH v3 4/6] [Newcomer] t7004-tag: do not prepare except outside test_expect_success
Quoted 6 lines · AbdAlRahman Gad
do not prepare expect outside
test_expect_successSigned-off-by AbdAlRahman Gad <[email protected]>---
t/t7004-tag.sh test_expect_success 'listing all tags if one exists should succeed' ' · line 135
Quoted 8 lines
t/t7004-tag.sh +3
-3@@ -131,10 +131,10 @@ test_expect_success 'listing all tags if one exists should succeed' ' -cat >expect <<EOF -mytag -EOF test_expect_success 'Multiple -l or --list options are equivalent to one -l option' ' + cat >expect <<-\EOF && + mytag + EOF git tag -l -l >actual &&
This patch also changes bare EOF to \EOF which correctly signals to the reader that no variable interpolation or other processing is happening inside the here-doc body. Such a change of semantics is significant enough that it normally warrants mention in the commit message. In fact, often the EOF to \EOF change would be done in its own commit. However, it's probably not worth a reroll in this case; v3 is likely a good place to stop unless a reviewer finds a problem which demands v4.
Re: [PATCH v3 4/6] [Newcomer] t7004-tag: do not prepare except outside test_expect_success
Quoted 16 lines · Eric Sunshine
Quoted 6 lines · AbdAlRahman Gad
do not prepare expect outside
test_expect_successSigned-off-by AbdAlRahman Gad <[email protected]>---
t/t7004-tag.sh test_expect_success 'listing all tags if one exists should succeed' ' · line 135
Quoted 8 lines
t/t7004-tag.sh +3
-3@@ -131,10 +131,10 @@ test_expect_success 'listing all tags if one exists should succeed' ' -cat >expect <<EOF -mytag -EOF test_expect_success 'Multiple -l or --list options are equivalent to one -l option' ' + cat >expect <<-\EOF && + mytag + EOF git tag -l -l >actual &&
Quoted 8 lines
This patch also changes bare
EOFto\EOFwhich correctly signals to the reader that no variable interpolation or other processing is happening inside the here-doc body. Such a change of semantics is significant enough that it normally warrants mention in the commit message. In fact, often theEOFto\EOFchange would be done in its own commit. However, it's probably not worth a reroll in this case; v3 is likely a good place to stop unless a reviewer finds a problem which demands v4.
Thanks for the feedback.
I'll keep that in mind in the upcoming patches.
Re: [PATCH v3 4/6] [Newcomer] t7004-tag: do not prepare except outside test_expect_success
In reply to AbdAlRahman GadThere are other "prepare for next test" remaining even after applying this patch, though.
Quoted 9 lines
t/t7004-tag.sh +0
-3-cat >expect <<EOF -mytag -EOF test_expect_success 'Multiple -l or --list options are equivalent to one -l option' '
t/t7004-tag.sh test_expect_success 'listing all tags if one exists should succeed' '
Quoted 10 lines
t/t7004-tag.sh +3
-0+ cat >expect <<-\EOF && + mytag + EOF git tag -l -l >actual && test_cmp expect actual && git tag --list --list >actual && test_cmp expect actual && git tag --list -l --list >actual && test_cmp expect actual '
Good.
Quoted 6 lines
t/t7004-tag.sh +0
-4-cat >expect <<EOF -myhead -mytag -EOF test_expect_success \ 'trying to delete tags without params should succeed and do nothing' '
t/t7004-tag.sh test_expect_success 'trying to delete an unknown tag should fail' '
Quoted 10 lines
t/t7004-tag.sh +4
-0+ cat >expect <<-\EOF && + myhead + mytag + EOF git tag -l >actual && test_cmp expect actual && git tag -d && git tag -l >actual && test_cmp expect actual '
Good too.
Quoted 18 lines
# creating annotated tags:
get_tag_msg() {t/t7004-tag.sh +0
-0git cat-file tag "$1" | sed -e "/BEGIN PGP/q" } # run test_tick before committing always gives the time in that timezone get_tag_header () { cat <<EOF object $2 type $3 tag $1 tagger C O Mitter <[email protected]> $4 -0700 EOF } commit=$(git rev-parse HEAD)
t/t7004-tag.sh
Quoted 10 lines
t/t7004-tag.sh +0
-0time=$test_tick get_tag_header annotated-tag $commit commit $time >expect echo "A message" >>expect test_expect_success \ 'creating an annotated tag with -m message should succeed' ' git tag -m "A message" annotated-tag && get_tag_msg annotated-tag >actual && test_cmp expect actual '
The creation of $commit, holding the timestamp in $time, calling the get_tag_header helper helper function, and addition of the message to 'expect' file. Moving all of them inside expect_success block is perfectly in line with the theme of this step.
t/t7004-tag.sh
Quoted 10 lines
get_tag_headerannotated-tag-edit $commit commit $time >expect echo "An edited message" >>expecttest_expect_success'set up editor' 't/t7004-tag.sh +0
-0write_script fakeeditor <<-\EOF sed -e "s/A message/An edited message/g" <"$1" >"$1-" mv "$1-" "$1" EOF ' test_expect_success \
Ditto here. In addition, there is a blank line lacking after the above test piece and before the next one.
t/t7004-tag.sh
Quoted 12 lines
cat >msgfile <<EOF
Another message
in a file.
EOF
get_tag_headerfile-annotated-tag $commit commit $time >expect cat msgfile >>expect
test_expect_success\t/t7004-tag.sh +0
-0'creating an annotated tag with -F messagefile should succeed' ' git tag -F msgfile file-annotated-tag && get_tag_msg file-annotated-tag >actual && test_cmp expect actual '
Ditto.
Quoted 16 lines
get_tag_headerfile-annotated-tag-edit $commit commit $time >expect sed -e "s/Another message/Another edited message/g" msgfile >>expecttest_expect_success'set up editor' 't/t7004-tag.sh +0
-0write_script fakeeditor <<-\EOF sed -e "s/Another message/Another edited message/g" <"$1" >"$1-" mv "$1-" "$1" EOF ' test_expect_success \ 'creating an annotated tag with -F messagefile --edit should succeed' ' GIT_EDITOR=./fakeeditor git tag -F msgfile --edit file-annotated-tag-edit && get_tag_msg file-annotated-tag-edit >actual && test_cmp expect actual ' cat >inputmsg <<EOF
t/t7004-tag.sh
Quoted 10 lines
t/t7004-tag.sh +0
-0A message from the standard input EOF get_tag_header stdin-annotated-tag $commit commit $time >expect cat inputmsg >>expect test_expect_success 'creating an annotated tag with -F - should succeed' ' git tag -F - stdin-annotated-tag <inputmsg && get_tag_msg stdin-annotated-tag >actual && test_cmp expect actual '
Ditto.
Quoted 29 lines
# blank and empty messages:
get_tag_headerempty-annotated-tag $commit commit $time >expecttest_expect_success\t/t7004-tag.sh +0
-0'creating a tag with an empty -m message should succeed' ' git tag -m "" empty-annotated-tag && get_tag_msg empty-annotated-tag >actual && test_cmp expect actual ' >emptyfile get_tag_header emptyfile-annotated-tag $commit commit $time >expect test_expect_success \ 'creating a tag with an empty -F messagefile should succeed' ' git tag -F emptyfile emptyfile-annotated-tag && get_tag_msg emptyfile-annotated-tag >actual && test_cmp expect actual ' printf '\n\n \n\t\nLeading blank lines\n' >blanksfile printf '\n\t \t \nRepeated blank lines\n' >>blanksfile printf '\n\n\nTrailing spaces \t \n' >>blanksfile printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile get_tag_header blanks-annotated-tag $commit commit $time >expect cat >>expect <<EOF Leading blank lines Repeated blank lines
t/t7004-tag.sh
Quoted 10 lines
t/t7004-tag.sh +0
-0Trailing spaces Trailing blank lines EOF test_expect_success \ 'extra blanks in the message for an annotated tag should be removed' ' git tag -F blanksfile blanks-annotated-tag && get_tag_msg blanks-annotated-tag >actual && test_cmp expect actual '
Ditto.
Quoted 52 lines
get_tag_headerblank-annotated-tag $commit commit $time >expecttest_expect_success\t/t7004-tag.sh +0
-0'creating a tag with blank -m message with spaces should succeed' ' git tag -m " " blank-annotated-tag && get_tag_msg blank-annotated-tag >actual && test_cmp expect actual ' echo ' ' >blankfile echo '' >>blankfile echo ' ' >>blankfile get_tag_header blankfile-annotated-tag $commit commit $time >expect test_expect_success \ 'creating a tag with blank -F messagefile with spaces should succeed' ' git tag -F blankfile blankfile-annotated-tag && get_tag_msg blankfile-annotated-tag >actual && test_cmp expect actual ' printf ' ' >blanknonlfile get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect test_expect_success \ 'creating a tag with -F file of spaces and no newline should succeed' ' git tag -F blanknonlfile blanknonlfile-annotated-tag && get_tag_msg blanknonlfile-annotated-tag >actual && test_cmp expect actual ' # messages with commented lines: cat >commentsfile <<EOF # A comment ############ The message. ############ One line. # commented lines # commented lines Another line. # comments Last line. EOF get_tag_header comments-annotated-tag $commit commit $time >expect cat >>expect <<EOF The message. One line.
t/t7004-tag.sh
Quoted 10 lines
t/t7004-tag.sh +0
-0Another line. Last line. EOF test_expect_success \ 'creating a tag using a -F messagefile with #comments should succeed' ' git tag -F commentsfile comments-annotated-tag && get_tag_msg comments-annotated-tag >actual && test_cmp expect actual '
Ditto.
Quoted 17 lines
get_tag_headercomment-annotated-tag $commit commit $time >expecttest_expect_success\t/t7004-tag.sh +0
-0'creating a tag with a #comment in the -m message should succeed' ' git tag -m "#comment" comment-annotated-tag && get_tag_msg comment-annotated-tag >actual && test_cmp expect actual ' echo '#comment' >commentfile echo '' >>commentfile echo '####' >>commentfile get_tag_header commentfile-annotated-tag $commit commit $time >expect test_expect_success \ 'creating a tag with #comments in the -F messagefile should succeed' ' git tag -F commentfile commentfile-annotated-tag && get_tag_msg commentfile-annotated-tag >actual && test_cmp expect actual
t/t7004-tag.sh
Quoted 10 lines
t/t7004-tag.sh +0
-0' printf '#comment' >commentnonlfile get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect test_expect_success \ 'creating a tag with a file of #comment and no newline should succeed' ' git tag -F commentnonlfile commentnonlfile-annotated-tag && get_tag_msg commentnonlfile-annotated-tag >actual && test_cmp expect actual '
Ditto.
t/t7004-tag.sh
Quoted 7 lines
echo 'tag line one' >annotagmsg
echo 'tag line two' >>annotagmsg
echo 'tag line three' >>annotagmsg
test_expect_success\t/t7004-tag.sh +0
-0'listing many message lines of a non-signed tag should succeed' ' git tag -F annotagmsg tag-lines &&
Ditto.
t/t7004-tag.sh test_expect_success 'listing all tags should print them ordered' ' · line 280
Quoted 10 lines
# creating and verifying signed tags:
get_tag_headersigned-tag $commit commit $time >expect
echo 'A signed tag message' >>expect
echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_successGPG 'creating a signed tag with -m message should succeed' 't/t7004-tag.sh +0
-0git tag -s -m "A signed tag message" signed-tag && get_tag_msg signed-tag >actual && test_cmp expect actual '
Ditto.
t/t7004-tag.sh test_expect_success 'listing all tags should print them ordered' ' · line 292
Quoted 10 lines
get_tag_headeru-signed-tag $commit commit $time >expect echo 'Another message' >>expect
echo '-----BEGIN PGP SIGNATURE-----' >>expecttest_expect_successGPG 'sign with a given key id' 't/t7004-tag.sh +0
-0git tag -u [email protected] -m "Another message" u-signed-tag && get_tag_msg u-signed-tag >actual && test_cmp expect actual '
Ditto.
If it is too much to include all of the above in the same patch I think it would be OK to stop at "move prepatation of the expect file using cat and here-doc into test_expect_success block", as long as we make it clear in the log message that we are drawing the line there in the patch, and leaving other similar issues untouched to keep the step manageably short. Adding a new patch to clean up the "other similar issues" is entirely optional, but doing so would make the series even more thorough.
Thanks.
PATCH v3 5/6 t7004-tag: here-doc modernization
In reply to AbdAlRahman Gaduse <<-\EOF to indent here-doc
--- t/t7004-tag.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
t/t7004-tag.sh +19 -19
@@ -389,10 +389,10 @@ test_expect_success 'tag -l <pattern> -l <pattern> works, as our buggy documenta test_expect_success 'listing tags in column' ' COLUMNS=41 git tag -l --column=row >actual && - cat >expected <<\EOF && -a1 aa1 cba t210 t211 -v0.2.1 v1.0 v1.0.1 v1.1.3 -EOF + cat >expected <<-\EOF && + a1 aa1 cba t210 t211 + v0.2.1 v1.0 v1.0.1 v1.1.3 + EOF test_cmp expected actual '
@@ -400,10 +400,10 @@ test_expect_success 'listing tags in column with column.*' ' test_config column.tag row && test_config column.ui dense && COLUMNS=40 git tag -l >actual && - cat >expected <<\EOF && -a1 aa1 cba t210 t211 -v0.2.1 v1.0 v1.0.1 v1.1.3 -EOF + cat >expected <<-\EOF && + a1 aa1 cba t210 t211 + v0.2.1 v1.0 v1.0.1 v1.1.3 + EOF test_cmp expected actual '
@@ -414,17 +414,17 @@ test_expect_success 'listing tag with -n --column should fail' ' test_expect_success 'listing tags -n in column with column.ui ignored' ' test_config column.ui "row dense" && COLUMNS=40 git tag -l -n >actual && - cat >expected <<\EOF && -a1 Foo -aa1 Foo -cba Foo -t210 Foo -t211 Foo -v0.2.1 Foo -v1.0 Foo -v1.0.1 Foo -v1.1.3 Foo -EOF + cat >expected <<-\EOF && + a1 Foo + aa1 Foo + cba Foo + t210 Foo + t211 Foo + v0.2.1 Foo + v1.0 Foo + v1.0.1 Foo + v1.1.3 Foo + EOF test_cmp expected actual '
Signature · 1 line
2.43.0
Re: [PATCH v3 5/6] [Newcomer] t7004-tag: here-doc modernization
Quoted 1 line · AbdAlRahman Gad
use <<-\EOF to indent here-doc
Instead of what? It would help to mention that the change converts from <<\EOF to <<\-EOF, where the latter allows us to indent the body.
I'd also suggest a commit title like "t7004: use indented here docs", as "here doc modernizations" doesn't quite give you a hint what the modernization looks like.
Patrick
PATCH v3 6/6 t7004-tag: description on the same line as test_expect_success
In reply to AbdAlRahman Gadchanged test_expect_success that are seperated from its name like:
test_expect_success \
'trying to delete tags without params ....' '
test_expect_success GPG \
'trying to verify an annotated ....' '
to
test_expect_success 'trying to delete tags without params ....' '
test_expect_success GPG 'trying to verify an annotated.... ' '
--- t/t7004-tag.sh | 280 +++++++++++++++++++------------------------------ 1 file changed, 109 insertions(+), 171 deletions(-)
t/t7004-tag.sh +109 -171
@@ -156,26 +156,25 @@ test_expect_success 'listing a tag using a matching pattern should succeed' \ test_expect_success 'listing a tag with --ignore-case' \ 'test $(git tag -l --ignore-case MYTAG) = mytag' -test_expect_success \ - 'listing a tag using a matching pattern should output that tag' \ - 'test $(git tag -l mytag) = mytag' +test_expect_success 'listing a tag using a matching pattern should output that tag' ' + test $(git tag -l mytag) = mytag +' -test_expect_success \ - 'listing tags using a non-matching pattern should succeed' \ - 'git tag -l xxx' +test_expect_success 'listing tags using a non-matching pattern should succeed' ' + git tag -l xxx +' -test_expect_success \ - 'listing tags using a non-matching pattern should output nothing' \ - 'test $(git tag -l xxx | wc -l) -eq 0' +test_expect_success 'listing tags using a non-matching pattern should output nothing' ' + test $(git tag -l xxx | wc -l) -eq 0 +' # special cases for creating tags: -test_expect_success \ - 'trying to create a tag with the name of one existing should fail' \ - 'test_must_fail git tag mytag' +test_expect_success 'trying to create a tag with the name of one existing should fail' ' + test_must_fail git tag mytag +' -test_expect_success \ - 'trying to create a tag with a non-valid name should fail' ' +test_expect_success 'trying to create a tag with a non-valid name should fail' ' test $(git tag -l | wc -l) -eq 1 && test_must_fail git tag "" && test_must_fail git tag .othertag &&
@@ -209,8 +208,7 @@ test_expect_success 'trying to delete an unknown tag should fail' ' test_must_fail git tag -d unknown-tag ' -test_expect_success \ - 'trying to delete tags without params should succeed and do nothing' ' +test_expect_success 'trying to delete tags without params should succeed and do nothing' ' cat >expect <<-\EOF && myhead mytag
@@ -222,8 +220,7 @@ test_expect_success \ test_cmp expect actual ' -test_expect_success \ - 'deleting two existing tags in one command should succeed' ' +test_expect_success 'deleting two existing tags in one command should succeed' ' tag_exists mytag && tag_exists myhead && git tag -d mytag myhead &&
@@ -231,15 +228,13 @@ test_expect_success \ ! tag_exists myhead ' -test_expect_success \ - 'creating a tag with the name of another deleted one should succeed' ' +test_expect_success 'creating a tag with the name of another deleted one should succeed' ' ! tag_exists mytag && git tag mytag && tag_exists mytag ' -test_expect_success \ - 'trying to delete two tags, existing and not, should fail in the 2nd' ' +test_expect_success 'trying to delete two tags, existing and not, should fail in the 2nd' ' tag_exists mytag && ! tag_exists nonexistingtag && test_must_fail git tag -d mytag nonexistingtag &&
@@ -279,8 +274,7 @@ test_expect_success 'listing all tags should print them ordered' ' test_cmp expect actual ' -test_expect_success \ - 'listing tags with substring as pattern must print those matching' ' +test_expect_success 'listing tags with substring as pattern must print those matching' ' cat >expect <<-\EOF && a1 aa1
@@ -291,8 +285,7 @@ test_expect_success \ test_cmp expect current ' -test_expect_success \ - 'listing tags with a suffix as pattern must print those matching' ' +test_expect_success 'listing tags with a suffix as pattern must print those matching' ' cat >expect <<-\EOF && v0.2.1 v1.0.1
@@ -301,8 +294,7 @@ test_expect_success \ test_cmp expect actual ' -test_expect_success \ - 'listing tags with a prefix as pattern must print those matching' ' +test_expect_success 'listing tags with a prefix as pattern must print those matching' ' cat >expect <<-\EOF && t210 t211
@@ -311,8 +303,7 @@ test_expect_success \ test_cmp expect actual ' -test_expect_success \ - 'listing tags using a name as pattern must print that one matching' ' +test_expect_success 'listing tags using a name as pattern must print that one matching' ' cat >expect <<-\EOF && a1 EOF
@@ -320,8 +311,7 @@ test_expect_success \ test_cmp expect actual ' -test_expect_success \ - 'listing tags using a name as pattern must print that one matching' ' +test_expect_success 'listing tags using a name as pattern must print that one matching' ' cat >expect <<-\EOF && v1.0 EOF
@@ -329,8 +319,7 @@ test_expect_success \ test_cmp expect actual ' -test_expect_success \ - 'listing tags with ? in the pattern should print those matching' ' +test_expect_success 'listing tags with ? in the pattern should print those matching' ' cat >expect <<-\EOF && v1.0.1 v1.1.3
@@ -339,14 +328,12 @@ test_expect_success \ test_cmp expect actual ' -test_expect_success \ - 'listing tags using v.* should print nothing because none have v.' ' +test_expect_success 'listing tags using v.* should print nothing because none have v.' ' git tag -l "v.*" >actual && test_must_be_empty actual ' -test_expect_success \ - 'listing tags using v* should print only those having v' ' +test_expect_success 'listing tags using v* should print only those having v' ' cat >expect <<-\EOF && v0.2.1 v1.0
@@ -430,23 +417,23 @@ test_expect_success 'listing tags -n in column with column.ui ignored' ' # creating and verifying lightweight tags: -test_expect_success \ - 'a non-annotated tag created without parameters should point to HEAD' ' +test_expect_success 'a non-annotated tag created without parameters should point to HEAD' ' git tag non-annotated-tag && test $(git cat-file -t non-annotated-tag) = commit && test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD) ' -test_expect_success 'trying to verify an unknown tag should fail' \ - 'test_must_fail git tag -v unknown-tag' +test_expect_success 'trying to verify an unknown tag should fail' ' + test_must_fail git tag -v unknown-tag +' -test_expect_success \ - 'trying to verify a non-annotated and non-signed tag should fail' \ - 'test_must_fail git tag -v non-annotated-tag' +test_expect_success 'trying to verify a non-annotated and non-signed tag should fail' ' + test_must_fail git tag -v non-annotated-tag +' -test_expect_success \ - 'trying to verify many non-annotated or unknown tags, should fail' \ - 'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2' +test_expect_success 'trying to verify many non-annotated or unknown tags, should fail' ' + test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2 +' # creating annotated tags:
@@ -470,8 +457,7 @@ time=$test_tick get_tag_header annotated-tag $commit commit $time >expect echo "A message" >>expect -test_expect_success \ - 'creating an annotated tag with -m message should succeed' ' +test_expect_success 'creating an annotated tag with -m message should succeed' ' git tag -m "A message" annotated-tag && get_tag_msg annotated-tag >actual && test_cmp expect actual
@@ -485,8 +471,7 @@ test_expect_success 'set up editor' ' mv "$1-" "$1" EOF ' -test_expect_success \ - 'creating an annotated tag with -m message --edit should succeed' ' +test_expect_success 'creating an annotated tag with -m message --edit should succeed' ' GIT_EDITOR=./fakeeditor git tag -m "A message" --edit annotated-tag-edit && get_tag_msg annotated-tag-edit >actual && test_cmp expect actual
@@ -498,8 +483,7 @@ in a file. EOF get_tag_header file-annotated-tag $commit commit $time >expect cat msgfile >>expect -test_expect_success \ - 'creating an annotated tag with -F messagefile should succeed' ' +test_expect_success 'creating an annotated tag with -F messagefile should succeed' ' git tag -F msgfile file-annotated-tag && get_tag_msg file-annotated-tag >actual && test_cmp expect actual
@@ -513,8 +497,7 @@ test_expect_success 'set up editor' ' mv "$1-" "$1" EOF ' -test_expect_success \ - 'creating an annotated tag with -F messagefile --edit should succeed' ' +test_expect_success 'creating an annotated tag with -F messagefile --edit should succeed' ' GIT_EDITOR=./fakeeditor git tag -F msgfile --edit file-annotated-tag-edit && get_tag_msg file-annotated-tag-edit >actual && test_cmp expect actual
@@ -532,16 +515,14 @@ test_expect_success 'creating an annotated tag with -F - should succeed' ' test_cmp expect actual ' -test_expect_success \ - 'trying to create a tag with a non-existing -F file should fail' ' +test_expect_success 'trying to create a tag with a non-existing -F file should fail' ' ! test -f nonexistingfile && ! tag_exists notag && test_must_fail git tag -F nonexistingfile notag && ! tag_exists notag ' -test_expect_success \ - 'trying to create tags giving both -m or -F options should fail' ' +test_expect_success 'trying to create tags giving both -m or -F options should fail' ' echo "message file 1" >msgfile1 && ! tag_exists msgtag && test_must_fail git tag -m "message 1" -F msgfile1 msgtag &&
@@ -556,8 +537,7 @@ test_expect_success \ # blank and empty messages: get_tag_header empty-annotated-tag $commit commit $time >expect -test_expect_success \ - 'creating a tag with an empty -m message should succeed' ' +test_expect_success 'creating a tag with an empty -m message should succeed' ' git tag -m "" empty-annotated-tag && get_tag_msg empty-annotated-tag >actual && test_cmp expect actual
@@ -565,8 +545,7 @@ test_expect_success \ >emptyfile get_tag_header emptyfile-annotated-tag $commit commit $time >expect -test_expect_success \ - 'creating a tag with an empty -F messagefile should succeed' ' +test_expect_success 'creating a tag with an empty -F messagefile should succeed' ' git tag -F emptyfile emptyfile-annotated-tag && get_tag_msg emptyfile-annotated-tag >actual && test_cmp expect actual
@@ -586,16 +565,14 @@ Trailing spaces Trailing blank lines EOF -test_expect_success \ - 'extra blanks in the message for an annotated tag should be removed' ' +test_expect_success 'extra blanks in the message for an annotated tag should be removed' ' git tag -F blanksfile blanks-annotated-tag && get_tag_msg blanks-annotated-tag >actual && test_cmp expect actual ' get_tag_header blank-annotated-tag $commit commit $time >expect -test_expect_success \ - 'creating a tag with blank -m message with spaces should succeed' ' +test_expect_success 'creating a tag with blank -m message with spaces should succeed' ' git tag -m " " blank-annotated-tag && get_tag_msg blank-annotated-tag >actual && test_cmp expect actual
@@ -605,8 +582,7 @@ echo ' ' >blankfile echo '' >>blankfile echo ' ' >>blankfile get_tag_header blankfile-annotated-tag $commit commit $time >expect -test_expect_success \ - 'creating a tag with blank -F messagefile with spaces should succeed' ' +test_expect_success 'creating a tag with blank -F messagefile with spaces should succeed' ' git tag -F blankfile blankfile-annotated-tag && get_tag_msg blankfile-annotated-tag >actual && test_cmp expect actual
@@ -614,8 +590,7 @@ test_expect_success \ printf ' ' >blanknonlfile get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect -test_expect_success \ - 'creating a tag with -F file of spaces and no newline should succeed' ' +test_expect_success 'creating a tag with -F file of spaces and no newline should succeed' ' git tag -F blanknonlfile blanknonlfile-annotated-tag && get_tag_msg blanknonlfile-annotated-tag >actual && test_cmp expect actual
@@ -649,16 +624,14 @@ Another line. Last line. EOF -test_expect_success \ - 'creating a tag using a -F messagefile with #comments should succeed' ' +test_expect_success 'creating a tag using a -F messagefile with #comments should succeed' ' git tag -F commentsfile comments-annotated-tag && get_tag_msg comments-annotated-tag >actual && test_cmp expect actual ' get_tag_header comment-annotated-tag $commit commit $time >expect -test_expect_success \ - 'creating a tag with a #comment in the -m message should succeed' ' +test_expect_success 'creating a tag with a #comment in the -m message should succeed' ' git tag -m "#comment" comment-annotated-tag && get_tag_msg comment-annotated-tag >actual && test_cmp expect actual
@@ -668,8 +641,7 @@ echo '#comment' >commentfile echo '' >>commentfile echo '####' >>commentfile get_tag_header commentfile-annotated-tag $commit commit $time >expect -test_expect_success \ - 'creating a tag with #comments in the -F messagefile should succeed' ' +test_expect_success 'creating a tag with #comments in the -F messagefile should succeed' ' git tag -F commentfile commentfile-annotated-tag && get_tag_msg commentfile-annotated-tag >actual && test_cmp expect actual
@@ -677,8 +649,7 @@ test_expect_success \ printf '#comment' >commentnonlfile get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect -test_expect_success \ - 'creating a tag with a file of #comment and no newline should succeed' ' +test_expect_success 'creating a tag with a file of #comment and no newline should succeed' ' git tag -F commentnonlfile commentnonlfile-annotated-tag && get_tag_msg commentnonlfile-annotated-tag >actual && test_cmp expect actual
@@ -795,8 +766,7 @@ test_expect_success 'bad editor causes panic when only --trailer is given' ' # listing messages for annotated non-signed tags: -test_expect_success \ - 'listing the one-line message of a non-signed tag should succeed' ' +test_expect_success 'listing the one-line message of a non-signed tag should succeed' ' git tag -m "A msg" tag-one-line && echo "tag-one-line" >expect &&
@@ -835,8 +805,7 @@ test_expect_success 'The -n 100 invocation means -n --list 100, not -n100' ' test_cmp expect actual ' -test_expect_success \ - 'listing the zero-lines message of a non-signed tag should succeed' ' +test_expect_success 'listing the zero-lines message of a non-signed tag should succeed' ' git tag -m "" tag-zero-lines && echo "tag-zero-lines" >expect &&
@@ -863,8 +832,7 @@ test_expect_success \ echo 'tag line one' >annotagmsg echo 'tag line two' >>annotagmsg echo 'tag line three' >>annotagmsg -test_expect_success \ - 'listing many message lines of a non-signed tag should succeed' ' +test_expect_success 'listing many message lines of a non-signed tag should succeed' ' git tag -F annotagmsg tag-lines && echo "tag-lines" >expect &&
@@ -952,20 +920,17 @@ test_expect_success 'git tag --format with ahead-behind' ' # trying to verify annotated non-signed tags: -test_expect_success GPG \ - 'trying to verify an annotated non-signed tag should fail' ' +test_expect_success GPG 'trying to verify an annotated non-signed tag should fail' ' tag_exists annotated-tag && test_must_fail git tag -v annotated-tag ' -test_expect_success GPG \ - 'trying to verify a file-annotated non-signed tag should fail' ' +test_expect_success GPG 'trying to verify a file-annotated non-signed tag should fail' ' tag_exists file-annotated-tag && test_must_fail git tag -v file-annotated-tag ' -test_expect_success GPG \ - 'trying to verify two annotated non-signed tags should fail' ' +test_expect_success GPG 'trying to verify two annotated non-signed tags should fail' ' tag_exists annotated-tag file-annotated-tag && test_must_fail git tag -v annotated-tag file-annotated-tag '
@@ -1029,8 +994,7 @@ EOF get_tag_header file-signed-tag $commit commit $time >expect cat sigmsgfile >>expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag with -F messagefile should succeed' ' +test_expect_success GPG 'creating a signed tag with -F messagefile should succeed' ' git tag -s -F sigmsgfile file-signed-tag && get_tag_msg file-signed-tag >actual && test_cmp expect actual
@@ -1061,17 +1025,15 @@ test_expect_success GPG '-s implies annotated tag' ' get_tag_header forcesignannotated-implied-sign $commit commit $time >expect echo "A message" >>expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'git tag -s implied if configured with tag.forcesignannotated' \ - 'test_config tag.forcesignannotated true && +test_expect_success GPG 'git tag -s implied if configured with tag.forcesignannotated' ' + test_config tag.forcesignannotated true && git tag -m "A message" forcesignannotated-implied-sign && get_tag_msg forcesignannotated-implied-sign >actual && test_cmp expect actual ' -test_expect_success GPG \ - 'lightweight with no message when configured with tag.forcesignannotated' \ - 'test_config tag.forcesignannotated true && +test_expect_success GPG 'lightweight with no message when configured with tag.forcesignannotated' ' + test_config tag.forcesignannotated true && git tag forcesignannotated-lightweight && tag_exists forcesignannotated-lightweight && test_must_fail git tag -v forcesignannotated-no-message
@@ -1079,9 +1041,8 @@ test_expect_success GPG \ get_tag_header forcesignannotated-annotate $commit commit $time >expect echo "A message" >>expect -test_expect_success GPG \ - 'git tag -a disable configured tag.forcesignannotated' \ - 'test_config tag.forcesignannotated true && +test_expect_success GPG 'git tag -a disable configured tag.forcesignannotated' ' + test_config tag.forcesignannotated true && git tag -a -m "A message" forcesignannotated-annotate && get_tag_msg forcesignannotated-annotate >actual && test_cmp expect actual &&
@@ -1091,9 +1052,8 @@ test_expect_success GPG \ get_tag_header forcesignannotated-disabled $commit commit $time >expect echo "A message" >>expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'git tag --sign enable GPG sign' \ - 'test_config tag.forcesignannotated false && +test_expect_success GPG 'git tag --sign enable GPG sign' ' + test_config tag.forcesignannotated false && git tag --sign -m "A message" forcesignannotated-disabled && get_tag_msg forcesignannotated-disabled >actual && test_cmp expect actual
@@ -1102,9 +1062,8 @@ test_expect_success GPG \ get_tag_header gpgsign-enabled $commit commit $time >expect echo "A message" >>expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'git tag configured tag.gpgsign enables GPG sign' \ - 'test_config tag.gpgsign true && +test_expect_success GPG 'git tag configured tag.gpgsign enables GPG sign' ' + test_config tag.gpgsign true && git tag -m "A message" gpgsign-enabled && get_tag_msg gpgsign-enabled>actual && test_cmp expect actual
@@ -1112,30 +1071,29 @@ test_expect_success GPG \ get_tag_header no-sign $commit commit $time >expect echo "A message" >>expect -test_expect_success GPG \ - 'git tag --no-sign configured tag.gpgsign skip GPG sign' \ - 'test_config tag.gpgsign true && +test_expect_success GPG 'git tag --no-sign configured tag.gpgsign skip GPG sign' ' + test_config tag.gpgsign true && git tag -a --no-sign -m "A message" no-sign && get_tag_msg no-sign>actual && test_cmp expect actual ' -test_expect_success GPG \ - 'trying to create a signed tag with non-existing -F file should fail' ' +test_expect_success GPG 'trying to create a signed tag with non-existing -F file should fail' ' ! test -f nonexistingfile && ! tag_exists nosigtag && test_must_fail git tag -s -F nonexistingfile nosigtag && ! tag_exists nosigtag ' -test_expect_success GPG 'verifying a signed tag should succeed' \ - 'git tag -v signed-tag' +test_expect_success GPG 'verifying a signed tag should succeed' ' + git tag -v signed-tag +' -test_expect_success GPG 'verifying two signed tags in one command should succeed' \ - 'git tag -v signed-tag file-signed-tag' +test_expect_success GPG 'verifying two signed tags in one command should succeed' ' + git tag -v signed-tag file-signed-tag +' -test_expect_success GPG \ - 'verifying many signed and non-signed tags should fail' ' +test_expect_success GPG 'verifying many signed and non-signed tags should fail' ' test_must_fail git tag -v signed-tag annotated-tag && test_must_fail git tag -v file-annotated-tag file-signed-tag && test_must_fail git tag -v annotated-tag \
@@ -1168,8 +1126,7 @@ test_expect_success GPG 'verifying a forged tag with --format should fail silent get_tag_header empty-signed-tag $commit commit $time >expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag with an empty -m message should succeed' ' +test_expect_success GPG 'creating a signed tag with an empty -m message should succeed' ' git tag -s -m "" empty-signed-tag && get_tag_msg empty-signed-tag >actual && test_cmp expect actual &&
@@ -1179,8 +1136,7 @@ test_expect_success GPG \ >sigemptyfile get_tag_header emptyfile-signed-tag $commit commit $time >expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag with an empty -F messagefile should succeed' ' +test_expect_success GPG 'creating a signed tag with an empty -F messagefile should succeed' ' git tag -s -F sigemptyfile emptyfile-signed-tag && get_tag_msg emptyfile-signed-tag >actual && test_cmp expect actual &&
@@ -1202,8 +1158,7 @@ Trailing spaces Trailing blank lines EOF echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'extra blanks in the message for a signed tag should be removed' ' +test_expect_success GPG 'extra blanks in the message for a signed tag should be removed' ' git tag -s -F sigblanksfile blanks-signed-tag && get_tag_msg blanks-signed-tag >actual && test_cmp expect actual &&
@@ -1212,8 +1167,7 @@ test_expect_success GPG \ get_tag_header blank-signed-tag $commit commit $time >expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag with a blank -m message should succeed' ' +test_expect_success GPG 'creating a signed tag with a blank -m message should succeed' ' git tag -s -m " " blank-signed-tag && get_tag_msg blank-signed-tag >actual && test_cmp expect actual &&
@@ -1225,8 +1179,7 @@ echo '' >>sigblankfile echo ' ' >>sigblankfile get_tag_header blankfile-signed-tag $commit commit $time >expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag with blank -F file with spaces should succeed' ' +test_expect_success GPG 'creating a signed tag with blank -F file with spaces should succeed' ' git tag -s -F sigblankfile blankfile-signed-tag && get_tag_msg blankfile-signed-tag >actual && test_cmp expect actual &&
@@ -1236,8 +1189,7 @@ test_expect_success GPG \ printf ' ' >sigblanknonlfile get_tag_header blanknonlfile-signed-tag $commit commit $time >expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag with spaces and no newline should succeed' ' +test_expect_success GPG 'creating a signed tag with spaces and no newline should succeed' ' git tag -s -F sigblanknonlfile blanknonlfile-signed-tag && get_tag_msg blanknonlfile-signed-tag >actual && test_cmp expect actual &&
@@ -1284,8 +1236,7 @@ Another line. Last line. EOF echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag with a -F file with #comments should succeed' ' +test_expect_success GPG 'creating a signed tag with a -F file with #comments should succeed' ' git tag -s -F sigcommentsfile comments-signed-tag && get_tag_msg comments-signed-tag >actual && test_cmp expect actual &&
@@ -1294,8 +1245,7 @@ test_expect_success GPG \ get_tag_header comment-signed-tag $commit commit $time >expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag with #commented -m message should succeed' ' +test_expect_success GPG 'creating a signed tag with #commented -m message should succeed' ' git tag -s -m "#comment" comment-signed-tag && get_tag_msg comment-signed-tag >actual && test_cmp expect actual &&
@@ -1307,8 +1257,7 @@ echo '' >>sigcommentfile echo '####' >>sigcommentfile get_tag_header commentfile-signed-tag $commit commit $time >expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag with #commented -F messagefile should succeed' ' +test_expect_success GPG 'creating a signed tag with #commented -F messagefile should succeed' ' git tag -s -F sigcommentfile commentfile-signed-tag && get_tag_msg commentfile-signed-tag >actual && test_cmp expect actual &&
@@ -1318,8 +1267,7 @@ test_expect_success GPG \ printf '#comment' >sigcommentnonlfile get_tag_header commentnonlfile-signed-tag $commit commit $time >expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag with a #comment and no newline should succeed' ' +test_expect_success GPG 'creating a signed tag with a #comment and no newline should succeed' ' git tag -s -F sigcommentnonlfile commentnonlfile-signed-tag && get_tag_msg commentnonlfile-signed-tag >actual && test_cmp expect actual &&
@@ -1328,8 +1276,7 @@ test_expect_success GPG \ # listing messages for signed tags: -test_expect_success GPG \ - 'listing the one-line message of a signed tag should succeed' ' +test_expect_success GPG 'listing the one-line message of a signed tag should succeed' ' git tag -s -m "A message line signed" stag-one-line && echo "stag-one-line" >expect &&
@@ -1353,8 +1300,7 @@ test_expect_success GPG \ test_cmp expect actual ' -test_expect_success GPG \ - 'listing the zero-lines message of a signed tag should succeed' ' +test_expect_success GPG 'listing the zero-lines message of a signed tag should succeed' ' git tag -s -m "" stag-zero-lines && echo "stag-zero-lines" >expect &&
@@ -1381,8 +1327,7 @@ test_expect_success GPG \ echo 'stag line one' >sigtagmsg echo 'stag line two' >>sigtagmsg echo 'stag line three' >>sigtagmsg -test_expect_success GPG \ - 'listing many message lines of a signed tag should succeed' ' +test_expect_success GPG 'listing many message lines of a signed tag should succeed' ' git tag -s -F sigtagmsg stag-lines && echo "stag-lines" >expect &&
@@ -1431,8 +1376,7 @@ tag=$(git rev-parse signed-tag 2>/dev/null) get_tag_header tree-signed-tag $tree tree $time >expect echo "A message for a tree" >>expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag pointing to a tree should succeed' ' +test_expect_success GPG 'creating a signed tag pointing to a tree should succeed' ' git tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} && get_tag_msg tree-signed-tag >actual && test_cmp expect actual
@@ -1441,8 +1385,7 @@ test_expect_success GPG \ get_tag_header blob-signed-tag $blob blob $time >expect echo "A message for a blob" >>expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag pointing to a blob should succeed' ' +test_expect_success GPG 'creating a signed tag pointing to a blob should succeed' ' git tag -s -m "A message for a blob" blob-signed-tag HEAD:foo && get_tag_msg blob-signed-tag >actual && test_cmp expect actual
@@ -1451,8 +1394,7 @@ test_expect_success GPG \ get_tag_header tag-signed-tag $tag tag $time >expect echo "A message for another tag" >>expect echo '-----BEGIN PGP SIGNATURE-----' >>expect -test_expect_success GPG \ - 'creating a signed tag pointing to another tag should succeed' ' +test_expect_success GPG 'creating a signed tag pointing to another tag should succeed' ' git tag -s -m "A message for another tag" tag-signed-tag signed-tag && get_tag_msg tag-signed-tag >actual && test_cmp expect actual
@@ -1528,16 +1470,16 @@ test_expect_success GPG,RFC1991 \ ' # try to sign with bad user.signingkey -test_expect_success GPG \ - 'git tag -s fails if gpg is misconfigured (bad key)' \ - 'test_config user.signingkey BobTheMouse && - test_must_fail git tag -s -m tail tag-gpg-failure' +test_expect_success GPG 'git tag -s fails if gpg is misconfigured (bad key)' ' + test_config user.signingkey BobTheMouse && + test_must_fail git tag -s -m tail tag-gpg-failure +' # try to produce invalid signature -test_expect_success GPG \ - 'git tag -s fails if gpg is misconfigured (bad signature format)' \ - 'test_config gpg.program echo && - test_must_fail git tag -s -m tail tag-gpg-failure' +test_expect_success GPG 'git tag -s fails if gpg is misconfigured (bad signature format)' ' + test_config gpg.program echo && + test_must_fail git tag -s -m tail tag-gpg-failure +' # try to produce invalid signature test_expect_success GPG 'git verifies tag is valid with double signature' '
@@ -1574,17 +1516,15 @@ test_expect_success GPGSM \ # try to verify without gpg: rm -rf gpghome -test_expect_success GPG \ - 'verify signed tag fails when public key is not present' \ - 'test_must_fail git tag -v signed-tag' +test_expect_success GPG 'verify signed tag fails when public key is not present' ' + test_must_fail git tag -v signed-tag +' -test_expect_success \ - 'git tag -a fails if tag annotation is empty' ' +test_expect_success 'git tag -a fails if tag annotation is empty' ' ! (GIT_EDITOR=cat git tag -a initial-comment) ' -test_expect_success \ - 'message in editor has initial comment' ' +test_expect_success 'message in editor has initial comment' ' ! (GIT_EDITOR=cat git tag -a initial-comment >actual) '
@@ -1595,8 +1535,7 @@ test_expect_success 'message in editor has initial comment: first line' ' test_cmp first.expect first.actual ' -test_expect_success \ - 'message in editor has initial comment: remainder' ' +test_expect_success 'message in editor has initial comment: remainder' ' # remove commented lines from the remainder -- should be empty sed -e 1d -e "/^#/d" <actual >rest.actual && test_must_be_empty rest.actual
@@ -1604,8 +1543,7 @@ test_expect_success \ get_tag_header reuse $commit commit $time >expect echo "An annotation to be reused" >>expect -test_expect_success \ - 'overwriting an annotated tag should use its previous body' ' +test_expect_success 'overwriting an annotated tag should use its previous body' ' git tag -a -m "An annotation to be reused" reuse && GIT_EDITOR=true git tag -f -a reuse && get_tag_msg reuse >actual &&
Signature · 1 line
2.43.0
Re: [PATCH v3 6/6] [Newcomer] t7004-tag: description on the same line as test_expect_success
Quoted 1 line · AbdAlRahman Gad
changed
test_expect_successthat are seperated from its name like:
We do not say "changed something to something", but rather use imperative wording as if we were instructing the code itself to change. So maybe something like the following:
There are several tests in t7004 where the test description that follows test_expect_success is on a separate line, violating our coding style. Adapt these to be on the same line.
Patrick