Patchwork [6,of,7] tests: factor external procedures out for portability

login
register
mail settings
Submitter Katsunori FUJIWARA
Date June 9, 2017, 4:08 a.m.
Message ID <9b4ff10f9db00ae7d91a.1496981306@speaknoevil>
Download mbox | patch
Permalink /patch/21266/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - June 9, 2017, 4:08 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1496981269 -32400
#      Fri Jun 09 13:07:49 2017 +0900
# Node ID 9b4ff10f9db00ae7d91a28067d6b50655f5f957d
# Parent  cbeddc126d25bff1adc257a2ec9938763a449a95
tests: factor external procedures out for portability

Fortunately, "&&" is treated as "execute next, if previous doesn't
fail" both on POSIX and Windows. But keeping portability of
"dirstaterace.command" manually is troublesome.

This patch factors external procedures out as a shell script for
portability. "sh SCRIPT" always allows scripting in POSIX style.

This change is also for convenience. Fixed script name can reduce
command line arguments.

"r" prefix is needed for "sh '$TESTTMP/dirstaterace.sh'", because
$TESTTMP contains backslash on Windows.

Patch

diff --git a/tests/test-dirstate-race.t b/tests/test-dirstate-race.t
--- a/tests/test-dirstate-race.t
+++ b/tests/test-dirstate-race.t
@@ -57,7 +57,8 @@  confused with a file with the exec bit s
   >     extensions.wrapfunction(context.workingctx, '_checklookup', overridechecklookup)
   > def overridechecklookup(orig, self, files):
   >     # make an update that changes the dirstate from underneath
-  >     self._repo.ui.system(self._repo.ui.config('dirstaterace', 'command'), cwd=self._repo.root)
+  >     self._repo.ui.system(r"sh '$TESTTMP/dirstaterace.sh'",
+  >                          cwd=self._repo.root)
   >     return orig(self, files)
   > EOF
 
@@ -73,8 +74,11 @@  XXX Note that this returns M for files t
 definitely a bug, but the fix for that is hard and the next status run is fine
 anyway.
 
-  $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py \
-  >   --config dirstaterace.command='rm b && rm -r dir1 && rm d && mkdir d && rm e && mkdir e'
+  $ cat > $TESTTMP/dirstaterace.sh <<EOF
+  > rm b && rm -r dir1 && rm d && mkdir d && rm e && mkdir e
+  > EOF
+
+  $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py
   M d
   M e
   ! b