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

.include ../common.test

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

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