[BUG] t7004 (master) busted on Leopard

6 messages, 3 authors, 2016-06-15 · open the first message on its own page

[BUG] t7004 (master) busted on Leopard

From: Wincent Colaiuta <hidden>
Date: 2016-06-15 22:43:51

Commit 4d8b1dc850 added a couple of tests to t7004, and my testing  
reveals that this one has been broken on Leopard since then:

* FAIL 83: message in editor has initial comment
GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0

(Not sure whether this affects other platforms, or versions of Mac OS  
X prior to Leopard, as I only have one machine here.)

The problem is the version of sed that ships with Leopard fails to  
match the initial comment with this syntax:

sed -n "/^\(#\|\$\)/p" actual

An alternative that works is:

sed -n "/^[#\$]/p" actual

Can someone with knowledge of sed compatibility across multiple  
platforms suggest an alternative which will work on a wider range of  
systems?

Cheers,
Wincent

Re: [BUG] t7004 (master) busted on Leopard

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:51

Hi,

On Thu, 15 Nov 2007, Wincent Colaiuta wrote:
Commit 4d8b1dc850 added a couple of tests to t7004, and my testing reveals
that this one has been broken on Leopard since then:

* FAIL 83: message in editor has initial comment
GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
I think this is our good old friend, MacOSX' sed.  (Wasn't there a 
question today what's wrong with using sed?  I think this issue 
qualifies.)

I imagine that it is that MacOSX' sed is adding a trailing newline (not 
the regexp like you suggested).  Which means that "wc -l" would print "1".  
(You can see for yourself if you run the script with "sh -x ...".)

IMHO a good solution would be

	test -z "$(grep -e '^#' -e '^$' actual)"

Could you test, please?

Thanks,
Dscho

Re: [BUG] t7004 (master) busted on Leopard

From: David Kastrup <hidden>
Date: 2016-06-15 22:43:51

Johannes Schindelin [off-list ref] writes:
Hi,

On Thu, 15 Nov 2007, Wincent Colaiuta wrote:
quoted
Commit 4d8b1dc850 added a couple of tests to t7004, and my testing reveals
that this one has been broken on Leopard since then:

* FAIL 83: message in editor has initial comment
GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
I think this is our good old friend, MacOSX' sed.  (Wasn't there a 
question today what's wrong with using sed?  I think this issue 
qualifies.)
\| is not portable.  $ in groups is not portable.
I imagine that it is that MacOSX' sed is adding a trailing newline (not 
the regexp like you suggested).
I imagine it is one of the above.  Most sed's add trailing newlines.

-- 
David Kastrup

Re: [BUG] t7004 (master) busted on Leopard

From: Wincent Colaiuta <hidden>
Date: 2016-06-15 22:43:51

El 15/11/2007, a las 15:37, Johannes Schindelin escribió:
Hi,

On Thu, 15 Nov 2007, Wincent Colaiuta wrote:
quoted
Commit 4d8b1dc850 added a couple of tests to t7004, and my testing  
reveals
that this one has been broken on Leopard since then:

* FAIL 83: message in editor has initial comment
GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
I think this is our good old friend, MacOSX' sed.
Yes, that's exactly what I said in the part of my post that you didn't  
quote.
I imagine that it is that MacOSX' sed is adding a trailing newline  
(not
the regexp like you suggested).  Which means that "wc -l" would  
print "1".
(You can see for yourself if you run the script with "sh -x ...".)
Unless I am misreading the test, any output from "wc -l" that is  
greater than 0 will cause the test to pass, so even if it outputted  
"1" as you suggest then that wouldn't be the cause of the failure.

I do think the cause of the failure is the limited regexp syntax that  
sed accepts on Leopard; witness: on Mac OS X the following prints 0:

   echo "# hello" | sed -n "/^\(#\|\$\)/p" | wc -l

Whereas the following prints 1:

   echo "# hello" | sed -n "/^[#\$]/p" | wc -l

Here's the output for the failing test run under "sh -x" as you  
suggest, although I must admit that I can't really parse it myself.

+ test_expect_success 'message in editor has initial comment' '
	GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
	test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
'
+ test 2 = 2
+ test_skip 'message in editor has initial comment' '
	GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
	test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
'
++ expr ./t7004-tag.sh : '.*/\(t[0-9]*\)-[^/]*$'
+ this_test=t7004
++ expr 82 + 1
+ this_test=t7004.83
+ to_skip=
+ case "$to_skip" in
+ false
+ say 'expecting success:
	GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
	test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
'
+ say_color info 'expecting success:
	GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
	test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
'
+ case "$1" in
+ tput setaf 3
+ shift
+ echo '* expecting success:
	GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
	test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
'
+ tput sgr0
+ test_run_ '
	GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
	test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
'
+ eval '
	GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
	test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
'
+ eval_ret=1
+ return 0
+ '[' 0 = 0 -a 1 = 0 ']'
+ test_failure_ 'message in editor has initial comment' '
	GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
	test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
'
++ expr 82 + 1
+ test_count=83
++ expr 0 + 1
+ test_failure=1
+ say_color error 'FAIL 83: message in editor has initial comment'
+ case "$1" in
+ tput bold
+ tput setaf 1
+ shift
+ echo '* FAIL 83: message in editor has initial comment'
* FAIL 83: message in editor has initial comment
+ tput sgr0
+ shift
IMHO a good solution would be

	test -z "$(grep -e '^#' -e '^$' actual)"

Could you test, please?
Yes, the test passes with that, although it has to be written as  
follows in the actual test file seeing as it's inside a single-quoted  
string:

test -z "$(grep -e \"^#\" -e \"^$\" actual)"

Will follow this up with a patch that implements your proposed fix.

Cheers,
Wincent

[PATCH] Fix git-tag test breakage caused by broken sed on Leopard

From: Wincent Colaiuta <hidden>
Date: 2016-06-15 22:43:51

The 'message in editor has initial comment' test fails on Leopard (and
possibly on other versions of Mac OS X as well) due to the limited
sed syntax available on that platform.

Avoid the breakage by using grep instead (suggested by Johannes
Schindelin).

Signed-off-by: Wincent Colaiuta <redacted>
---
  t/t7004-tag.sh |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 096fe33..02ec9c3 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1007,7 +1007,7 @@ test_expect_failure \
  test_expect_success \
  	'message in editor has initial comment' '
  	GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
-	test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
+	test -z "$(grep -e \"^#\" -e \"^$\" actual)"
  '

  get_tag_header reuse $commit commit $time >expect
-- 
1.5.3.5

[PATCH v2] Fix git-tag test breakage caused by broken sed on Leopard

From: Wincent Colaiuta <hidden>
Date: 2016-06-15 22:43:51

The 'message in editor has initial comment' test fails on Leopard (and
possibly on other versions of Mac OS X as well) due to the limited
sed syntax available on that platform.

Avoid the breakage by using grep instead (suggested by Johannes
Schindelin).

Signed-off-by: Wincent Colaiuta <redacted>
---

The patch I previously sent had the test sense inverted (it used 'test  
-z' to test for an empty string when we should have actually been  
looking for a non-empty string), so it really only passed by mistake.  
This revised version maintains the sense of the original, sed-based  
test.

t/t7004-tag.sh |    2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 096fe33..b54c2e0 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1007,7 +1007,7 @@ test_expect_failure \
test_expect_success \
	'message in editor has initial comment' '
	GIT_EDITOR=cat git tag -a initial-comment > actual || true &&
-	test $(sed -n "/^\(#\|\$\)/p" actual | wc -l) -gt 0
+	test $(grep -e "^#" -e "^\$" actual | wc -l ) -gt 0
'

get_tag_header reuse $commit commit $time >expect
-- 
1.5.3.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help