aboutsummaryrefslogtreecommitdiff
path: root/tests/dir-iterator/testscript
blob: 720622f5188f14cbf70c8caf1cdbf8612e4f9f67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# file      : tests/dir-iterator/testscript
# license   : MIT; see accompanying LICENSE file

test.options = -v

: file
:
mkdir a;
touch a/b;
$* a >"reg     b"

: dir
:
mkdir -p a/b;
$* a >"dir     b"

: symlink
:
: 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)
{
  +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

    jnc = cmd /C 'mklink /J wd\l wd\t' &wd/l >-
  end

  : 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

      $*    ../wd >- 2>! != 0 : keep
      $* -i ../wd >'reg     f': skip
    }

    : dir
    :
    {
      +mkdir wd
      +mkdir --no-cleanup wd/t
      +mkdir wd/d
      +$lns

      # 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

      +rmdir wd/t

      $*    ../wd >- 2>! != 0 : keep
      $* -i ../wd >'dir     d': skip
    }
  }

  : junction
  :
  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
  }
}