aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/lit/tests/Inputs/shtest-if-else/test.txt
blob: b5fc1b49fcc52ee32bb17ac3e2817c3d546cf0b8 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# CHECK: -- Testing:{{.*}}
# CHECK-NEXT: PASS: shtest-if-else :: test.txt (1 of 1)
#      CHECK: Command Output (stdout):
# CHECK-NEXT: --

# RUN: %if feature %{ echo "test-1" %}
#      CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo "test-1"

# If %else is not present it is treated like %else %{%}. Empty commands
# are ignored.
#
# RUN: %if nofeature %{ echo "fail" %}
#     CHECK: # {{RUN}}: at line [[#@LINE-1]] has no command after substitutions
# CHECK-NOT: fail

# RUN: %if nofeature %{ echo "fail" %} %else %{ echo "test-2" %}
#      CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo "test-2"

# Spaces inside curly braces are not ignored
#
# RUN: echo test-%if feature %{ 3 %} %else %{ fail %}-test
# RUN: echo test-%if feature %{ 4 4 %} %else %{ fail %}-test
# RUN: echo test-%if nofeature %{ fail %} %else %{ 5 5 %}-test
#      CHECK: # {{RUN}}: at line [[#@LINE-3]]
# CHECK-NEXT: echo test- 3 -test
#      CHECK: # {{RUN}}: at line [[#@LINE-4]]
# CHECK-NEXT: echo test- 4 4 -test
#      CHECK: # {{RUN}}: at line [[#@LINE-5]]
# CHECK-NEXT: echo test- 5 5 -test

# Escape line breaks for multi-line expressions
#
# RUN: %if feature  \
# RUN:   %{ echo     \
# RUN:     "test-5" \
# RUN:   %}
#      CHECK: # {{RUN}}: at line [[#@LINE-4]]
# CHECK-NEXT: echo "test-5"

# RUN: %if nofeature       \
# RUN:   %{ echo "fail" %}   \
# RUN: %else               \
# RUN:   %{ echo "test-6" %}
#      CHECK: # {{RUN}}: at line [[#@LINE-4]]
# CHECK-NEXT: echo "test-6"

# RUN: echo "test%if feature %{%} %else %{%}-7"
#      CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo "test-7"

# Escape %if. Without %if..%else context '%{' and '%}' are treated
# literally.
#
# RUN: echo %%if feature %{ echo "test-8" %}
#      CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo %if feature %{ echo "test-8" %}

# Nested expressions are supported:
#
# RUN: echo %if feature %{ %if feature %{ %if nofeature %{"fail"%} %else %{"test-9"%} %} %}
#      CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo "test-9"

# Binary expression evaluation and regex match can be used as
# conditions.
#
# RUN: echo %if feature && !nofeature %{ "test-10" %}
# RUN: echo %if feature && nofeature %{ "fail" %} %else %{ "test-11" %}
# RUN: echo %if {{fea.+}} %{ "test-12" %} %else %{ "fail" %}
#      CHECK: # {{RUN}}: at line [[#@LINE-3]]
# CHECK-NEXT: echo "test-10"
#      CHECK: # {{RUN}}: at line [[#@LINE-4]]
# CHECK-NEXT: echo "test-11"
#      CHECK: # {{RUN}}: at line [[#@LINE-5]]
# CHECK-NEXT: echo "test-12"

# Spaces between %if and %else are ignored. If there is no %else -
# space after %if %{...%} is not ignored.
#
# RUN: echo XX %if feature %{YY%} ZZ
# RUN: echo AA %if feature %{BB%} %else %{CC%} DD
# RUN: echo AA %if nofeature %{BB%} %else %{CC%} DD
#      CHECK: # {{RUN}}: at line [[#@LINE-3]]
# CHECK-NEXT: echo XX YY ZZ
#      CHECK: # {{RUN}}: at line [[#@LINE-4]]
# CHECK-NEXT: echo AA BB DD
#      CHECK: # {{RUN}}: at line [[#@LINE-5]]
# CHECK-NEXT: echo AA CC DD

# '{' and '}' can be used without escaping
#
# RUN: %if feature %{echo {}%}
#      CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo {}

# Spaces are not required
#
# RUN: echo %if feature%{"ok"%}%else%{"fail"%}
#      CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo "ok"

# Substitutions with braces are handled correctly
#
# RUN: echo %{sub} %if feature%{test-%{sub}%}%else%{"fail"%}
#      CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo ok test-ok