Git Mailing List Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] t5150: skip request-pull test if Perl is disabled
@ 2019-11-26  0:02 Ruud van Asseldonk
  2019-11-26  0:43 ` Jonathan Nieder
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ruud van Asseldonk @ 2019-11-26  0:02 UTC (permalink / raw)
  To: git; +Cc: Paolo Bonzini, Jonathan Nieder

The git-request-pull.sh script invokes Perl, so it requires Perl to be
available, but the associated test t5150 does not skip itself when Perl
has been disabled, which then makes subtest 4 through 10 fail. Subtest 3
still passes, but for the wrong reasons (it expects git-request-pull to
fail, and it does fail when Perl is not available). The initial two
subtests that do pass are only doing setup.

To prevent t5150 from failing the build when NO_PERL=1, add a check that
sets skip_all when "! test_have_prereq PERL", just like how for example
t3701-add-interactive skips itself when Perl has been disabled.

Signed-off-by: Ruud van Asseldonk <dev@veniogames.com>
---
I discovered this issue in the Git package in Nixpkgs. The Nix package
manager tries to make it hard to accidentally introduce undeclared
dependencies, and it has a sandbox that hides things in /usr/bin. So
when it builds with NO_PERL=1, it really makes no Perl available, so you
cannot accidentally depend on the Perl in /usr/bin/perl. For the tests
it does set PERL_PATH, but it does not point to a binary in /usr/bin.

 t/t5150-request-pull.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh
index 852dcd913f..1ad4ecc29a 100755
--- a/t/t5150-request-pull.sh
+++ b/t/t5150-request-pull.sh
@@ -4,6 +4,12 @@ test_description='Test workflows involving pull request.'
 
 . ./test-lib.sh
 
+if ! test_have_prereq PERL
+then
+	skip_all='skipping request-pull tests, perl not available'
+	test_done
+fi
+
 test_expect_success 'setup' '
 
 	git init --bare upstream.git &&
-- 
2.24.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] t5150: skip request-pull test if Perl is disabled
  2019-11-26  0:02 [PATCH] t5150: skip request-pull test if Perl is disabled Ruud van Asseldonk
@ 2019-11-26  0:43 ` Jonathan Nieder
  2019-11-26  0:46 ` Jonathan Nieder
  2019-11-27 11:21 ` Jeff King
  2 siblings, 0 replies; 9+ messages in thread
From: Jonathan Nieder @ 2019-11-26  0:43 UTC (permalink / raw)
  To: Ruud van Asseldonk; +Cc: git, Paolo Bonzini

Hi,

Ruud van Asseldonk wrote:

> The git-request-pull.sh script invokes Perl,

Do you have more details?  From a quick glance, I wasn't able to find
any instance of perl or $PERL_PATH in git-request-pull.sh.

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] t5150: skip request-pull test if Perl is disabled
  2019-11-26  0:02 [PATCH] t5150: skip request-pull test if Perl is disabled Ruud van Asseldonk
  2019-11-26  0:43 ` Jonathan Nieder
@ 2019-11-26  0:46 ` Jonathan Nieder
  2019-11-27 22:42   ` Ruud van Asseldonk
  2019-11-27 11:21 ` Jeff King
  2 siblings, 1 reply; 9+ messages in thread
From: Jonathan Nieder @ 2019-11-26  0:46 UTC (permalink / raw)
  To: Ruud van Asseldonk; +Cc: git, Paolo Bonzini

Ruud van Asseldonk wrote:

> The git-request-pull.sh script invokes Perl,

Okay, on second glance I found it:

  set fnord $(git ls-remote "$url" | @@PERL@@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")

This does seem pretty inherently to require perl, so makes sense.

I wonder if we can generalize this.  For example, would it make sense to
have a helper that looks for @@PERL@@ in a file,  so we could say

	if uses_perl git-request-pull.sh && ! test_have_prereq PERL
	then
		...
	fi

That way, this would be more futureproof in case someone eliminates
the perl dependency (either by improving that particular parsing step
or by rewriting the whole program in C).

In any event,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

Do the request-pull tests in t7006-pager.sh need the same treatment?

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] t5150: skip request-pull test if Perl is disabled
  2019-11-26  0:02 [PATCH] t5150: skip request-pull test if Perl is disabled Ruud van Asseldonk
  2019-11-26  0:43 ` Jonathan Nieder
  2019-11-26  0:46 ` Jonathan Nieder
@ 2019-11-27 11:21 ` Jeff King
  2019-11-27 23:45   ` Ruud van Asseldonk
  2019-11-28  1:31   ` Jonathan Nieder
  2 siblings, 2 replies; 9+ messages in thread
From: Jeff King @ 2019-11-27 11:21 UTC (permalink / raw)
  To: Ruud van Asseldonk; +Cc: git, Paolo Bonzini, Jonathan Nieder

On Tue, Nov 26, 2019 at 01:02:46AM +0100, Ruud van Asseldonk wrote:

> The git-request-pull.sh script invokes Perl, so it requires Perl to be
> available, but the associated test t5150 does not skip itself when Perl
> has been disabled, which then makes subtest 4 through 10 fail. Subtest 3
> still passes, but for the wrong reasons (it expects git-request-pull to
> fail, and it does fail when Perl is not available). The initial two
> subtests that do pass are only doing setup.
> 
> To prevent t5150 from failing the build when NO_PERL=1, add a check that
> sets skip_all when "! test_have_prereq PERL", just like how for example
> t3701-add-interactive skips itself when Perl has been disabled.
> 
> Signed-off-by: Ruud van Asseldonk <dev@veniogames.com>
> ---
> I discovered this issue in the Git package in Nixpkgs. The Nix package
> manager tries to make it hard to accidentally introduce undeclared
> dependencies, and it has a sandbox that hides things in /usr/bin. So
> when it builds with NO_PERL=1, it really makes no Perl available, so you
> cannot accidentally depend on the Perl in /usr/bin/perl. For the tests
> it does set PERL_PATH, but it does not point to a binary in /usr/bin.

Hmm. I don't think that technique gives complete coverage. There are
other scripts (e.g., filter-branch) that call a bare "perl" (not
PERL_PATH), which presumably pass the tests even though they'd break in
a real-world system without perl. In fact, many scripts used to do this
before fcb06a8d54 (use @@PERL@@ in built scripts, 2013-10-28). I don't
think the effects on NO_PERL were really considered there; it was more
about finding the right perl.

I think NO_PERL has historically mostly meant "do not build or install
perl scripts", and not "everything ought to run fine without perl".
We've generally assumed you can run vanilla perl snippets from the
command line the same way you'd run awk or sed (and the tests use this
extensively, which is why you have to set PERL_PATH again to run them).

That said, most of those casual uses of perl in actual built scripts
have gone away because the shell scripts have gone away. It looks like
filter-branch, request-pull, and instaweb are the last holdouts. So
maybe we should be treating NO_PERL as disabling those scripts, too.

But then, should we be doing more to make it clear that those scripts
are broken in a NO_PERL build? Who knows what happens if you run
filter-branch without any perl available?

-Peff

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] t5150: skip request-pull test if Perl is disabled
  2019-11-26  0:46 ` Jonathan Nieder
@ 2019-11-27 22:42   ` Ruud van Asseldonk
  0 siblings, 0 replies; 9+ messages in thread
From: Ruud van Asseldonk @ 2019-11-27 22:42 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, Paolo Bonzini

Thanks for having a look Jonathan.

Jonathan Nieder wrote:
> Ruud van Asseldonk wrote:
> 
>> The git-request-pull.sh script invokes Perl,
> 
> Okay, on second glance I found it:
> 
>    set fnord $(git ls-remote "$url" | @@PERL@@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
> 
> This does seem pretty inherently to require perl, so makes sense.
> 
> I wonder if we can generalize this.  For example, would it make sense to
> have a helper that looks for @@PERL@@ in a file,  so we could say
> 
> 	if uses_perl git-request-pull.sh && ! test_have_prereq PERL
> 	then
> 		...
> 	fi
> 
> That way, this would be more futureproof in case someone eliminates
> the perl dependency (either by improving that particular parsing step
> or by rewriting the whole program in C).

That sounds like a good idea. How about turning that into a test itself? 
The test would check that the script mentions @@PERL@@, as the first 
subtest. That way, if somebody removes the Perl dependency in the 
future, that will make the test fail, and that will be a reminder to 
remove the check from the test, so the test runs unconditionally.

> In any event,
> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
> 
> Do the request-pull tests in t7006-pager.sh need the same treatment?

I think these tests are fine, they run "git -p request-pull", not enough 
arguments to make request-pull do something, so it prints its usage and 
exits with 1. The tests use test_must_fail to verify the exit code, and 
printing usage does go through the pager. request-pull does not call 
Perl when it only prints its usage.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] t5150: skip request-pull test if Perl is disabled
  2019-11-27 11:21 ` Jeff King
@ 2019-11-27 23:45   ` Ruud van Asseldonk
  2019-11-28  1:35     ` Jonathan Nieder
  2019-11-28  1:31   ` Jonathan Nieder
  1 sibling, 1 reply; 9+ messages in thread
From: Ruud van Asseldonk @ 2019-11-27 23:45 UTC (permalink / raw)
  To: Jeff King; +Cc: git, Paolo Bonzini, Jonathan Nieder

> Hmm. I don't think that technique gives complete coverage. There are
> other scripts (e.g., filter-branch) that call a bare "perl" (not
> PERL_PATH), which presumably pass the tests even though they'd break in
> a real-world system without perl. In fact, many scripts used to do this
> before fcb06a8d54 (use @@PERL@@ in built scripts, 2013-10-28). I don't
> think the effects on NO_PERL were really considered there; it was more
> about finding the right perl.

Hmm, filter-branch calls bare "perl", not @@PERL@@ or Perl at an 
absolute path. At first I thought that made it pass when "perl" is on 
the PATH in tests. But even when I replace those with @@PERL@@, the test 
still pass. I will investigate further.

> I think NO_PERL has historically mostly meant "do not build or install
> perl scripts", and not "everything ought to run fine without perl".
> We've generally assumed you can run vanilla perl snippets from the
> command line the same way you'd run awk or sed (and the tests use this
> extensively, which is why you have to set PERL_PATH again to run them)
> That said, most of those casual uses of perl in actual built scripts
> have gone away because the shell scripts have gone away. It looks like
> filter-branch, request-pull, and instaweb are the last holdouts. So
> maybe we should be treating NO_PERL as disabling those scripts, too.
> 
> But then, should we be doing more to make it clear that those scripts
> are broken in a NO_PERL build? Who knows what happens if you run
> filter-branch without any perl available?

My understanding was that NO_PERL controlled the runtime dependencies of 
Git, and that the tests require Perl either way. Of course, without Perl 
any scripts that depend on it can't be used, but like you say, there are 
few of them left. I think it would make sense to not install those 
scripts when NO_PERL=1. Should I make a patch to change that in the 
makefile?

Best,
Ruud

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] t5150: skip request-pull test if Perl is disabled
  2019-11-27 11:21 ` Jeff King
  2019-11-27 23:45   ` Ruud van Asseldonk
@ 2019-11-28  1:31   ` Jonathan Nieder
  2019-12-02  6:19     ` Junio C Hamano
  1 sibling, 1 reply; 9+ messages in thread
From: Jonathan Nieder @ 2019-11-28  1:31 UTC (permalink / raw)
  To: Jeff King; +Cc: Ruud van Asseldonk, git, Paolo Bonzini

Jeff King wrote:

> Hmm. I don't think that technique gives complete coverage. There are
> other scripts (e.g., filter-branch) that call a bare "perl" (not
> PERL_PATH), which presumably pass the tests even though they'd break in
> a real-world system without perl. In fact, many scripts used to do this
> before fcb06a8d54 (use @@PERL@@ in built scripts, 2013-10-28). I don't
> think the effects on NO_PERL were really considered there; it was more
> about finding the right perl.

Oh!  Thanks for looking deeper.

> I think NO_PERL has historically mostly meant "do not build or install
> perl scripts", and not "everything ought to run fine without perl".
> We've generally assumed you can run vanilla perl snippets from the
> command line the same way you'd run awk or sed (and the tests use this
> extensively, which is why you have to set PERL_PATH again to run them).

Right.  PERL_PATH and NO_PERL are more orthogonal than I had thought.
So this is

  Not-Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

--- the patch shouldn't be applied as is.

> That said, most of those casual uses of perl in actual built scripts
> have gone away because the shell scripts have gone away. It looks like
> filter-branch, request-pull, and instaweb are the last holdouts. So
> maybe we should be treating NO_PERL as disabling those scripts, too.
>
> But then, should we be doing more to make it clear that those scripts
> are broken in a NO_PERL build? Who knows what happens if you run
> filter-branch without any perl available?

Agreed: if we want to follow this approach, we should install stubs in
place of those scripts when NO_PERL=YesPlease.  Will say more about
this in a separate reply.

Thanks for catching it,
Jonathan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] t5150: skip request-pull test if Perl is disabled
  2019-11-27 23:45   ` Ruud van Asseldonk
@ 2019-11-28  1:35     ` Jonathan Nieder
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Nieder @ 2019-11-28  1:35 UTC (permalink / raw)
  To: Ruud van Asseldonk; +Cc: Jeff King, git, Paolo Bonzini

Hi,

Ruud van Asseldonk wrote:
> Jeff King wrote:

>> I think NO_PERL has historically mostly meant "do not build or install
>> perl scripts", and not "everything ought to run fine without perl".
>> We've generally assumed you can run vanilla perl snippets from the
>> command line the same way you'd run awk or sed (and the tests use this
>> extensively, which is why you have to set PERL_PATH again to run them)

We've definitely held the stance that NO_PERL doesn't mean to disable
perl in tests.  For casual use of perl in installed shell scripts, on
the other hand, I suspect it was more that we forgot about them than
that we had decided one way or another. :)

[...]
>> That said, most of those casual uses of perl in actual built scripts
>> have gone away because the shell scripts have gone away. It looks like
>> filter-branch, request-pull, and instaweb are the last holdouts. So
>> maybe we should be treating NO_PERL as disabling those scripts, too.
>>
>> But then, should we be doing more to make it clear that those scripts
>> are broken in a NO_PERL build? Who knows what happens if you run
>> filter-branch without any perl available?
>
> My understanding was that NO_PERL controlled the runtime dependencies of
> Git, and that the tests require Perl either way. Of course, without Perl any
> scripts that depend on it can't be used, but like you say, there are few of
> them left. I think it would make sense to not install those scripts when
> NO_PERL=1. Should I make a patch to change that in the makefile?

Yes, that sounds good to me.  (The status quo also seems fine to me,
but I like that this proposed approach would simplify things a
little.)

Thanks for working on this, and sorry for the earlier noise.

Sincerely,
Jonathan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] t5150: skip request-pull test if Perl is disabled
  2019-11-28  1:31   ` Jonathan Nieder
@ 2019-12-02  6:19     ` Junio C Hamano
  0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2019-12-02  6:19 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Jeff King, Ruud van Asseldonk, git, Paolo Bonzini

Jonathan Nieder <jrnieder@gmail.com> writes:

>   Not-Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
>
> --- the patch shouldn't be applied as is.
> ...
> Agreed: if we want to follow this approach, we should install stubs in
> place of those scripts when NO_PERL=YesPlease.  Will say more about
> this in a separate reply.

I am just leaving a note here in the thread to make sure I notice if
there is any progress/conclusion, until which time I'll keep the
patch on hold.  Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26  0:02 [PATCH] t5150: skip request-pull test if Perl is disabled Ruud van Asseldonk
2019-11-26  0:43 ` Jonathan Nieder
2019-11-26  0:46 ` Jonathan Nieder
2019-11-27 22:42   ` Ruud van Asseldonk
2019-11-27 11:21 ` Jeff King
2019-11-27 23:45   ` Ruud van Asseldonk
2019-11-28  1:35     ` Jonathan Nieder
2019-11-28  1:31   ` Jonathan Nieder
2019-12-02  6:19     ` Junio C Hamano

Git Mailing List Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/git/0 git/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 git git/ https://lore.kernel.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.git


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git