Patchwork D11449: tests: make removeemptydirs more portable

login
register
mail settings
Submitter phabricator
Date Sept. 17, 2021, 2:06 p.m.
Message ID <differential-rev-PHID-DREV-hgrbqzu5vgz6rvxpxlau-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49765/
State Superseded
Headers show

Comments

phabricator - Sept. 17, 2021, 2:06 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The behavior of pwd change from one system (i.e. default shell/sh) from one
  system to another so we use fuzzy matching for the output we do not care and we
  use narrower command call to highlight what we are trying to test here.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D11449

AFFECTED FILES
  contrib/check-code.py
  tests/test-removeemptydirs.t

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-removeemptydirs.t b/tests/test-removeemptydirs.t
--- a/tests/test-removeemptydirs.t
+++ b/tests/test-removeemptydirs.t
@@ -1,5 +1,13 @@ 
 Tests for experimental.removeemptydirs
 
+  $ cat >> pwd.py << EOF
+  > import os
+  > try:
+  >     print(os.getcwd())
+  > except OSError:
+  >     print("<directory is no longer accessible>")
+  > EOF
+
   $ NO_RM=--config=experimental.removeemptydirs=0
   $ DO_RM=--config=experimental.removeemptydirs=1
   $ isdir() { if [ -d $1 ]; then echo yes; else echo no; fi }
@@ -132,8 +140,15 @@ 
   r1
   r2
   somedir
-  $ pwd
+#if windows
+  $ "$PYTHON" "$TESTTMP/pwd.py"
   $TESTTMP/hghistedit/somedir
+#else
+  $ echo ${PWD} # no-pwd-check
+  $TESTTMP/hghistedit/somedir
+  $ "$PYTHON" "$TESTTMP/pwd.py"
+  <directory is no longer accessible>
+#endif
   $ ls -1 $TESTTMP/hghistedit/somedir
   foo
   $ ls -1
@@ -142,6 +157,7 @@ 
 Get out of the doomed directory
 
   $ cd $TESTTMP/hghistedit
+  chdir: error retrieving current directory: getcwd: cannot access parent directories: $ENOENT$ (?)
   $ hg files --rev . | grep somedir/
   somedir/foo
 
diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -195,7 +195,7 @@ 
     [
         (r'^function', "don't use 'function', use old style"),
         (r'^diff.*-\w*N', "don't use 'diff -N'"),
-        (r'\$PWD|\${PWD}', "don't use $PWD, use `pwd`"),
+        (r'\$PWD|\${PWD}', "don't use $PWD, use `pwd`", "no-pwd-check"),
         (r'^([^"\'\n]|("[^"\n]*")|(\'[^\'\n]*\'))*\^', "^ must be quoted"),
         (r'kill (`|\$\()', "don't use kill, use killdaemons.py"),
     ],