tests: introduce hghave hardlinks stable
authorMads Kiilerich <mads@kiilerich.com>
Fri, 15 Jun 2012 00:02:27 +0200
branchstable
changeset 1102 51afb47e2399
parent 1101 89f984505cbb
child 1103 9459951761fb
child 1104 5c7fdc5d6a36
tests: introduce hghave hardlinks Some tests can't be run on FAT filesystems because it doesn't support hardlinks. [ original upstream message ]
tests/hghave.py
--- a/tests/hghave.py	Fri Jun 15 00:02:27 2012 +0200
+++ b/tests/hghave.py	Fri Jun 15 00:02:27 2012 +0200
@@ -189,6 +189,21 @@
     except (OSError, AttributeError):
         return False
 
+def has_hardlink():
+    from mercurial import util
+    fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
+    os.close(fh)
+    name = tempfile.mktemp(dir='.', prefix=tempprefix)
+    try:
+        try:
+            util.oslink(fn, name)
+            os.unlink(name)
+            return True
+        except OSError:
+            return False
+    finally:
+        os.unlink(fn)
+
 def has_tla():
     return matchoutput('tla --version 2>&1', r'The GNU Arch Revision')
 
@@ -266,6 +281,7 @@
     "gettext": (has_gettext, "GNU Gettext (msgfmt)"),
     "git": (has_git, "git command line client"),
     "gpg": (has_gpg, "gpg client"),
+    "hardlink": (has_hardlink, "hardlinks"),
     "icasefs": (has_icasefs, "case insensitive file system"),
     "inotify": (has_inotify, "inotify extension support"),
     "lsprof": (has_lsprof, "python lsprof module"),