@matheusbsbs / matheus-bagliano / commits / eb9d2b91cf
Fork 0

Fix and improve t7004 (git-tag tests)

Brown paper bag fix to avoid using non portable sed syntax. The test by itself didn't catch what it was supposed to, anyways. The new test first checks if git-tag correctly errors out when the user exited the editor without editing the file. Then it checks if what the user was presented in the editor was any useful, which we define as the following: * It begins with a single blank line, where the invoked editor would typically place the editing curser at, so that the user can immediately start typing; * It has some instruction but that comes after that initial blank line, all lines prefixed with "#". We specifically do not check for the wording of this instruction. * And it has nothing else, as the expected behaviour is "Hey you did not leave any message". Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Mike Hommey committed Nov 16, 2007 at 23:02 UTC eb9d2b91cf12b92ab45855702965f3bc384462f9
1 file changed +12 -2
t/t7004-tag.sh
+12 -2
@@ -1004,10 +1004,20 @@ test_expect_failure \
1004 'verify signed tag fails when public key is not present' \
1005 'git-tag -v signed-tag'
1006
1007 +test_expect_failure \
1008 + 'git-tag -a fails if tag annotation is empty' '
1009 + GIT_EDITOR=cat git tag -a initial-comment
1010 +'
1011 +
1012 test_expect_success \
1013 'message in editor has initial comment' '
1009 - GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
1010 - test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
1014 + GIT_EDITOR=cat git tag -a initial-comment > actual
1015 + # check the first line --- should be empty
1016 + first=$(sed -e 1q <actual) &&
1017 + test -z "$first" &&
1018 + # remove commented lines from the remainder -- should be empty
1019 + rest=$(sed -e 1d -e '/^#/d' <actual) &&
1020 + test -z "$rest"
1021 '
1022
1023 get_tag_header reuse $commit commit $time >expect