Patchwork [2,of,7] tests: change blackbox test to work cross platform

login
register
mail settings
Submitter timeless@mozdev.org
Date Feb. 3, 2016, 9:40 p.m.
Message ID <53190dfbd7ebb3fe6bc7.1454535644@waste.org>
Download mbox | patch
Permalink /patch/12962/
State Superseded
Commit 142891ab6e892bb3df64a15512400adba734ba23
Delegated to: Yuya Nishihara
Headers show

Comments

timeless@mozdev.org - Feb. 3, 2016, 9:40 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1454523318 0
#      Wed Feb 03 18:15:18 2016 +0000
# Node ID 53190dfbd7ebb3fe6bc714ce08f8c1a7ae7ef16e
# Parent  65b75dd6ed071300014eefc947c517b292ed9f86
tests: change blackbox test to work cross platform

While it is not easy to make a file 000 on Windows, you can
emulate most of the behaviors by replacing the file with a directory.
Yuya Nishihara - Feb. 7, 2016, 2:08 p.m.
On Wed, 03 Feb 2016 15:40:44 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1454523318 0
> #      Wed Feb 03 18:15:18 2016 +0000
> # Node ID 53190dfbd7ebb3fe6bc714ce08f8c1a7ae7ef16e
> # Parent  65b75dd6ed071300014eefc947c517b292ed9f86
> tests: change blackbox test to work cross platform

> +  $ perl -pne 'if (/test1/) {s/^/#/; next} if (/commit2/) { print qq{os.rmdir(".hg/blackbox.log")\nos.rename(".hg/blackbox.log-", ".hg/blackbox.log")\n} }' $TESTDIR/test-dispatch.py > ../test-dispatch.py

This is the first patch that depends on perl. Can you rewrite it by sed or
python?

Patch

diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -45,7 +45,7 @@ 
   (run 'hg update' to get a working copy)
   $ hg blackbox -l 5
   1970/01/01 00:00:00 bob (*)> pull (glob)
-  1970/01/01 00:00:00 bob (*)> updated served branch cache in ?.???? seconds (glob)
+  1970/01/01 00:00:00 bob (*)> updated served branch cache in * seconds (glob)
   1970/01/01 00:00:00 bob (*)> wrote served branch cache with 1 labels and 2 nodes (glob)
   1970/01/01 00:00:00 bob (*)> 1 incoming changes - new heads: d02f48003e62 (glob)
   1970/01/01 00:00:00 bob (*)> pull exited 0 after * seconds (glob)
@@ -55,10 +55,10 @@ 
   $ hg rollback
   repository tip rolled back to revision 1 (undo pull)
 
-#if unix-permissions no-root
-  $ chmod 000 .hg/blackbox.log
+  $ mv .hg/blackbox.log .hg/blackbox.log-
+  $ mkdir .hg/blackbox.log
   $ hg --debug incoming
-  warning: cannot write to blackbox.log: Permission denied
+  warning: cannot write to blackbox.log: * (glob)
   comparing with $TESTTMP/blackboxtest (glob)
   query 1; heads
   searching for changes
@@ -77,7 +77,6 @@ 
   c
   
   
-#endif
   $ hg pull
   pulling from $TESTTMP/blackboxtest (glob)
   searching for changes
@@ -88,13 +87,13 @@ 
   (run 'hg update' to get a working copy)
 
 a failure reading from the log is fine
-#if unix-permissions no-root
+
   $ hg blackbox -l 3
-  abort: Permission denied: $TESTTMP/blackboxtest2/.hg/blackbox.log
+  abort: *: $TESTTMP/blackboxtest2/.hg/blackbox.log (glob)
   [255]
 
-  $ chmod 600 .hg/blackbox.log
-#endif
+  $ rmdir .hg/blackbox.log
+  $ mv .hg/blackbox.log- .hg/blackbox.log
 
 backup bundles get logged
 
@@ -108,7 +107,7 @@ 
   $ hg blackbox -l 5
   1970/01/01 00:00:00 bob (*)> strip tip (glob)
   1970/01/01 00:00:00 bob (*)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob)
-  1970/01/01 00:00:00 bob (*)> updated base branch cache in ?.???? seconds (glob)
+  1970/01/01 00:00:00 bob (*)> updated base branch cache in * seconds (glob)
   1970/01/01 00:00:00 bob (*)> wrote base branch cache with 1 labels and 2 nodes (glob)
   1970/01/01 00:00:00 bob (*)> strip tip exited 0 after * seconds (glob)
 
@@ -142,6 +141,39 @@ 
   .hg/blackbox.log
   .hg/blackbox.log.1
   .hg/blackbox.log.2
+  $ cd ..
+
+  $ hg init blackboxtest3
+  $ cd blackboxtest3
+  $ hg blackbox
+  $ mv .hg/blackbox.log .hg/blackbox.log-
+  $ mkdir .hg/blackbox.log
+  $ perl -pne 'if (/test1/) {s/^/#/; next} if (/commit2/) { print qq{os.rmdir(".hg/blackbox.log")\nos.rename(".hg/blackbox.log-", ".hg/blackbox.log")\n} }' $TESTDIR/test-dispatch.py > ../test-dispatch.py
+  $ python ../test-dispatch.py
+  running: add foo
+  result: 0
+  running: commit -m commit1 -d 2000-01-01 foo
+  result: None
+  running: commit -m commit2 -d 2000-01-02 foo
+  result: None
+  running: log -r 0
+  changeset:   0:0e4634943879
+  user:        test
+  date:        Sat Jan 01 00:00:00 2000 +0000
+  summary:     commit1
+  
+  result: None
+  running: log -r tip
+  changeset:   1:45589e459b2e
+  tag:         tip
+  user:        test
+  date:        Sun Jan 02 00:00:00 2000 +0000
+  summary:     commit2
+  
+  result: None
+  $ hg blackbox
+  1970/01/01 00:00:00 bob (*)> blackbox (glob)
+  1970/01/01 00:00:00 bob (*)> blackbox exited 0 after * seconds (glob)
 
 cleanup
   $ cd ..