fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

NahorFix failing system tests on Cygwin440e7fcbc

master
3.7 KiB155 linesraw
1# RUN: %fish --features test-require-arg %s
2#
3# Tests for the `test` builtin, aka `[`.
4test inf -gt 0
5# CHECKERR: Number is infinite
6# CHECKERR: {{.*}}test.fish (line {{\d+}}):
7# CHECKERR: test inf -gt 0
8# CHECKERR: ^
9
10test 5 -eq nan
11# CHECKERR: Not a number
12# CHECKERR: {{.*}}test.fish (line {{\d+}}):
13# CHECKERR: test 5 -eq nan
14# CHECKERR: ^
15
16test -z nan || echo nan is fine
17# CHECK: nan is fine
18
19test 1 =
20# CHECKERR: test: Missing argument at index 3
21# CHECKERR: 1 =
22# CHECKERR: ^
23# CHECKERR: {{.*}}test.fish (line {{\d+}}):
24# CHECKERR: test 1 =
25# CHECKERR: ^
26
27test 1 = 2 and echo true or echo false
28# CHECKERR: test: Expected a combining operator like '-a' at index 4
29# CHECKERR: 1 = 2 and echo true or echo false
30# CHECKERR: ^
31# CHECKERR: {{.*}}test.fish (line {{\d+}}):
32# CHECKERR: test 1 = 2 and echo true or echo false
33# CHECKERR: ^
34
35function t
36    test $argv[1] -eq 5
37end
38
39t foo
40# CHECKERR: Argument is not a number: 'foo'
41# CHECKERR: {{.*}}test.fish (line {{\d+}}):
42# CHECKERR: test $argv[1] -eq 5
43# CHECKERR: ^
44# CHECKERR: in function 't' with arguments 'foo'
45# CHECKERR: called on line {{\d+}} of file {{.*}}test.fish
46
47t 5,2
48# CHECKERR: Integer 5 in '5,2' followed by non-digit
49# CHECKERR: {{.*}}test.fish (line {{\d+}}):
50# CHECKERR: test $argv[1] -eq 5
51# CHECKERR: ^
52# CHECKERR: in function 't' with arguments '5,2'
53# CHECKERR: called on line {{\d+}} of file {{.*}}test.fish
54
55test -x /usr/bin/go /usr/local/bin/go
56# CHECKERR: test: unexpected argument at index 3: '/usr/local/bin/go'
57# CHECKERR: -x /usr/bin/go /usr/local/bin/go
58# CHECKERR: {{               \^}}
59# CHECKERR: {{.*}}test.fish (line {{\d+}}):
60# CHECKERR: test -x /usr/bin/go /usr/local/bin/go
61# CHECKERR: ^
62
63# Test `test` date comparison logic for dates older than epoch
64touch -m -t 197001010000 epoch
65touch -m -t 190212112045 old
66touch -m -t 203801080314 newest
67
68# Some filesystem do not support dates older than epoch, so silently skip this test - there's no
69# guarantee that an FS supports pre-epoch timestamps and lxfs (virtual WSLv1 fs) doesn't.
70if not path mtime epoch | string match -qr -- '^[^-]'
71    test newest -nt old || echo bad nt
72    test epoch -nt newest && echo bad nt
73end
74
75for file in epoch old newest
76    test $file -nt nonexist && echo good nt || echo $file: bad nt
77end
78#CHECK: good nt
79#CHECK: good nt
80#CHECK: good nt
81
82for file in epoch old newest
83    test nonexist -ot $file && echo good ot || echo $file: bad ot
84end
85#CHECK: good ot
86#CHECK: good ot
87#CHECK: good ot
88
89if cygwin_nosymlinks
90    echo good ef
91else
92    ln -sf epoch epochlink
93    test epoch -ef epochlink && echo good ef || echo bad ef
94end
95#CHECK: good ef
96
97test epoch -ef old && echo bad ef || echo good ef
98#CHECK: good ef
99
100rm -f epoch old newest epochlink
101
102test -n
103echo -- -n $status
104#CHECK: -n 1
105test -z
106echo -- -z $status
107#CHECK: -z 0
108
109test -d
110#CHECKERR: test: Missing argument at index 2
111#CHECKERR: -d
112#CHECKERR: ^
113#CHECKERR: {{.*}}test.fish (line {{\d+}}):
114#CHECKERR: test -d
115#CHECKERR: ^
116
117test foo
118#CHECKERR: test: Missing argument at index 2
119#CHECKERR: foo
120#CHECKERR: ^
121#CHECKERR: {{.*}}test.fish (line {{\d+}}):
122#CHECKERR: test foo
123#CHECKERR: ^
124
125test ""
126#CHECKERR: test: Missing argument at index 2
127#CHECKERR: ^
128#CHECKERR: {{.*}}test.fish (line {{\d+}}):
129#CHECKERR: test ""
130#CHECKERR: ^
131
132test -z "" -a foo
133#CHECKERR: test: Missing argument at index 5
134#CHECKERR: -z  -a foo
135#CHECKERR: ^
136#CHECKERR: {{.*}}test.fish (line {{\d+}}):
137#CHECKERR: test -z "" -a foo
138#CHECKERR: ^
139
140echo $status
141#CHECK: 1
142
143test
144#CHECKERR: test: Expected at least one argument
145#CHECKERR: {{.*}}test.fish (line {{\d+}}):
146#CHECKERR: test
147#CHECKERR: ^
148#CHECKERR: (Type 'help test' for related documentation)
149
150[ -z
151#CHECKERR: [: the last argument must be ']'
152#CHECKERR: {{.*}}test.fish (line {{\d+}}):
153#CHECKERR: [ -z
154#CHECKERR: ^
155#CHECKERR: (Type 'help [' for related documentation)