aboutsummaryrefslogtreecommitdiff
path: root/tests/test/script/builtin/test.test
blob: 7e9ace4ff192a1430a344b6ada4a98eda07da576 (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/test/script/builtin/test.test
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

.include ../common.test

: file
:
{
  : exists
  :
  $c <<EOI;
  touch a;
  test -f a
  EOI
  $b

  : not-exists
  :
  $c <'test -f a == 1';
  $b

  : not-file
  :
  $c <'test -f . == 1';
  $b
}

: dir
:
{
  : exists
  :
  $c <'test -d .';
  $b

  : not-exists
  :
  $c <'test -d a == 1';
  $b

  : not-dir
  :
  $c <<EOI;
  touch a;
  test -d a == 1
  EOI
  $b
}

: no-args
:
: Test passing no arguments.
:
$c <'test 2>"test: missing path" == 2';
$b

: invalid-option
:
: Test passing invalid option.
:
$c <'test -c a 2>"test: invalid option" == 2';
$b

: unexpected-arg
:
: Test passing extra argument.
:
$c <'test -f a b 2>"test: unexpected argument" == 2';
$b

: empty-path
:
: Test testing an empty path.
:
$c <<EOI;
test -d '' 2>"test: invalid path ''" == 2
EOI
$b