aboutsummaryrefslogtreecommitdiff
path: root/tests/dir-iterator
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-03-07 14:07:28 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-03-09 14:18:20 +0300
commitdcccba655fe848564e961b3f285ce3a82d3ac73a (patch)
tree598ced3b406d80c23798672930e1a17cfe112b75 /tests/dir-iterator
parent63b2988e4f2630cc688ff43b7e5f0d4f977896cd (diff)
Add more support for symlinks on Windows
See mksymlink() for details of the symlinks support on Windows.
Diffstat (limited to 'tests/dir-iterator')
-rw-r--r--tests/dir-iterator/testscript100
1 files changed, 71 insertions, 29 deletions
diff --git a/tests/dir-iterator/testscript b/tests/dir-iterator/testscript
index b1444ad..720622f 100644
--- a/tests/dir-iterator/testscript
+++ b/tests/dir-iterator/testscript
@@ -14,42 +14,84 @@ $* a >"reg b"
mkdir -p a/b;
$* a >"dir b"
-# Note that on Windows only directory symlinks are currently supported (see
-# mksymlink() for details).
-#
-: dangling-link
+: symlink
:
-if ($cxx.target.class != 'windows')
+: If we are not cross-testing let's test dangling and non-dangling symlynks.
+: On Windows that involves mklink command usability test. If we fail to create
+: a trial link (say because we are not in the Developer Mode and are running
+: non-elevated console), then the test group will be silently skipped.
+:
+if ($test.target == $build.host)
{
- +mkdir a
- +touch --no-cleanup a/b
- +ln -s a/b a/l
- +rm a/b
+ +if ($cxx.target.class != 'windows')
+ lns = ln -s wd/t wd/l &wd/l
+ else
+ echo 'yes' >=t
+ if cmd /C 'mklink l t' >- 2>- &?l && cat l >'yes'
+ lns = cmd /C 'mklink wd\l t' &wd/l >-
+ end
- +touch a/c
+ jnc = cmd /C 'mklink /J wd\l wd\t' &wd/l >-
+ end
- $* ../a >! 2>! != 0 : keep
- $* -i ../a >'reg c' : skip
-}
-else
-{
- +mkdir a
- +mkdir --no-cleanup a/b
- +ln -s a/b a/bl
- +rmdir a/b
+ : symlink
+ :
+ if! $empty($lns)
+ {
+ : file
+ :
+ {
+ +mkdir wd
+ +touch --no-cleanup wd/t
+ +touch wd/f
+ +$lns
+ +$* wd >>~%EOO%
+ %(reg f|reg t|sym reg l)%{3}
+ EOO
+ +rm wd/t
- +touch a/c
+ $* ../wd >- 2>! != 0 : keep
+ $* -i ../wd >'reg f': skip
+ }
- +mkdir a/d
- +ln -s a/d a/dl
+ : dir
+ :
+ {
+ +mkdir wd
+ +mkdir --no-cleanup wd/t
+ +mkdir wd/d
+ +$lns
- # On Wine dangling symlinks are not visible (see mksymlink() for details).
- #
- #$* ../a >! 2>! != 0 : keep
+ # Note that this test may fail on Windows (see symlinks known issues in
+ # libbutl/filesystem.mxx).
+ #
+ +if ($cxx.target.class != 'windows')
+ $* wd >>~%EOO%
+ %(dir d|dir t|sym dir l)%{3}
+ EOO
+ end
- : skip
+ +rmdir wd/t
+
+ $* ../wd >- 2>! != 0 : keep
+ $* -i ../wd >'dir d': skip
+ }
+ }
+
+ : junction
:
- $* -i ../a >>~%EOO%
- %(reg c|dir d|sym dir dl)%{3}
- EOO
+ if! $empty($jnc)
+ {
+ +mkdir wd
+ +mkdir --no-cleanup wd/t
+ +mkdir wd/d
+ +$jnc
+ +$* wd >>~%EOO%
+ %(dir d|dir t|sym dir l)%{3}
+ EOO
+ +rmdir wd/t
+
+ $* ../wd >- 2>! != 0 : keep
+ $* -i ../wd >'dir d': skip
+ }
}