Skip to contentSkip to conversation

gitweb/gitweb.perl: remove use of qw(...) as parentheses

PATCH New Ævar Arnfjörð Bjarmason 3 participants 15 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb/gitweb.perl: remove use of qw(...) as parentheses

Using the qw(...) construct as implicit parentheses was deprecated in perl 5.13.5. Change the relevant code in gitweb to not use the deprecated construct. The offending code was introduced in 3562198b by Jakub Narebski.

The issue is that perl will now warn about this:

    $ perl -wE 'for my $i qw(a b) { say $i }'
    Use of qw(...) as parentheses is deprecated at -e line 1.
    a
    b

This caused gitweb.perl to warn on perl 5.13.5 and above, and these tests to fail on those perl versions:

    ./t9501-gitweb-standalone-http-status.sh           (Wstat: 256 Tests: 11 Failed: 10)
      Failed tests:  2-11
      Non-zero exit status: 1
    ./t9502-gitweb-standalone-parse-output.sh          (Wstat: 256 Tests: 10 Failed: 9)
      Failed tests:  2-10
      Non-zero exit status: 1
    ./t9500-gitweb-standalone-no-errors.sh             (Wstat: 256 Tests: 90 Failed: 84)
      Failed tests:  1-8, 10-36, 38-45, 47-48, 50-88
      Non-zero exit status: 1
---
 gitweb/gitweb.perl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
gitweb/gitweb.perl +2 -2
index 0779f12..b02372c 100755
@@ -3501,7 +3501,7 @@ sub print_feed_meta {
 			$href_params{'-title'} = 'log';
 		}
 
-		foreach my $format qw(RSS Atom) {
+		foreach my $format (qw(RSS Atom)) {
 			my $type = lc($format);
 			my %link_attr = (
 				'-rel' => 'alternate',
@@ -3682,7 +3682,7 @@ sub git_footer_html {
 		}
 		$href_params{'-title'} ||= 'log';
 
-		foreach my $format qw(RSS Atom) {
+		foreach my $format (qw(RSS Atom)) {
 			$href_params{'action'} = lc($format);
 			print $cgi->a({-href => href(%href_params),
 			              -title => "$href_params{'-title'} $format feed",
Signature · 1 line
1.7.2.3
#1 lore raw

v2 cover Fix failure-causing warnings in Gitweb + improve gitweb-lib.sh

Ignore the previous patch series to fix the qw(...) warning. I missed some spots.

Ævar Arnfjörð Bjarmason (3):
t/gitweb-lib.sh: print to stderr when gitweb_run has errors gitweb/gitweb.perl: remove use of qw(...) as parentheses gitweb/gitweb.perl: don't call S_ISREG() with undef

 gitweb/gitweb.perl |    6 +++---
 t/gitweb-lib.sh    |    7 ++++++-
 2 files changed, 9 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.2.3
#2 lore raw

PATCH v2 1/3 t/gitweb-lib.sh: print to stderr when gitweb_run has errors

In reply to Ævar Arnfjörð Bjarmason

Change the gitweb_run test subroutine to spew errors to stderr if there are any, previously it would just silently fail, which made tests very hard to debug.

Before you'd get this output, when running tests under --verbose --immediate --debug:

    expecting success: git rm renamed_file &&
             rm -f renamed_file &&
             git commit -a -m "File removed." &&
             gitweb_run "p=.git;a=commitdiff"
    rm 'renamed_file'
    [master 8d80741] File removed.
     Author: A U Thor <[email protected]>
     1 files changed, 0 insertions(+), 1 deletions(-)
     delete mode 120000 renamed_file
    not ok - 32 commitdiff(0): file deleted
    #       git rm renamed_file &&
    #                rm -f renamed_file &&
    #                git commit -a -m "File removed." &&
    #                gitweb_run "p=.git;a=commitdiff"

Now you'll get the much more useful:

    expecting success: git rm renamed_file &&
             rm -f renamed_file &&
             git commit -a -m "File removed." &&
             gitweb_run "p=.git;a=commitdiff"
    rm 'renamed_file'
    [master 2a4214e] File removed.
     Author: A U Thor <[email protected]>
     1 files changed, 0 insertions(+), 1 deletions(-)
     delete mode 120000 renamed_file
    [Sat Feb 19 14:32:54 2011] gitweb.perl: Use of uninitialized value in subroutine entry at /home/avar/g/git/t/../gitweb/gitweb.perl line 4415.
    not ok - 32 commitdiff(0): file deleted
    #       git rm renamed_file &&
    #                rm -f renamed_file &&
    #                git commit -a -m "File removed." &&
    #                gitweb_run "p=.git;a=commitdiff"
---
 t/gitweb-lib.sh |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
t/gitweb-lib.sh +6 -1
index b9bb95f..2388b0f 100644
@@ -82,7 +82,12 @@ gitweb_run () {
 		}
 		close O;
 	' gitweb.output &&
-	if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi
+	if grep '^[[]' gitweb.log >/dev/null 2>&1; then
+		cat gitweb.log >&2
+		false
+	else
+		true
+	fi
 
 	# gitweb.log is left for debugging
 	# gitweb.output is used to parse HTTP output
Signature · 1 line
1.7.2.3
#3 lore raw

Re: [PATCH v2 1/3] t/gitweb-lib.sh: print to stderr when gitweb_run has errors

Quoted 6 lines · Ævar Arnfjörð Bjarmason

Change the gitweb_run test subroutine to spew errors to stderr if there are any, previously it would just silently fail, which made tests very hard to debug.

Before you'd get this output, when running tests under --verbose --immediate --debug:

Which test?

[...]

t/gitweb-lib.sh gitweb_run () { · line 90

Quoted 13 lines
t/gitweb-lib.sh +6 -1
@@ -82,7 +82,12 @@ gitweb_run () {
 		}
 		close O;
 	' gitweb.output &&
-	if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi
+	if grep '^[[]' gitweb.log >/dev/null 2>&1; then
+		cat gitweb.log >&2
+		false
+	else
+		true
+	fi

I don't understand this change. Either it is not necessary, because test suite (or at least t9500) has

test_debug 'cat gitweb.log'

after each test, so that error messages would be printed with --debug, or it doesn't go far enough: if the above is used then those test_debug should be removed.

Signature · 2 lines
Jakub Narebski
Poland
#4 lore raw

Re: [PATCH v2 1/3] t/gitweb-lib.sh: print to stderr when gitweb_run has errors

Quoted 29 lines · Jakub Narebski
Quoted 6 lines · Ęvar Arnfjörš Bjarmason

Change the gitweb_run test subroutine to spew errors to stderr if there are any, previously it would just silently fail, which made tests very hard to debug.

Before you'd get this output, when running tests under --verbose --immediate --debug:

Which test?

[...]

Quoted 5 lines
t/gitweb-lib.sh +0 -0
@@ -82,7 +82,12 @@ gitweb_run () {
               }
               close O;
Quoted 8 lines

      ' gitweb.output &&
-     if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi
+     if grep '^[[]' gitweb.log >/dev/null 2>&1; then
+             cat gitweb.log >&2
+             false
+     else
+             true
+     fi

I don't understand this change.  Either it is not necessary, because test suite (or at least t9500) has

Quoted 5 lines

 test_debug 'cat gitweb.log'

after each test, so that error messages would be printed with --debug, or it doesn't go far enough: if the above is used then those test_debug should be removed.

The way you're using test_debug() is incompatible with --immediate. The test dies, but I'll never see your debug message because I'm using --immediate.

It would be better to just use test_debug in gitweb_run (instead of my "cat gitweb.log").

Anyway, if you feel like fixing that feel free, I wan't pursue this further (going to hack on what I was going to do before gitweb tests started failing).

Junio, you can drop this patch since it'll produce duplicate output if the test fails and the user *doesn't* use --immediate, but IMO this should be fixed by doing the debug output differently.

#5 lore raw

Re: [PATCH v2 1/3] t/gitweb-lib.sh: print to stderr when gitweb_run has errors

Quoted 32 lines · Ævar Arnfjörð Bjarmason
Quoted 31 lines · Jakub Narebski
Quoted 6 lines · Ęvar Arnfjörš Bjarmason

Change the gitweb_run test subroutine to spew errors to stderr if there are any, previously it would just silently fail, which made tests very hard to debug.

Before you'd get this output, when running tests under --verbose --immediate --debug:

Which test?

[...]

Quoted 5 lines
t/gitweb-lib.sh +0 -0
@@ -82,7 +82,12 @@ gitweb_run () {
               }
               close O;
Quoted 8 lines

      ' gitweb.output &&
-     if grep '^[[]' gitweb.log>/dev/null 2>&1; then false; else true; fi
+     if grep '^[[]' gitweb.log>/dev/null 2>&1; then
+             cat gitweb.log>&2
+             false
+     else
+             true
+     fi

I don't understand this change.  Either it is not necessary, because test suite (or at least t9500) has

 test_debug 'cat gitweb.log'

Quoted 7 lines
Quoted 3 lines

after each test, so that error messages would be printed with --debug, or it doesn't go far enough: if the above is used then those test_debug should be removed.

The way you're using test_debug() is incompatible with --immediate. The test dies, but I'll never see your debug message because I'm using --immediate.

Ah, so that is what it is about: using --immediate negates --debug.

Note that it is *much* wider issue; it is not only gitweb tests that use test_debug in such way. See for example t/t4114-apply-typechange.sh where you have

  test_expect_success SYMLINKS 'directory becomes symlink' '
        git checkout -f foo-becomes-a-directory &&
        git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
        git apply --index < patch
        '
  test_debug 'cat patch'

This causes the same problem.

Quoted 10 lines

It would be better to just use test_debug in gitweb_run (instead of my "cat gitweb.log").

Anyway, if you feel like fixing that feel free, I wan't pursue this further (going to hack on what I was going to do before gitweb tests started failing).

Junio, you can drop this patch since it'll produce duplicate output if the test fails and the user *doesn't* use --immediate, but IMO this should be fixed by doing the debug output differently.

Below there is proposed patch that removes duplication of --debug output... but does not solve issue for other places where we use test_debug in test suite and incompatibility with --immediate run.

-- >8 --
From: Ævar Arnfjörð Bjarmason <[email protected]>
Subject: [PATCH] t/gitweb-lib.sh: Ensure that errors are shown for --debug --immediate

Because '--immediate' stops test suite after first error, therefore in this mode

test_debug 'cat gitweb.log'

was never ran, thus in effect negating effect of '--debug' option. This made finidng the cause of errors in gitweb test sute difficult.

Modify the gitweb_run test subroutine to run test_debug itself in the case of errors (and also remove "test_debug 'cat gitweb.log'" from gitweb tests).

This makes it possible to run *gitweb tests* with --immediate ---debug combination of options; also it makes gitweb tests to not output spurious debug data that is not considered error.

---
 t/gitweb-lib.sh                          |    7 ++
 t/t9500-gitweb-standalone-no-errors.sh   |   86 ------------------------------
 t/t9501-gitweb-standalone-http-status.sh |    1 
 3 files changed, 6 insertions(+), 88 deletions(-)
t/gitweb-lib.sh +6 -1
index b9bb95f..143eb1f 100644
@@ -82,7 +82,12 @@ gitweb_run () {
 		}
 		close O;
 	' gitweb.output &&
-	if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi
+	if grep '^[[]' gitweb.log >/dev/null 2>&1; then
+		test_debug 'cat gitweb.log >&2' &&
+		false
+	else
+		true
+	fi
 
 	# gitweb.log is left for debugging
 	# gitweb.output is used to parse HTTP output
t/t9500-gitweb-standalone-no-errors.sh +0 -86

498 lines not on this page · raw message

t/t9501-gitweb-standalone-http-status.sh +0 -1
index 18825af..26102ee 100755
@@ -126,7 +126,6 @@ test_expect_success 'load checking: load too high (default action)' '
 	grep "Status: 503 Service Unavailable" gitweb.headers &&
 	grep "503 - The load average on the server is too high" gitweb.body
 '
-test_debug 'cat gitweb.log' # just in case
 test_debug 'cat gitweb.headers'
 
 # turn off load checking
#6 lore raw

Re: [PATCH v2 1/3] t/gitweb-lib.sh: print to stderr when gitweb_run has errors

Quoted 37 lines · Jakub Narebski
Quoted 36 lines · Ævar Arnfjörð Bjarmason
Quoted 34 lines · Jakub Narebski
Quoted 6 lines · Ęvar Arnfjörš Bjarmason

Change the gitweb_run test subroutine to spew errors to stderr if there are any, previously it would just silently fail, which made tests very hard to debug.

Before you'd get this output, when running tests under --verbose --immediate --debug:

Which test?

[...]

Quoted 5 lines
t/gitweb-lib.sh +0 -0
@@ -82,7 +82,12 @@ gitweb_run () {
               }
               close O;
Quoted 8 lines

      ' gitweb.output &&
-     if grep '^[[]' gitweb.log>/dev/null 2>&1; then false; else true; fi
+     if grep '^[[]' gitweb.log>/dev/null 2>&1; then
+             cat gitweb.log>&2
+             false
+     else
+             true
+     fi

I don't understand this change.  Either it is not necessary, because test suite (or at least t9500) has

 test_debug 'cat gitweb.log'

after each test, so that error messages would be printed with --debug, or it doesn't go far enough: if the above is used then those test_debug should be removed.

Quoted 5 lines
Quoted 3 lines

The way you're using test_debug() is incompatible with --immediate. The test dies, but I'll never see your debug message because I'm using --immediate.

Ah, so that is what it is about: using --immediate negates --debug.

Yeah, I didn't realize that when I submitted my patch, I just thought it would never be printed, period.

Quoted 3 lines

Note that it is *much* wider issue; it is not only gitweb tests that use test_debug in such way.  See for example t/t4114-apply-typechange.sh where you have

Indeed, it's all over the test suite.

Quoted 16 lines

 test_expect_success SYMLINKS 'directory becomes symlink' ' git checkout -f foo-becomes-a-directory && git diff-tree -p HEAD foo-symlinked-to-bar > patch && git apply --index < patch
       '
 test_debug 'cat patch'

This causes the same problem.

Quoted 7 lines

It would be better to just use test_debug in gitweb_run (instead of my "cat gitweb.log").

Anyway, if you feel like fixing that feel free, I wan't pursue this further (going to hack on what I was going to do before gitweb tests started failing).

Quoted 7 lines
Quoted 3 lines

Junio, you can drop this patch since it'll produce duplicate output if the test fails and the user *doesn't* use --immediate, but IMO this should be fixed by doing the debug output differently.

Below there is proposed patch that removes duplication of --debug output... but does not solve issue for other places where we use test_debug in test suite and incompatibility with --immediate run.

This patch looks good to me.

#8 lore raw

PATCH v2 2/3 gitweb/gitweb.perl: remove use of qw(...) as parentheses

In reply to Ævar Arnfjörð Bjarmason

Using the qw(...) construct as implicit parentheses was deprecated in perl 5.13.5. Change the relevant code in gitweb to not use the deprecated construct. The offending code was introduced in 3562198b by Jakub Narebski.

The issue is that perl will now warn about this:

    $ perl -wE 'for my $i qw(a b) { say $i }'
    Use of qw(...) as parentheses is deprecated at -e line 1.
    a
    b

This caused gitweb.perl to warn on perl 5.13.5 and above, and these tests to fail on those perl versions:

    ./t9501-gitweb-standalone-http-status.sh           (Wstat: 256 Tests: 11 Failed: 10)
      Failed tests:  2-11
      Non-zero exit status: 1
    ./t9502-gitweb-standalone-parse-output.sh          (Wstat: 256 Tests: 10 Failed: 9)
      Failed tests:  2-10
      Non-zero exit status: 1
---
 gitweb/gitweb.perl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
gitweb/gitweb.perl +2 -2
index 0779f12..b02372c 100755
@@ -3501,7 +3501,7 @@ sub print_feed_meta {
 			$href_params{'-title'} = 'log';
 		}
 
-		foreach my $format qw(RSS Atom) {
+		foreach my $format (qw(RSS Atom)) {
 			my $type = lc($format);
 			my %link_attr = (
 				'-rel' => 'alternate',
@@ -3682,7 +3682,7 @@ sub git_footer_html {
 		}
 		$href_params{'-title'} ||= 'log';
 
-		foreach my $format qw(RSS Atom) {
+		foreach my $format (qw(RSS Atom)) {
 			$href_params{'action'} = lc($format);
 			print $cgi->a({-href => href(%href_params),
 			              -title => "$href_params{'-title'} $format feed",
Signature · 1 line
1.7.2.3
#9 lore raw
Quoted 4 lines · Ævar Arnfjörð Bjarmason

Using the qw(...) construct as implicit parentheses was deprecated in perl 5.13.5. Change the relevant code in gitweb to not use the deprecated construct. The offending code was introduced in 3562198b by Jakub Narebski.

It is strange that Perl introduces such backwards incompatibile change (well, actually will introduce, as 5.13.x is development branch leading to future Perl version 5.14).

qw{} is described in perlop(1) as "word list" operator, so one would suppose that it generates a list.

Quoted 6 lines

The issue is that perl will now warn about this:

    $ perl -wE 'for my $i qw(a b) { say $i }'
    Use of qw(...) as parentheses is deprecated at -e line 1.
    a
    b

Hmmm... does it affect only foreach loop, or dows it affect also other places, like

use POSIX qw( setlocale localeconv )
@EXPORT = qw( foo bar baz );

Both of those forms are used by gitweb:

      use CGI qw(:standard :escapeHTML -nosticky);

      map { $_ => 'sh'  } qw(bash zsh ksh)
      my @navs = qw(summary shortlog log commit commitdiff tree);

[...]

gitweb/gitweb.perl sub print_feed_meta { · line 3507

Quoted 11 lines
gitweb/gitweb.perl +1 -1
@@ -3501,7 +3501,7 @@ sub print_feed_meta {
 			$href_params{'-title'} = 'log';
 		}
 
-		foreach my $format qw(RSS Atom) {
+		foreach my $format (qw(RSS Atom)) {
 			my $type = lc($format);
 			my %link_attr = (
 				'-rel' => 'alternate',

I am not against futureproofing gitweb in above way for future Perl 5.14.x

Signature · 2 lines
Jakub Narebski
Poland
#10 lore raw
Quoted 9 lines · Jakub Narebski

On Sat, 19 Feb 2011, Ævar Arnfjörð Bjarmason wrote:

[...]

Quoted 6 lines
gitweb/gitweb.perl +0 -0
@@ -3501,7 +3501,7 @@ sub print_feed_meta {
 			$href_params{'-title'} = 'log';
 		}
 
Quoted 5 lines

gitweb/gitweb.perl sub print_feed_meta { · line 3507

Quoted 5 lines
gitweb/gitweb.perl +1 -1
-		foreach my $format qw(RSS Atom) {
+		foreach my $format (qw(RSS Atom)) {
 			my $type = lc($format);
 			my %link_attr = (
 				'-rel' => 'alternate',

Ah, sorry, if Perl reqyures to use 'foreach (@array)', then of course one should use 'forach (qw(A B))'.

Signature · 2 lines
Jakub Narebski
Poland
#11 lore raw
In reply to Jakub Narebski
Quoted 7 lines · Jakub Narebski
Quoted 4 lines · Ævar Arnfjörð Bjarmason

Using the qw(...) construct as implicit parentheses was deprecated in perl 5.13.5. Change the relevant code in gitweb to not use the deprecated construct. The offending code was introduced in 3562198b by Jakub Narebski.

Quoted 6 lines

It is strange that Perl introduces such backwards incompatibile change (well, actually will introduce, as 5.13.x is development branch leading to future Perl version 5.14).

qw{} is described in perlop(1) as "word list" operator, so one would suppose that it generates a list.

It does, but it wasn't supposed to generate parens for you.

Quoted 13 lines
Quoted 6 lines

The issue is that perl will now warn about this:

    $ perl -wE 'for my $i qw(a b) { say $i }'
    Use of qw(...) as parentheses is deprecated at -e line 1.
    a
    b

Hmmm... does it affect only foreach loop, or dows it affect also other places, like

     use POSIX qw( setlocale localeconv )
     @EXPORT = qw( foo bar baz );

Quoted 6 lines

Both of those forms are used by gitweb:

     use CGI qw(:standard :escapeHTML -nosticky);

     map { $_ => 'sh'  } qw(bash zsh ksh)
     my @navs = qw(summary shortlog log commit commitdiff tree);

No. This is being deprecated because qw(foo bar) is supposed to mean "foo, "bar", not ("foo", "bar"). I.e. this doesn't compile:

    for my $i "a", "b", "c" { }

So neither should this:

    for my $i qw(a b c) {}

But these both work:

    for my $i ("a", "b", "c") { }
    for my $i (qw(a b c)) {}

All of your other examples could have used a list without implicit parens. So this is the only change that's needed in gitweb.

#13 lore raw

PATCH v2 3/3 gitweb/gitweb.perl: don't call S_ISREG() with undef

In reply to Ævar Arnfjörð Bjarmason

Change S_ISREG($to_mode_oct) to S_ISREG($from_mode_oct) in the branch that handles from modes, not to modes. This logic appears to have been caused by copy/paste programming by Jakub Narebski in e8e41a93. It would be better to rewrite this code not to be duplicated, but I haven't done so.

This issue caused a failing test on perl 5.13.9, which has a warning that turned this up:

gitweb.perl: Use of uninitialized value in subroutine entry at /home/avar/g/git/t/../gitweb/gitweb.perl line 4415.

Which caused the Git test suite to fail on this test:

    ./t9500-gitweb-standalone-no-errors.sh             (Wstat: 256 Tests: 90 Failed: 84)
      Failed tests:  1-8, 10-36, 38-45, 47-48, 50-88
      Non-zero exit status: 1
Reported-by perl 5.13.9
---
 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +1 -1
index b02372c..1b9369d 100755
@@ -4412,7 +4412,7 @@ sub git_difftree_body {
 		}
 		if ($diff->{'from_mode'} ne ('0' x 6)) {
 			$from_mode_oct = oct $diff->{'from_mode'};
-			if (S_ISREG($to_mode_oct)) { # only for regular file
+			if (S_ISREG($from_mode_oct)) { # only for regular file
 				$from_mode_str = sprintf("%04o", $from_mode_oct & 0777); # permission bits
 			}
 			$from_file_type = file_type($diff->{'from_mode'});
Signature · 1 line
1.7.2.3
Acked-by on v2 3/3
#14 lore raw

Re: [PATCH v2 3/3] gitweb/gitweb.perl: don't call S_ISREG() with undef

Quoted 10 lines · Ævar Arnfjörð Bjarmason

Change S_ISREG($to_mode_oct) to S_ISREG($from_mode_oct) in the branch that handles from modes, not to modes. This logic appears to have been caused by copy/paste programming by Jakub Narebski in e8e41a93. It would be better to rewrite this code not to be duplicated, but I haven't done so.

This issue caused a failing test on perl 5.13.9, which has a warning that turned this up:

gitweb.perl: Use of uninitialized value in subroutine entry at /home/avar/g/git/t/../gitweb/gitweb.perl line 4415.

[...]

Quoted 2 lines
Reported-by perl 5.13.9

Thanks for catching this. I wonder why we didn't caught this earlier...

For what it is worth it:

Quoted 21 lines
---
 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +1 -1
index b02372c..1b9369d 100755
@@ -4412,7 +4412,7 @@ sub git_difftree_body {
 		}
 		if ($diff->{'from_mode'} ne ('0' x 6)) {
 			$from_mode_oct = oct $diff->{'from_mode'};
-			if (S_ISREG($to_mode_oct)) { # only for regular file
+			if (S_ISREG($from_mode_oct)) { # only for regular file
 				$from_mode_str = sprintf("%04o", $from_mode_oct & 0777); # permission bits
 			}
 			$from_file_type = file_type($diff->{'from_mode'});
Signature · 1 line
1.7.2.3
Signature · 2 lines
Jakub Narebski
Poland
#7 lore raw

Re: [PATCH v2 1/3] t/gitweb-lib.sh: print to stderr when gitweb_run has errors

In reply to Jakub Narebski
Quoted 7 lines · Jakub Narebski

Because '--immediate' stops test suite after first error, therefore in this mode

test_debug 'cat gitweb.log'

was never ran, thus in effect negating effect of '--debug' option. This made finidng the cause of errors in gitweb test sute difficult.

I think the patch itself makes sense, but I actually don't agree with the above reasoning.

The point of --immediate is not just it stops where we find a failure, but also it leaves the trash directory intact, so that _you_ who started the test with --immediate can run the "cat gitweb.log" yourself.

In other words, I think test_debug is overused. In the current setting, I think a sane way to debug the test script itself would probably be

sh -x tXXXX-xxxx.sh -i -v -d

so that:

(1) with -x I can see what commands are being run;
(2) with -i I can stop the test immediately upon the first failure;
(3) with -v I can see the output from the commands that we usually do not show; and
(4) with -d I can be sure that trash directory does not go away.

Notice that I do not count "I can see test_debug executed" as a benefit from (4) above?

My preference, although I do not care too deeply, would be to gradually remove test_debug calls that were casually sprinkled and left in the test scripts while they were initially developed, and have the regular test sequence run them just like your patch does. Another change I would welcome would be to make the "-d" option automatically trigger shell tracing, to make it unnecessary to say "sh -x".

#12 lore raw
In reply to Ævar Arnfjörð Bjarmason
Quoted 16 lines · Ævar Arnfjörð Bjarmason
Quoted 7 lines · Jakub Narebski
Quoted 4 lines · Ævar Arnfjörð Bjarmason

Using the qw(...) construct as implicit parentheses was deprecated in perl 5.13.5. Change the relevant code in gitweb to not use the deprecated construct. The offending code was introduced in 3562198b by Jakub Narebski.

Quoted 6 lines

It is strange that Perl introduces such backwards incompatibile change (well, actually will introduce, as 5.13.x is development branch leading to future Perl version 5.14).

qw{} is described in perlop(1) as "word list" operator, so one would suppose that it generates a list.

It does, but it wasn't supposed to generate parens for you.

[...]

Quoted 5 lines
Quoted 5 lines

Hmmm... does it affect only foreach loop, or dows it affect also other places, like

     use POSIX qw( setlocale localeconv )
     @EXPORT = qw( foo bar baz );

[...]

Quoted 9 lines

No. This is being deprecated because qw(foo bar) is supposed to mean "foo, "bar", not ("foo", "bar"). I.e. this doesn't compile:

    for my $i "a", "b", "c" { }

So neither should this:

    for my $i qw(a b c) {}
Quoted 7 lines

But these both work:

    for my $i ("a", "b", "c") { }
    for my $i (qw(a b c)) {}

All of your other examples could have used a list without implicit parens. So this is the only change that's needed in gitweb.

Thanks for the explanation. It makes sense. So:

Signature · 2 lines
Jakub Narebski
Poland