Skip to contentSkip to conversation

t8001, t8002: fix "blame -L :literal" test on NetBSD

PATCH In review René Scharfe 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 t8001, t8002: fix "blame -L :literal" test on NetBSD

Sub-test 42 of t8001 and t8002 ("blame -L :literal") fails on NetBSD with the following verbose output:

git annotate -L:main hello.c
Author F (expected 4, attributed 3) bad
Author G (expected 1, attributed 1) good

This is not caused by different behaviour of git blame or annotate on that platform, but by different test input, in turn caused by a sed command that forgets to add a newline on NetBSD. Here's the diff of the commit that adds "goodbye" to hello.c, for Linux:

	@@ -1,4 +1,5 @@
	 int main(int argc, const char *argv[])
	 {
		puts("hello");
	+		puts("goodbye");
	 }

We see that it adds an extra TAB, but that's not a problem. Here's the same on NetBSD:

	@@ -1,4 +1,4 @@
	 int main(int argc, const char *argv[])
	 {
		puts("hello");
	-}
	+		puts("goodbye");}

It also adds an extra TAB, but it is missing the newline character after the semicolon.

The following patch gets rid of the extra TAB at the beginning, but more importantly adds the missing newline at the end in a (hopefully) portable way, mentioned in http://sed.sourceforge.net/sedfaq4.html.
The diff becomes this, on both Linux and NetBSD:

	@@ -1,4 +1,5 @@
	 int main(int argc, const char *argv[])
	 {
		puts("hello");
	+	puts("goodbye");
	 }

---
This regression was introduced by 5a9830cb ("t8001/t8002 (blame):
add blame -L :funcname tests").

 t/annotate-tests.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
t/annotate-tests.sh +2 -2
index 0bfee00..d4e7f47 100644
@@ -245,8 +245,8 @@ test_expect_success 'setup -L :regex' '
 	git commit -m "hello" &&
 
 	mv hello.c hello.orig &&
-	sed -e "/}/i\\
-	Qputs(\"goodbye\");" <hello.orig | tr Q "\\t" >hello.c &&
+	sed -e "/}/ {x; s/$/Qputs(\"goodbye\");/; G;}" <hello.orig |
+	tr Q "\\t" >hello.c &&
 	GIT_AUTHOR_NAME="G" GIT_AUTHOR_EMAIL="[email protected]" \
 	git commit -a -m "goodbye" &&
 
Signature · 1 line
1.8.1.5
Acked-by on v1 1/1
#2 lore raw
In reply to René Scharfe
Quoted 12 lines · René Scharfe

Sub-test 42 of t8001 and t8002 ("blame -L :literal") fails on NetBSD with the following verbose output:

git annotate -L:main hello.c
Author F (expected 4, attributed 3) bad
Author G (expected 1, attributed 1) good

This is not caused by different behaviour of git blame or annotate on that platform, but by different test input, in turn caused by a sed command that forgets to add a newline on NetBSD. Here's the diff of the commit that adds "goodbye" to hello.c, for Linux:

Quoted 8 lines
        @@ -1,4 +1,5 @@
         int main(int argc, const char *argv[])
         {
                puts("hello");
        +               puts("goodbye");
         }

We see that it adds an extra TAB,

Curious. On Mac OS X, there is only a single tab.

Quoted 10 lines

but that's not a problem. Here's the
same on NetBSD:

        @@ -1,4 +1,4 @@
         int main(int argc, const char *argv[])
         {
                puts("hello");
        -}
        +               puts("goodbye");}
Quoted 6 lines

It also adds an extra TAB, but it is missing the newline character after the semicolon.

The following patch gets rid of the extra TAB at the beginning, but more importantly adds the missing newline at the end in a (hopefully) portable way, mentioned in http://sed.sourceforge.net/sedfaq4.html.

Tested on Mac OS X. Works correctly.

Quoted 22 lines

The diff becomes this, on both Linux and NetBSD:

        @@ -1,4 +1,5 @@
         int main(int argc, const char *argv[])
         {
                puts("hello");
        +       puts("goodbye");
         }

---
This regression was introduced by 5a9830cb ("t8001/t8002 (blame):
add blame -L :funcname tests").

 t/annotate-tests.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
t/annotate-tests.sh +0 -0
index 0bfee00..d4e7f47 100644

t/annotate-tests.sh test_expect_success 'setup -L :regex' ' · line 249

Quoted 7 lines
t/annotate-tests.sh +2 -2
@@ -245,8 +245,8 @@ test_expect_success 'setup -L :regex' '
        git commit -m "hello" &&
 
        mv hello.c hello.orig &&
-       sed -e "/}/i\\
-       Qputs(\"goodbye\");" <hello.orig | tr Q "\\t" >hello.c &&
+       sed -e "/}/ {x; s/$/Qputs(\"goodbye\");/; G;}" <hello.orig |
+       tr Q "\\t" >hello.c &&

Thanks.

Quoted 2 lines
t/annotate-tests.sh +0 -0
        GIT_AUTHOR_NAME="G" GIT_AUTHOR_EMAIL="[email protected]" \
        git commit -a -m "goodbye" &&