Patchwork [2,of,2] test-hardlink: do not test .hg/cache/checklink

login
register
mail settings
Submitter Jun Wu
Date May 15, 2017, 8:38 p.m.
Message ID <0e53ae9a7e47e6596e79.1494880717@x1c>
Download mbox | patch
Permalink /patch/20633/
State Accepted
Headers show

Comments

Jun Wu - May 15, 2017, 8:38 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1494880158 25200
#      Mon May 15 13:29:18 2017 -0700
# Node ID 0e53ae9a7e47e6596e79fa40fe6e6dc3e37db343
# Parent  caf620c5d0a0aa05e0bc36d3a97edc0e0a9b2b9c
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 0e53ae9a7e47
test-hardlink: do not test .hg/cache/checklink

Linux and BSD have different behavior on "os.link(src, dst)" where "src" is
a symlink. That causes test difference.

According to POSIX [1]:

  If path1 names a symbolic link, it is implementation-defined whether
  link() follows the symbolic link, or creates a new link to the symbolic
  link itself.

So both behaviors are correct. This patch removes the trouble maker
"checklink" to make the test pass on both platforms.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html
Sean Farley - May 16, 2017, 12:31 a.m.
Jun Wu <quark@fb.com> writes:

> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1494880158 25200
> #      Mon May 15 13:29:18 2017 -0700
> # Node ID 0e53ae9a7e47e6596e79fa40fe6e6dc3e37db343
> # Parent  caf620c5d0a0aa05e0bc36d3a97edc0e0a9b2b9c
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 0e53ae9a7e47
> test-hardlink: do not test .hg/cache/checklink
>
> Linux and BSD have different behavior on "os.link(src, dst)" where "src" is
> a symlink. That causes test difference.
>
> According to POSIX [1]:
>
>   If path1 names a symbolic link, it is implementation-defined whether
>   link() follows the symbolic link, or creates a new link to the symbolic
>   link itself.
>
> So both behaviors are correct. This patch removes the trouble maker
> "checklink" to make the test pass on both platforms.
>
> [1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html

Welp, fair enough. I think this will fix the error I'm seeing on my mac.
Queued! Will report back if it doesn't.

Patch

diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t
--- a/tests/test-hardlinks.t
+++ b/tests/test-hardlinks.t
@@ -215,4 +215,10 @@  Create hardlinked copy r4 of r3 (on Linu
   $ linkcp r3 r4
 
+'checklink' is produced by hardlinking a symlink, which is undefined whether
+the symlink should be followed or not. It does behave differently on Linux and
+BSD. Just remove it so the test pass on both platforms.
+
+  $ rm -f r4/.hg/cache/checklink
+
 r4 has hardlinks in the working dir (not just inside .hg):
 
@@ -221,5 +227,4 @@  r4 has hardlinks in the working dir (not
   2 r4/.hg/branch
   2 r4/.hg/cache/checkisexec (execbit !)
-  3 r4/.hg/cache/checklink (?)
   ? r4/.hg/cache/checklink-target (glob) (symlink !)
   2 r4/.hg/cache/checknoexec (execbit !)