aboutsummaryrefslogtreecommitdiff
path: root/tests/link/testscript
blob: 194b09320c25bcc517afcfc0680b37498ae8b694 (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
# file      : tests/link/testscript
# license   : MIT; see accompanying LICENSE file

: basics
:
$*

: follow-symlinks
:
: Note that we may not be able to create symlinks on Windows and so test on
: POSIX only. But that'is ok since the follow_symlinks() implementation is not
: platform-specific.
:
if ($cxx.target.class != 'windows')
{
  : not-symlink
  :
  {
    touch f;
    $* -f f >f
  }

  : not-exists
  :
  {
    $* -f f >f
  }

  : single-link
  :
  {
    : absolute
    :
    {
      $* -s $~/f l &l;
      $* -f l >/"$~/f"
    }

    : relative
    :
    {
      $* -s d/f l &l;
      $* -f l >/'d/f'
    }
  }

  : multiple-links
  :
  {
    : relative-path
    :
    {
      mkdir -p d1/d2;
      $* -s ../d3/f d1/d2/l1 &d1/d2/l1;

      $* -f d1/d2/l1                  >/'d1/d3/f';
      $* -f ../relative-path/d1/d2/l1 >/'../relative-path/d1/d3/f';

      mkdir d4;
      $* -s ../d1/d2/l1 d4/l2 &d4/l2;

      $* -f d4/l2    >/'d1/d3/f';
      $* -f $~/d4/l2 >/"$~/d1/d3/f"
    }

    : absolute-path
    :
    {
      mkdir -p d1/d2;
      $* -s ../d3/f d1/d2/l1 &d1/d2/l1;

      mkdir d4;
      $* -s $~/d1/d2/l1 d4/l2 &d4/l2;

      $* -f d4/l2    >/"$~/d1/d3/f";
      $* -f $~/d4/l2 >/"$~/d1/d3/f"
    }
  }
}