aboutsummaryrefslogtreecommitdiff
path: root/tests/builtin/touch.testscript
blob: e7e2d04066db0bf68bfd342e4f486428a6e0f782 (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
84
85
86
87
88
89
90
91
# file      : tests/builtin/touch.testscript
# license   : MIT; see accompanying LICENSE file

test.arguments = "touch"

: file
:
$* a &a

: file-create
:
: Test that file is created. If it didn't then 'rm' would fail.
:
{
  $* a &!a;

  rm a
}

: file-update
:
: Test that existing file touch doesn't fail.
:
{
  cat <'' >=a;

  $* a
}

: callback
:
: Test that the callback is not called for touching an existing file.
:
{
  test.options += -c;

  $* a >>/~%EOO% &a;
    %create .+/a true%
    %create .+/a false%
    EOO

  $* >>/~%EOO% a
    %create .+/a true%
    %create .+/a false%
    EOO
}

: unknown-option
:
$* -u 2>"touch: unknown option '-u'" == 1

: no-args
:
: Test passing no arguments.
:
$* 2>"touch: missing file" != 0

: empty-path
:
: Test touching an empty path.
:
$* '' 2>"touch: invalid path ''" != 0

: dir-update
:
: Test touching an existing directory.
:
{
  mkdir a;

  $* a 2>~'%touch: cannot create/update .+: .+%' != 0
}

: after
:
{
  : success
  :
  {
    $* a &a;
    $* --after a b &b
  }

  : no-value
  :
  $* --after 2>"touch: missing value for option '--after'" != 0

  : not-exists
  :
  touch --after a b 2>~"%touch: cannot obtain file '.+a' modification time: .+%" != 0
}