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

.include ../common.testscript

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

  : 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 && $b
  touch a;
  test -d a == 1
  EOI
}

: 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 <<EOI && $b
test -f a b 2>"test: unexpected argument 'b'" == 2
EOI

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