# HG changeset patch # User Mads Kiilerich # Date 2012-06-14 22:02:27 # Node ID 8aeb2f1ae94cdd27895cfc0db59a26cec7a920d1 # Parent 8be2a28cc782b990b5d5d2cc77a7e6080c8fe039 tests: introduce hghave hardlinks Some tests can't be run on FAT filesystems because it doesn't support hardlinks. diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -189,6 +189,21 @@ def has_symlink(): 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 @@ checks = { "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"), diff --git a/tests/test-clone.t b/tests/test-clone.t --- a/tests/test-clone.t +++ b/tests/test-clone.t @@ -48,8 +48,13 @@ Invalid dest '' must abort: No update, with debug option: +#if hardlink $ hg --debug clone -U . ../c linked 8 files +#else + $ hg --debug clone -U . ../c + copied 8 files +#endif $ cd ../c $ cat a 2>/dev/null || echo "a not present" a not present diff --git a/tests/test-contrib.t b/tests/test-contrib.t --- a/tests/test-contrib.t +++ b/tests/test-contrib.t @@ -104,6 +104,8 @@ Compare repos: [1] +#if hardlink + Test shrink-revlog: $ cd repo-a $ hg --config extensions.shrink="$CONTRIBDIR/shrink-revlog.py" shrink @@ -127,6 +129,8 @@ Test shrink-revlog: 1 files, 3 changesets, 3 total revisions $ cd .. +#endif + Test simplemerge command: $ cp "$CONTRIBDIR/simplemerge" . diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t --- a/tests/test-hardlinks.t +++ b/tests/test-hardlinks.t @@ -1,3 +1,5 @@ + $ "$TESTDIR/hghave" hardlink || exit 80 + $ cat > nlinks.py < import sys > from mercurial import util diff --git a/tests/test-relink.t b/tests/test-relink.t --- a/tests/test-relink.t +++ b/tests/test-relink.t @@ -1,3 +1,5 @@ + $ "$TESTDIR/hghave" hardlink || exit 80 + $ echo "[extensions]" >> $HGRCPATH $ echo "relink=" >> $HGRCPATH