Patchwork solaris: tests can't use tail -n

login
register
mail settings
Submitter Danek Duvall
Date Aug. 26, 2013, 10:21 p.m.
Message ID <871cf1a5a705871efca2.1377555697@smelly>
Download mbox | patch
Permalink /patch/2271/
State Accepted
Commit 3193b23eec61b95442097514ca479474b6e8dae6
Headers show

Comments

Danek Duvall - Aug. 26, 2013, 10:21 p.m.
# HG changeset patch
# User Danek Duvall <danek.duvall@oracle.com>
# Date 1377555644 25200
# Node ID 871cf1a5a705871efca2edf3e78c6bd70c16d20e
# Parent  98bfce1f5769084ddf0483e613381a3580d056ed
solaris: tests can't use tail -n

Solaris tail doesn't recognize the -n option.  Replace the one use of it
with some inline python code, and add a test case to check-code.py.

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -67,6 +67,7 @@  testpats = [
     (r'echo -n', "don't use 'echo -n', use printf"),
     (r'(^| )wc[^|]*$\n(?!.*\(re\))', "filter wc output"),
     (r'head -c', "don't use 'head -c', use 'dd'"),
+    (r'tail -n', "don't use the '-n' option to tail, just use '-<num>'"),
     (r'sha1sum', "don't use sha1sum, use $TESTDIR/md5sum.py"),
     (r'ls.*-\w*R', "don't use 'ls -R', use 'find'"),
     (r'printf.*[^\\]\\([1-9]|0\d)', "don't use 'printf \NNN', use Python"),
diff --git a/tests/test-import-merge.t b/tests/test-import-merge.t
--- a/tests/test-import-merge.t
+++ b/tests/test-import-merge.t
@@ -129,7 +129,9 @@  Test that --exact on a bad header doesn'
   $ echo a>>a
   $ hg ci -m3
   $ hg export 2 | head -7 > ../a.patch
-  $ hg export tip | tail -n +8 >> ../a.patch
+  $ hg export tip > out
+  >>> apatch = open("../a.patch", "a")
+  >>> apatch.write("".join(open("out").readlines()[7:]))
 
   $ cd ..
   $ hg clone -qr0 repo3 repo3-clone