Patchwork test-rebase-interruptions: stabilize for Windows

login
register
mail settings
Submitter Matt Harbison
Date July 1, 2017, 7:16 p.m.
Message ID <61ed2cc98fd17c50c7ad.1498936605@Envy>
Download mbox | patch
Permalink /patch/21861/
State Accepted
Headers show

Comments

Matt Harbison - July 1, 2017, 7:16 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1498936389 14400
#      Sat Jul 01 15:13:09 2017 -0400
# Node ID 61ed2cc98fd17c50c7adf634d777d946781a9fc1
# Parent  77e666f943a6c246d7fc970a8a36cd8b2023e03b
test-rebase-interruptions: stabilize for Windows

External hooks end up launching cmd.exe, which knows nothing about $VAR syntax.
For some reason, I thought that Mercurial would substitute in the value, in
order to paper over the platform difference.  But I can't find that in the
documentation, and there's at least one other use of this pattern [1].

[1] https://www.mercurial-scm.org/repo/hg/file/tip/tests/test-histedit-fold.t#l477
Sean Farley - July 1, 2017, 11:37 p.m.
Matt Harbison <mharbison72@gmail.com> writes:

> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1498936389 14400
> #      Sat Jul 01 15:13:09 2017 -0400
> # Node ID 61ed2cc98fd17c50c7adf634d777d946781a9fc1
> # Parent  77e666f943a6c246d7fc970a8a36cd8b2023e03b
> test-rebase-interruptions: stabilize for Windows
>
> External hooks end up launching cmd.exe, which knows nothing about $VAR syntax.
> For some reason, I thought that Mercurial would substitute in the value, in
> order to paper over the platform difference.  But I can't find that in the
> documentation, and there's at least one other use of this pattern [1].
>
> [1] https://www.mercurial-scm.org/repo/hg/file/tip/tests/test-histedit-fold.t#l477

Huh. I would have thought that, too. Should that be something we do?

Anyways, queued!
Matt Harbison - July 2, 2017, 1:29 a.m.
On Sat, 01 Jul 2017 19:37:51 -0400, Sean Farley <sean@farley.io> wrote:

>
> Matt Harbison <mharbison72@gmail.com> writes:
>
>> # HG changeset patch
>> # User Matt Harbison <matt_harbison@yahoo.com>
>> # Date 1498936389 14400
>> #      Sat Jul 01 15:13:09 2017 -0400
>> # Node ID 61ed2cc98fd17c50c7adf634d777d946781a9fc1
>> # Parent  77e666f943a6c246d7fc970a8a36cd8b2023e03b
>> test-rebase-interruptions: stabilize for Windows
>>
>> External hooks end up launching cmd.exe, which knows nothing about $VAR  
>> syntax.
>> For some reason, I thought that Mercurial would substitute in the  
>> value, in
>> order to paper over the platform difference.  But I can't find that in  
>> the
>> documentation, and there's at least one other use of this pattern [1].
>>
>> [1]  
>> https://www.mercurial-scm.org/repo/hg/file/tip/tests/test-histedit-fold.t#l477
>
> Huh. I would have thought that, too. Should that be something we do?

Maybe it was aliases that I was thinking of, but that's not really env  
related.  I haven't had a need for hooks yet, but I'd say yes, even if for  
no other reason than it's one less mode of failure for Windows tests. :-)   
Presumably, '\$foo' could be used to pass a literal $foo.

> Anyways, queued!
Yuya Nishihara - July 2, 2017, 3:16 a.m.
On Sat, 01 Jul 2017 21:29:37 -0400, Matt Harbison wrote:
> On Sat, 01 Jul 2017 19:37:51 -0400, Sean Farley <sean@farley.io> wrote:
> > Matt Harbison <mharbison72@gmail.com> writes:
> >> # HG changeset patch
> >> # User Matt Harbison <matt_harbison@yahoo.com>
> >> # Date 1498936389 14400
> >> #      Sat Jul 01 15:13:09 2017 -0400
> >> # Node ID 61ed2cc98fd17c50c7adf634d777d946781a9fc1
> >> # Parent  77e666f943a6c246d7fc970a8a36cd8b2023e03b
> >> test-rebase-interruptions: stabilize for Windows
> >>
> >> External hooks end up launching cmd.exe, which knows nothing about $VAR  
> >> syntax.
> >> For some reason, I thought that Mercurial would substitute in the  
> >> value, in
> >> order to paper over the platform difference.  But I can't find that in  
> >> the
> >> documentation, and there's at least one other use of this pattern [1].
> >>
> >> [1]  
> >> https://www.mercurial-scm.org/repo/hg/file/tip/tests/test-histedit-fold.t#l477
> >
> > Huh. I would have thought that, too. Should that be something we do?
> 
> Maybe it was aliases that I was thinking of, but that's not really env  
> related.  I haven't had a need for hooks yet, but I'd say yes, even if for  
> no other reason than it's one less mode of failure for Windows tests. :-)   
> Presumably, '\$foo' could be used to pass a literal $foo.

That probably means reimplementing shell (or shell parsing, at least), which
I wouldn't like to. shlex doesn't support everything the Unix shell can do.
Matt Harbison - July 2, 2017, 3:32 a.m.
On Sat, 01 Jul 2017 23:16:26 -0400, Yuya Nishihara <yuya@tcha.org> wrote:

> On Sat, 01 Jul 2017 21:29:37 -0400, Matt Harbison wrote:
>> On Sat, 01 Jul 2017 19:37:51 -0400, Sean Farley <sean@farley.io> wrote:
>> > Matt Harbison <mharbison72@gmail.com> writes:
>> >> # HG changeset patch
>> >> # User Matt Harbison <matt_harbison@yahoo.com>
>> >> # Date 1498936389 14400
>> >> #      Sat Jul 01 15:13:09 2017 -0400
>> >> # Node ID 61ed2cc98fd17c50c7adf634d777d946781a9fc1
>> >> # Parent  77e666f943a6c246d7fc970a8a36cd8b2023e03b
>> >> test-rebase-interruptions: stabilize for Windows
>> >>
>> >> External hooks end up launching cmd.exe, which knows nothing about  
>> $VAR
>> >> syntax.
>> >> For some reason, I thought that Mercurial would substitute in the
>> >> value, in
>> >> order to paper over the platform difference.  But I can't find that  
>> in
>> >> the
>> >> documentation, and there's at least one other use of this pattern  
>> [1].
>> >>
>> >> [1]
>> >>  
>> https://www.mercurial-scm.org/repo/hg/file/tip/tests/test-histedit-fold.t#l477
>> >
>> > Huh. I would have thought that, too. Should that be something we do?
>>
>> Maybe it was aliases that I was thinking of, but that's not really env
>> related.  I haven't had a need for hooks yet, but I'd say yes, even if  
>> for
>> no other reason than it's one less mode of failure for Windows tests.  
>> :-)
>> Presumably, '\$foo' could be used to pass a literal $foo.
>
> That probably means reimplementing shell (or shell parsing, at least),  
> which
> I wouldn't like to. shlex doesn't support everything the Unix shell can  
> do.

I was thinking find all instances of $foo in the command.  If the match  
starts with '\', drop that character.  Otherwise, substitute with %foo%  
before calling CreateProcess().  Windows doesn't understand single  
quoting, and doesn't need spaces around %foo% to substitute.  Are there  
other special cases that I'm not thinking of?
Yuya Nishihara - July 2, 2017, 2:20 p.m.
On Sat, 01 Jul 2017 23:32:07 -0400, Matt Harbison wrote:
> On Sat, 01 Jul 2017 23:16:26 -0400, Yuya Nishihara <yuya@tcha.org> wrote:
> > On Sat, 01 Jul 2017 21:29:37 -0400, Matt Harbison wrote:
> >> On Sat, 01 Jul 2017 19:37:51 -0400, Sean Farley <sean@farley.io> wrote:
> >> > Matt Harbison <mharbison72@gmail.com> writes:
> >> >> # HG changeset patch
> >> >> # User Matt Harbison <matt_harbison@yahoo.com>
> >> >> # Date 1498936389 14400
> >> >> #      Sat Jul 01 15:13:09 2017 -0400
> >> >> # Node ID 61ed2cc98fd17c50c7adf634d777d946781a9fc1
> >> >> # Parent  77e666f943a6c246d7fc970a8a36cd8b2023e03b
> >> >> test-rebase-interruptions: stabilize for Windows
> >> >>
> >> >> External hooks end up launching cmd.exe, which knows nothing about  
> >> $VAR
> >> >> syntax.
> >> >> For some reason, I thought that Mercurial would substitute in the
> >> >> value, in
> >> >> order to paper over the platform difference.  But I can't find that  
> >> in
> >> >> the
> >> >> documentation, and there's at least one other use of this pattern  
> >> [1].
> >> >>
> >> >> [1]
> >> >>  
> >> https://www.mercurial-scm.org/repo/hg/file/tip/tests/test-histedit-fold.t#l477
> >> >
> >> > Huh. I would have thought that, too. Should that be something we do?
> >>
> >> Maybe it was aliases that I was thinking of, but that's not really env
> >> related.  I haven't had a need for hooks yet, but I'd say yes, even if  
> >> for
> >> no other reason than it's one less mode of failure for Windows tests.  
> >> :-)
> >> Presumably, '\$foo' could be used to pass a literal $foo.
> >
> > That probably means reimplementing shell (or shell parsing, at least),  
> > which
> > I wouldn't like to. shlex doesn't support everything the Unix shell can  
> > do.
> 
> I was thinking find all instances of $foo in the command.  If the match  
> starts with '\', drop that character.  Otherwise, substitute with %foo%  
> before calling CreateProcess().  Windows doesn't understand single  
> quoting, and doesn't need spaces around %foo% to substitute.  Are there  
> other special cases that I'm not thinking of?

Ah, maybe it's okay to add a pretty basic UNIX emulation for Windows. I
heard the command parsing on Windows is somewhat weird, but it would be
much simpler than the POSIX shell.

Patch

diff --git a/tests/test-rebase-interruptions.t b/tests/test-rebase-interruptions.t
--- a/tests/test-rebase-interruptions.t
+++ b/tests/test-rebase-interruptions.t
@@ -333,7 +333,12 @@ 
 
   $ cp -R a3 hook-pretxncommit
   $ cd hook-pretxncommit
-  $ hg rebase --source 2 --dest 5 --tool internal:other --config 'hooks.pretxncommit=hg log -r $HG_NODE | grep "summary:     C"'
+#if windows
+  $ NODE="%HG_NODE%"
+#else
+  $ NODE="\$HG_NODE"
+#endif
+  $ hg rebase --source 2 --dest 5 --tool internal:other --config "hooks.pretxncommit=hg log -r $NODE | grep \"summary:     C\""
   rebasing 2:965c486023db "C"
   summary:     C
   rebasing 6:a0b2430ebfb8 "F" (tip)