Patchwork [STABLE] tests: make tests with temporary environment setting portable

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 1, 2015, 3:20 p.m.
Message ID <7086e9cfe82c6c5c08ad.1430493639@juju>
Download mbox | patch
Permalink /patch/8825/
State Accepted
Commit 8cc6036bca532e06681c5a8fa37efaa812de67b5
Headers show

Comments

Katsunori FUJIWARA - May 1, 2015, 3:20 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1430493303 -32400
#      Sat May 02 00:15:03 2015 +0900
# Branch stable
# Node ID 7086e9cfe82c6c5c08ad634aa8cfb74fb67b01d7
# Parent  ab9390165429b7891364c0d454f3ae3b04b00c7d
tests: make tests with temporary environment setting portable

With "dash" (as "/bin/sh" on Debian GNU/Linux), command execution in
"ENV=val foo bar" style doesn't work as expect in test script files,
if "foo" is user-defined function: it works fine, if "foo" is existing
commands like "hg".

09049042ab99 introduced tests for HGPLAIN and HGPLAINEXCEPT into
test-revset.t, and all of them are in such style.

This patch doesn't:

  - add explicit unsetting for HGPLAIN and HGPLAINEXCEPT

    they are already introduced by 09049042ab99

  - write assignment and exporting in one line

    "ENV=val; export ENV" for two or more environment variables in one
    line causes failure of test-check-code-hg.t: it is recognized as
    "don't export and assign at once" unfortunately.
Martin von Zweigbergk - May 1, 2015, 6:48 p.m.
On Fri, May 1, 2015 at 8:21 AM FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
wrote:

> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1430493303 -32400
> #      Sat May 02 00:15:03 2015 +0900
> # Branch stable
> # Node ID 7086e9cfe82c6c5c08ad634aa8cfb74fb67b01d7
> # Parent  ab9390165429b7891364c0d454f3ae3b04b00c7d
> tests: make tests with temporary environment setting portable
>
> With "dash" (as "/bin/sh" on Debian GNU/Linux), command execution in
> "ENV=val foo bar" style doesn't work as expect in test script files,
> if "foo" is user-defined function: it works fine, if "foo" is existing
> commands like "hg".
>
> 09049042ab99 introduced tests for HGPLAIN and HGPLAINEXCEPT into
> test-revset.t, and all of them are in such style.
>
> This patch doesn't:
>
>   - add explicit unsetting for HGPLAIN and HGPLAINEXCEPT
>
>     they are already introduced by 09049042ab99
>
>   - write assignment and exporting in one line
>
>     "ENV=val; export ENV" for two or more environment variables in one
>     line causes failure of test-check-code-hg.t: it is recognized as
>     "don't export and assign at once" unfortunately.
>
> diff --git a/tests/test-revset.t b/tests/test-revset.t
> --- a/tests/test-revset.t
> +++ b/tests/test-revset.t
> @@ -1066,12 +1066,16 @@ aliases:
>      <fullreposet+ 0:9>>
>    6
>
> -  $ HGPLAIN=1 try m
> +  $ HGPLAIN=1
> +  $ export HGPLAIN
> +  $ try m
>    ('symbol', 'm')
>    abort: unknown revision 'm'!
>    [255]
>
> -  $ HGPLAIN=1 HGPLAINEXCEPT=revsetalias try m
> +  $ HGPLAINEXCEPT=revsetalias
> +  $ export HGPLAINEXCEPT
> +  $ try m
>    ('symbol', 'm')
>    (func
>      ('symbol', 'merge')
>

Also drop the "(for some reason HGPLAIN and HGPLAINEXCEPT can carry
forward)" comment now? It seems quite expected after this patch.


> @@ -1097,14 +1101,18 @@ aliases:
>    <baseset+ [8]>
>    8
>
> -  $ HGPLAIN=1 try 'p2(.)'
> +  $ HGPLAIN=1
> +  $ export HGPLAIN
> +  $ try 'p2(.)'
>    (func
>      ('symbol', 'p2')
>      ('symbol', '.'))
>    * set:
>    <baseset+ []>
>
> -  $ HGPLAIN=1 HGPLAINEXCEPT=revsetalias try 'p2(.)'
> +  $ HGPLAINEXCEPT=revsetalias
> +  $ export HGPLAINEXCEPT
> +  $ try 'p2(.)'
>    (func
>      ('symbol', 'p2')
>      ('symbol', '.'))
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Matt Mackall - May 1, 2015, 7:51 p.m.
On Fri, 2015-05-01 at 18:48 +0000, Martin von Zweigbergk wrote:
> On Fri, May 1, 2015 at 8:21 AM FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> wrote:
> 
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> > # Date 1430493303 -32400
> > #      Sat May 02 00:15:03 2015 +0900
> > # Branch stable
> > # Node ID 7086e9cfe82c6c5c08ad634aa8cfb74fb67b01d7
> > # Parent  ab9390165429b7891364c0d454f3ae3b04b00c7d
> > tests: make tests with temporary environment setting portable
> >
> > With "dash" (as "/bin/sh" on Debian GNU/Linux), command execution in
> > "ENV=val foo bar" style doesn't work as expect in test script files,
> > if "foo" is user-defined function: it works fine, if "foo" is existing
> > commands like "hg".
> >
> > 09049042ab99 introduced tests for HGPLAIN and HGPLAINEXCEPT into
> > test-revset.t, and all of them are in such style.
> >
> > This patch doesn't:
> >
> >   - add explicit unsetting for HGPLAIN and HGPLAINEXCEPT
> >
> >     they are already introduced by 09049042ab99
> >
> >   - write assignment and exporting in one line
> >
> >     "ENV=val; export ENV" for two or more environment variables in one
> >     line causes failure of test-check-code-hg.t: it is recognized as
> >     "don't export and assign at once" unfortunately.
> >
> > diff --git a/tests/test-revset.t b/tests/test-revset.t
> > --- a/tests/test-revset.t
> > +++ b/tests/test-revset.t
> > @@ -1066,12 +1066,16 @@ aliases:
> >      <fullreposet+ 0:9>>
> >    6
> >
> > -  $ HGPLAIN=1 try m
> > +  $ HGPLAIN=1
> > +  $ export HGPLAIN
> > +  $ try m
> >    ('symbol', 'm')
> >    abort: unknown revision 'm'!
> >    [255]
> >
> > -  $ HGPLAIN=1 HGPLAINEXCEPT=revsetalias try m
> > +  $ HGPLAINEXCEPT=revsetalias
> > +  $ export HGPLAINEXCEPT
> > +  $ try m
> >    ('symbol', 'm')
> >    (func
> >      ('symbol', 'merge')
> >
> 
> Also drop the "(for some reason HGPLAIN and HGPLAINEXCEPT can carry
> forward)" comment now? It seems quite expected after this patch.

I've queued this for stable with Martin's suggestion rolled in, thanks.

Patch

diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1066,12 +1066,16 @@  aliases:
     <fullreposet+ 0:9>>
   6
 
-  $ HGPLAIN=1 try m
+  $ HGPLAIN=1
+  $ export HGPLAIN
+  $ try m
   ('symbol', 'm')
   abort: unknown revision 'm'!
   [255]
 
-  $ HGPLAIN=1 HGPLAINEXCEPT=revsetalias try m
+  $ HGPLAINEXCEPT=revsetalias
+  $ export HGPLAINEXCEPT
+  $ try m
   ('symbol', 'm')
   (func
     ('symbol', 'merge')
@@ -1097,14 +1101,18 @@  aliases:
   <baseset+ [8]>
   8
 
-  $ HGPLAIN=1 try 'p2(.)'
+  $ HGPLAIN=1
+  $ export HGPLAIN
+  $ try 'p2(.)'
   (func
     ('symbol', 'p2')
     ('symbol', '.'))
   * set:
   <baseset+ []>
 
-  $ HGPLAIN=1 HGPLAINEXCEPT=revsetalias try 'p2(.)'
+  $ HGPLAINEXCEPT=revsetalias
+  $ export HGPLAINEXCEPT
+  $ try 'p2(.)'
   (func
     ('symbol', 'p2')
     ('symbol', '.'))