[PATCH STABLE] tests: run "cwd was removed" test only if cwd can actually be removed

Yuya Nishihara yuya at tcha.org
Wed Oct 26 14:11:26 UTC 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1477489806 -32400
#      Wed Oct 26 22:50:06 2016 +0900
# Branch stable
# Node ID d389b88b942adb330819437ef46d1b9acb4392d7
# Parent  b9f7b0c10027764cee77f9c6d61877fcffea837f
tests: run "cwd was removed" test only if cwd can actually be removed

On some platforms, cwd can't be removed. In which case, util.unlinkpath()
continues with no error since the failure isn't critical. So it doesn't
make sense to run the test added by 90a6c18a7c1d on those platforms.

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -346,6 +346,19 @@ def has_hardlink():
     finally:
         os.unlink(fn)
 
+ at check("rmcwd", "can remove current working directory")
+def has_rmcwd():
+    ocwd = os.getcwd()
+    temp = tempfile.mkdtemp(dir='.', prefix=tempprefix)
+    try:
+        os.chdir(temp)
+        os.rmdir(os.getcwd())
+        return True
+    except OSError:
+        return False
+    finally:
+        os.chdir(ocwd)
+
 @check("tla", "GNU Arch tla client")
 def has_tla():
     return matchoutput('tla --version 2>&1', br'The GNU Arch Revision')
diff --git a/tests/test-update-names.t b/tests/test-update-names.t
--- a/tests/test-update-names.t
+++ b/tests/test-update-names.t
@@ -73,6 +73,8 @@ Test update when two commits have symlin
 
 #endif
 
+#if rmcwd
+
 Test that warning is printed if cwd is deleted during update
   $ hg init r4 && cd r4
   $ mkdir dir
@@ -84,3 +86,5 @@ Test that warning is printed if cwd is d
   $ hg up -q null
   current directory was removed
   (consider changing to repo root: $TESTTMP/r1/r4)
+
+#endif


More information about the Mercurial-devel mailing list