aboutsummaryrefslogtreecommitdiff
path: root/tests/builtin/test.testscript
blob: fe023aeb379d8c870881f11fc74753c71e9548a0 (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
# file      : tests/builtin/test.testscript
# license   : MIT; see accompanying LICENSE file

test.arguments = "test"

: file
:
{
  : exists
  :
  touch a;
  $* -f a

  : not-exists
  :
  $* -f a == 1

  : not-file
  :
  $* -f . == 1
}

: dir
:
{
  : exists
  :
  $* -d .

  : not-exists
  :
  $* -d a == 1

  : not-dir
  :
  touch a;
  $* -d a == 1
}

: options
:
{
  : unknown
  :
  $* -u 2>"test: unknown option '-u'" == 2

  : none
  :
  $* 2>"test: either -f|--file or -d|--directory must be specified" == 2

  : both-file-dir
  :
  $* -fd 2>"test: both -f|--file and -d|--directory specified" == 2
}

: args
:
{
  : none
  :
  $* -f 2>"test: missing path" == 2

  : unexpected
  :
  $* -f a b 2>"test: unexpected argument 'b'" == 2

  : empty-path
  :
  $* -d '' 2>"test: invalid path ''" == 2
}

: cwd
:
: When cross-testing we cannot guarantee that host absolute paths are
: recognized by the target process.
:
if ($test.target == $build.host)
{
  test.options += -d $~/a;
  mkdir -p a/b;

  $* -d b
}