# [PATCH v2] allow TTY tests to run under recent Mac OS

7 messages from 2014-11-13 to 2014-11-14. Participants: Mike Blume, John Szakmeister, Johannes Sixt, Michael Blume, Jeff King, Junio C Hamano.
Thread: https://gitlist.dev/t/37958

## Mike Blume, 2014-11-13 22:40

Subject: [PATCH v2] allow TTY tests to run under recent Mac OS
Message-ID: <1415918419-20807-1-git-send-email-blume.mike@gmail.com>
URL: https://gitlist.dev/e/1415918419-20807-1-git-send-email-blume.mike%40gmail.com

```
listed bug doesn't reproduce on Mac OS Yosemite. For now, just enable
TTY on Yosemite and higher

Signed-off-by: Mike Blume <blume.mike@gmail.com>
Improved-by: Junio C Hamano <gitster@pobox.com>
---
 t/lib-terminal.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/t/lib-terminal.sh b/t/lib-terminal.sh
index 5184549..6395a34 100644
--- a/t/lib-terminal.sh
+++ b/t/lib-terminal.sh
@@ -29,7 +29,10 @@ test_lazy_prereq TTY '
 	# After 2000 iterations or so it hangs.
 	# https://rt.cpan.org/Ticket/Display.html?id=65692
 	#
-	test "$(uname -s)" != Darwin &&
+	# Under Mac OS X 10.10.1 and Perl 5.18.2, this problem
+	# appears to be gone.
+	#
+	test "$(uname -s)" != Darwin || test "$(uname -r | cut -d. -f1)" -ge 14 &&
 
 	perl "$TEST_DIRECTORY"/test-terminal.perl \
 		sh -c "test -t 1 && test -t 2"
-- 
2.2.0.rc1.197.g60bf093

```

## John Szakmeister, 2014-11-14 10:43

Subject: Re: [PATCH v2] allow TTY tests to run under recent Mac OS
Message-ID: <CAEBDL5VgxTMyxx6FTxocuJ3hJ+yK-VF+RycFi5Fitc+V==UEnw@mail.gmail.com>
URL: https://gitlist.dev/e/CAEBDL5VgxTMyxx6FTxocuJ3hJ%2ByK-VF%2BRycFi5Fitc%2BV%3D%3DUEnw%40mail.gmail.com
In-Reply-To: <1415918419-20807-1-git-send-email-blume.mike@gmail.com>

```
On Thu, Nov 13, 2014 at 5:40 PM, Mike Blume <blume.mike@gmail.com> wrote:
> listed bug doesn't reproduce on Mac OS Yosemite. For now, just enable
> TTY on Yosemite and higher

I've tried the reproduction recipe on Mavericks (`uname -r` => 13.4.0)
and it works fine--still going after 12,000 iterations.  Trying the
same thing on Snow Leopard shows that it still fails there--it died
after 182 iterations.

So I think the check can be relaxed to `-ge 13`.

-John

```

## Johannes Sixt, 2014-11-14 19:23

Subject: Re: [PATCH v2] allow TTY tests to run under recent Mac OS
Message-ID: <546656C8.3070009@kdbg.org>
URL: https://gitlist.dev/e/546656C8.3070009%40kdbg.org
In-Reply-To: <1415918419-20807-1-git-send-email-blume.mike@gmail.com>

```
Am 13.11.2014 um 23:40 schrieb Mike Blume:
> listed bug doesn't reproduce on Mac OS Yosemite. For now, just enable
> TTY on Yosemite and higher
> 
> Signed-off-by: Mike Blume <blume.mike@gmail.com>
> Improved-by: Junio C Hamano <gitster@pobox.com>
> ---
>  t/lib-terminal.sh | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/t/lib-terminal.sh b/t/lib-terminal.sh
> index 5184549..6395a34 100644
> --- a/t/lib-terminal.sh
> +++ b/t/lib-terminal.sh
> @@ -29,7 +29,10 @@ test_lazy_prereq TTY '
>  	# After 2000 iterations or so it hangs.
>  	# https://rt.cpan.org/Ticket/Display.html?id=65692
>  	#
> -	test "$(uname -s)" != Darwin &&
> +	# Under Mac OS X 10.10.1 and Perl 5.18.2, this problem
> +	# appears to be gone.
> +	#
> +	test "$(uname -s)" != Darwin || test "$(uname -r | cut -d. -f1)" -ge 14 &&

This is part of an &&-chain; you can't just throw in a || in the middle.

How about

	if test "$(uname -s)" = Darwin
	then
		test "$(uname -r | cut -d. -f1)" -ge 14
	fi &&

>  
>  	perl "$TEST_DIRECTORY"/test-terminal.perl \
>  		sh -c "test -t 1 && test -t 2"
> 

-- Hannes

```

## Michael Blume, 2014-11-14 19:48

Subject: Re: [PATCH v2] allow TTY tests to run under recent Mac OS
Message-ID: <CAO2U3QgmuwatfDDO8f461cwq2SctPx+owL8gDMBpNyDcaxaWGQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAO2U3QgmuwatfDDO8f461cwq2SctPx%2BowL8gDMBpNyDcaxaWGQ%40mail.gmail.com
In-Reply-To: <546656C8.3070009@kdbg.org>

```
My understanding is that && and || have equal precedence, and this
seems to be borne out in testing at my shell. If the if/then method is
clearer I'm happy to go with that.

On Fri, Nov 14, 2014 at 11:23 AM, Johannes Sixt <j6t@kdbg.org> wrote:
> Am 13.11.2014 um 23:40 schrieb Mike Blume:
>> listed bug doesn't reproduce on Mac OS Yosemite. For now, just enable
>> TTY on Yosemite and higher
>>
>> Signed-off-by: Mike Blume <blume.mike@gmail.com>
>> Improved-by: Junio C Hamano <gitster@pobox.com>
>> ---
>>  t/lib-terminal.sh | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/t/lib-terminal.sh b/t/lib-terminal.sh
>> index 5184549..6395a34 100644
>> --- a/t/lib-terminal.sh
>> +++ b/t/lib-terminal.sh
>> @@ -29,7 +29,10 @@ test_lazy_prereq TTY '
>>       # After 2000 iterations or so it hangs.
>>       # https://rt.cpan.org/Ticket/Display.html?id=65692
>>       #
>> -     test "$(uname -s)" != Darwin &&
>> +     # Under Mac OS X 10.10.1 and Perl 5.18.2, this problem
>> +     # appears to be gone.
>> +     #
>> +     test "$(uname -s)" != Darwin || test "$(uname -r | cut -d. -f1)" -ge 14 &&
>
> This is part of an &&-chain; you can't just throw in a || in the middle.
>
> How about
>
>         if test "$(uname -s)" = Darwin
>         then
>                 test "$(uname -r | cut -d. -f1)" -ge 14
>         fi &&
>
>>
>>       perl "$TEST_DIRECTORY"/test-terminal.perl \
>>               sh -c "test -t 1 && test -t 2"
>>
>
> -- Hannes
>

```

## Jeff King, 2014-11-14 20:02

Subject: Re: [PATCH v2] allow TTY tests to run under recent Mac OS
Message-ID: <20141114200239.GA11581@peff.net>
URL: https://gitlist.dev/e/20141114200239.GA11581%40peff.net
In-Reply-To: <CAO2U3QgmuwatfDDO8f461cwq2SctPx+owL8gDMBpNyDcaxaWGQ@mail.gmail.com>

```
On Fri, Nov 14, 2014 at 11:48:36AM -0800, Michael Blume wrote:

> My understanding is that && and || have equal precedence, and this
> seems to be borne out in testing at my shell. If the if/then method is
> clearer I'm happy to go with that.

I think the problem is that there are earlier parts of the chain. It
currently looks like:

  foo &&
  bar &&
  do_something

but you are making it:

  foo &&
  bar || baz &&
  do_something

which will do_something whether or not "foo" is true. You need to put
your "||" at a lower precedence than the rest of the chain. The "if"
that Johannes mentioned works, though I think

  test_have_prereq PERL &&
  {
    test "$(uname -s)" != Darwin ||
    test "$(uname -r | cut -d. -f1)" -ge 13
  } &&
  ...

is more obvious to read (but that's subjective, of course).

-Peff

```

## Michael Blume, 2014-11-14 20:04

Subject: Re: [PATCH v2] allow TTY tests to run under recent Mac OS
Message-ID: <CAO2U3QhZrkmmCfFxKAcp+ojAso=ns6gA2g2TN5MZGdqCw0Y72A@mail.gmail.com>
URL: https://gitlist.dev/e/CAO2U3QhZrkmmCfFxKAcp%2BojAso%3Dns6gA2g2TN5MZGdqCw0Y72A%40mail.gmail.com
In-Reply-To: <20141114200239.GA11581@peff.net>

```
Right, I missed that there was more going on above, thanks =)

On Fri, Nov 14, 2014 at 12:02 PM, Jeff King <peff@peff.net> wrote:
> On Fri, Nov 14, 2014 at 11:48:36AM -0800, Michael Blume wrote:
>
>> My understanding is that && and || have equal precedence, and this
>> seems to be borne out in testing at my shell. If the if/then method is
>> clearer I'm happy to go with that.
>
> I think the problem is that there are earlier parts of the chain. It
> currently looks like:
>
>   foo &&
>   bar &&
>   do_something
>
> but you are making it:
>
>   foo &&
>   bar || baz &&
>   do_something
>
> which will do_something whether or not "foo" is true. You need to put
> your "||" at a lower precedence than the rest of the chain. The "if"
> that Johannes mentioned works, though I think
>
>   test_have_prereq PERL &&
>   {
>     test "$(uname -s)" != Darwin ||
>     test "$(uname -r | cut -d. -f1)" -ge 13
>   } &&
>   ...
>
> is more obvious to read (but that's subjective, of course).
>
> -Peff

```

## Junio C Hamano, 2014-11-14 20:16

Subject: Re: [PATCH v2] allow TTY tests to run under recent Mac OS
Message-ID: <xmqqfvdl35d0.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqfvdl35d0.fsf%40gitster.dls.corp.google.com
In-Reply-To: <20141114200239.GA11581@peff.net>

```
Jeff King <peff@peff.net> writes:

> On Fri, Nov 14, 2014 at 11:48:36AM -0800, Michael Blume wrote:
>
>> My understanding is that && and || have equal precedence, and this
>> seems to be borne out in testing at my shell. If the if/then method is
>> clearer I'm happy to go with that.
>
> I think the problem is that there are earlier parts of the chain. It
> currently looks like:
>
>   foo &&
>   bar &&
>   do_something
>
> but you are making it:
>
>   foo &&
>   bar || baz &&
>   do_something
>
> which will do_something whether or not "foo" is true. You need to put
> your "||" at a lower precedence than the rest of the chain. The "if"
> that Johannes mentioned works, though I think
>
>   test_have_prereq PERL &&
>   {
>     test "$(uname -s)" != Darwin ||
>     test "$(uname -r | cut -d. -f1)" -ge 13
>   } &&
>   ...
>
> is more obvious to read (but that's subjective, of course).

Thanks.

While I was reading this earlier I wondered the same thing and
concluded it was OK based on the equal precedence, but like Michael
I missed that there is yet another test before it.

```
