tests/hghave.py
branchstable
changeset 30230 46a0203dfb89
parent 29903 fe81c953f369
child 30242 389cbfe63586
--- a/tests/hghave.py	Tue Oct 25 21:01:53 2016 +0200
+++ b/tests/hghave.py	Wed Oct 26 22:50:06 2016 +0900
@@ -346,6 +346,21 @@
     finally:
         os.unlink(fn)
 
+@check("rmcwd", "can remove current working directory")
+def has_rmcwd():
+    ocwd = os.getcwd()
+    temp = tempfile.mkdtemp(dir='.', prefix=tempprefix)
+    try:
+        os.chdir(temp)
+        # On Linux, 'rmdir .' isn't allowed, but the other names are okay.
+        # On Solaris and Windows, the cwd can't be removed by any names.
+        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')