Patchwork [V2] tests: replace seq with seq.py for OS X support

login
register
mail settings
Submitter Matt Harbison
Date March 17, 2015, 7:14 p.m.
Message ID <8d21c9f9a051a485878e.1426619648@MATT7H-PC.attotech.com>
Download mbox | patch
Permalink /patch/8126/
State Superseded
Headers show

Comments

Matt Harbison - March 17, 2015, 7:14 p.m.
# HG changeset patch
# User Matt Harbison <mharbison@attotech.com>
# Date 1426618937 14400
#      Tue Mar 17 15:02:17 2015 -0400
# Node ID 8d21c9f9a051a485878e42185c203383e5688a39
# Parent  b7f936f47f2b104a60840bae571e009742126afc
tests: replace seq with seq.py for OS X support

10.6.8 doesn't have it, while 10.10 does.  I'm not sure when it was added.

There's a difference in this seq.py and the one proposed by foozy[1], in that
this starts at 1.  Otherwise, other test diffs occurred.

[1] http://www.selenic.com/pipermail/mercurial-devel/2015-March/067356.html
Matt Mackall - March 17, 2015, 8:47 p.m.
On Tue, 2015-03-17 at 15:14 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <mharbison@attotech.com>
> # Date 1426618937 14400
> #      Tue Mar 17 15:02:17 2015 -0400
> # Node ID 8d21c9f9a051a485878e42185c203383e5688a39
> # Parent  b7f936f47f2b104a60840bae571e009742126afc
> tests: replace seq with seq.py for OS X support
> 
> 10.6.8 doesn't have it, while 10.10 does.  I'm not sure when it was added.

This isn't all the users of seq? 

This is kind of amazing: all these instances of seq have crept in in the
past year, and somehow we'd never tried to use it in the past:

~/hg/tests$ hg grep -a "seq " .
tests/test-censor.t:27130:  $ for x in `seq 0 50000`
tests/test-commit-interactive-curses.t:27125:  $ seq 1 10 > b
tests/test-tools.t:26482:  $ seq 10 > bar
tests/test-setdiscovery.t:26262:  $ for i in `seq 101`; do hg -R r1 up -qr null && hg -R r1 branch -q b$i && hg -R r1 ci -qmb$i; done
tests/test-setdiscovery.t:26262:  $ for i in `seq 10`; do hg -R r1 up -qr null && hg -R r1 branch -q c$i && hg -R r1 ci -qmc$i; done
tests/test-push-warn.t:26124:  $ for i in `seq 3`; do hg -R h up -q 0; echo $i > h/b; hg -R h ci -qAm$i; done
tests/test-ancestor.py:25428:            seq = []

Anyway, I don't know that we want to cut-n-paste seq.py into N scripts.
We also need a check-code rule to keep from adding more instances.

Patch

diff --git a/tests/test-push-warn.t b/tests/test-push-warn.t
--- a/tests/test-push-warn.t
+++ b/tests/test-push-warn.t
@@ -1,3 +1,9 @@ 
+  $ cat > $TESTTMP/seq.py <<EOF
+  > import sys
+  > for i in xrange(*[int(a) for a in sys.argv[1:]]):
+  >     print i+1
+  > EOF
+
   $ hg init a
   $ cd a
   $ echo foo > t1
@@ -411,7 +417,7 @@  multiple new heads but also doesn't repo
   adding c
   created new head
 
-  $ for i in `seq 3`; do hg -R h up -q 0; echo $i > h/b; hg -R h ci -qAm$i; done
+  $ for i in `python $TESTTMP/seq.py 3`; do hg -R h up -q 0; echo $i > h/b; hg -R h ci -qAm$i; done
 
   $ hg -R i push h
   pushing to h
diff --git a/tests/test-tools.t b/tests/test-tools.t
--- a/tests/test-tools.t
+++ b/tests/test-tools.t
@@ -1,4 +1,9 @@ 
 Tests of the file helper tool
+  $ cat > $TESTTMP/seq.py <<EOF
+  > import sys
+  > for i in xrange(*[int(a) for a in sys.argv[1:]]):
+  >     print i+1
+  > EOF
 
   $ f -h
   ?sage: f [options] [filenames] (glob)
@@ -43,7 +48,7 @@  Tests of the file helper tool
   foo: mode=644
 #endif
 
-  $ seq 10 > bar
+  $ python $TESTTMP/seq.py 10 > bar
 #if unix-permissions symlink
   $ chmod +x bar
   $ f bar --newer foo --mode --type --size --dump --links --bytes 7