travis-conditions 0.0.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +65 -0
  3. data/Gemfile.lock +1 -1
  4. data/NOTES.md +107 -0
  5. data/README.md +261 -13
  6. data/bin/travis-conditions +34 -0
  7. data/lib/travis/conditions.rb +10 -16
  8. data/lib/travis/conditions/v0.rb +30 -0
  9. data/lib/travis/conditions/v0/data.rb +57 -0
  10. data/lib/travis/conditions/v0/eval.rb +70 -0
  11. data/lib/travis/conditions/v0/parser.rb +204 -0
  12. data/lib/travis/conditions/v1.rb +19 -0
  13. data/lib/travis/conditions/v1/boolean.rb +71 -0
  14. data/lib/travis/conditions/v1/data.rb +75 -0
  15. data/lib/travis/conditions/v1/eval.rb +114 -0
  16. data/lib/travis/conditions/v1/helper.rb +30 -0
  17. data/lib/travis/conditions/v1/parser.rb +214 -0
  18. data/lib/travis/conditions/version.rb +1 -1
  19. data/spec/conditions_spec.rb +15 -0
  20. data/spec/v0/conditions_spec.rb +15 -0
  21. data/spec/{data_spec.rb → v0/data_spec.rb} +6 -1
  22. data/spec/{eval_spec.rb → v0/eval_spec.rb} +1 -1
  23. data/spec/v0/fixtures/failures.txt +342 -0
  24. data/spec/v0/fixtures/passes.txt +1685 -0
  25. data/spec/{parser_spec.rb → v0/parser_spec.rb} +1 -1
  26. data/spec/v1/conditions_spec.rb +44 -0
  27. data/spec/v1/data_spec.rb +30 -0
  28. data/spec/v1/eval_spec.rb +349 -0
  29. data/spec/v1/fixtures/failures.txt +336 -0
  30. data/spec/v1/fixtures/passes.txt +1634 -0
  31. data/spec/v1/parser/boolean_spec.rb +215 -0
  32. data/spec/v1/parser/call_spec.rb +68 -0
  33. data/spec/v1/parser/comma_spec.rb +28 -0
  34. data/spec/v1/parser/cont_spec.rb +41 -0
  35. data/spec/v1/parser/eq_spec.rb +16 -0
  36. data/spec/v1/parser/in_list_spec.rb +60 -0
  37. data/spec/v1/parser/is_pred_spec.rb +24 -0
  38. data/spec/v1/parser/list_spec.rb +36 -0
  39. data/spec/v1/parser/operand_spec.rb +16 -0
  40. data/spec/v1/parser/parens_spec.rb +28 -0
  41. data/spec/v1/parser/quoted_spec.rb +24 -0
  42. data/spec/v1/parser/re_spec.rb +16 -0
  43. data/spec/v1/parser/regex_spec.rb +12 -0
  44. data/spec/v1/parser/space_spec.rb +40 -0
  45. data/spec/v1/parser/term_spec.rb +84 -0
  46. data/spec/v1/parser/val_spec.rb +24 -0
  47. data/spec/v1/parser/var_spec.rb +16 -0
  48. data/spec/v1/parser_spec.rb +486 -0
  49. data/spec/v1/user_spec.rb +223 -0
  50. metadata +48 -9
  51. data/lib/travis/conditions/data.rb +0 -45
  52. data/lib/travis/conditions/eval.rb +0 -68
  53. data/lib/travis/conditions/parser.rb +0 -202
@@ -0,0 +1,36 @@
1
+ describe Travis::Conditions::V1::Parser, 'list' do
2
+ let(:str) { |e| e.description }
3
+ let(:subject) { described_class.new(str).list }
4
+
5
+ it 'foo,bar' do
6
+ should eq [[:val, 'foo'], [:val, 'bar']]
7
+ end
8
+
9
+ it 'foo, bar' do
10
+ should eq [[:val, 'foo'], [:val, 'bar']]
11
+ end
12
+
13
+ it 'foo ,bar' do
14
+ should eq [[:val, 'foo'], [:val, 'bar']]
15
+ end
16
+
17
+ it 'foo , bar' do
18
+ should eq [[:val, 'foo'], [:val, 'bar']]
19
+ end
20
+
21
+ it 'foo, bar, ' do
22
+ should eq [[:val, 'foo'], [:val, 'bar']]
23
+ end
24
+
25
+ it 'foo' do
26
+ should eq [[:val, 'foo']]
27
+ end
28
+
29
+ it 'type' do
30
+ should eq [[:var, :type]]
31
+ end
32
+
33
+ it 'env(foo)' do
34
+ should eq [[:call, :env, [[:val, 'foo']]]]
35
+ end
36
+ end
@@ -0,0 +1,16 @@
1
+ describe Travis::Conditions::V1::Parser, 'operand' do
2
+ let(:str) { |e| e.description }
3
+ let(:subject) { described_class.new(str).operand }
4
+
5
+ it 'type' do
6
+ should eq [:var, :type]
7
+ end
8
+
9
+ it 'foo' do
10
+ should eq [:val, 'foo']
11
+ end
12
+
13
+ it 'env(foo)' do
14
+ should eq [:call, :env, [[:val, 'foo']]]
15
+ end
16
+ end
@@ -0,0 +1,28 @@
1
+ describe Travis::Conditions::V1::Parser, 'parens' do
2
+ let(:str) { |e| e.description }
3
+
4
+ let(:subject) do
5
+ parser = described_class.new(str)
6
+ parser.parens { parser.word }
7
+ end
8
+
9
+ it '(foo)' do
10
+ should eq 'foo'
11
+ end
12
+
13
+ it '( foo)' do
14
+ should eq 'foo'
15
+ end
16
+
17
+ it '(foo )' do
18
+ should eq 'foo'
19
+ end
20
+
21
+ it '( foo )' do
22
+ should eq 'foo'
23
+ end
24
+
25
+ it 'foo' do
26
+ should eq nil
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ describe Travis::Conditions::V1::Parser, 'quoted' do
2
+ let(:str) { |e| e.description }
3
+ let(:subject) { described_class.new(str).quoted }
4
+
5
+ it "'foo'" do
6
+ should eq 'foo'
7
+ end
8
+
9
+ it '"foo"' do
10
+ should eq 'foo'
11
+ end
12
+
13
+ it "'\"foo\"'" do
14
+ should eq '"foo"'
15
+ end
16
+
17
+ it '"\'foo\'"' do
18
+ should eq "'foo'"
19
+ end
20
+
21
+ it '"&.foo bar!?"' do
22
+ should eq '&.foo bar!?'
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ describe Travis::Conditions::V1::Parser, 'operand' do
2
+ let(:str) { |e| e.description }
3
+ let(:subject) { described_class.new(str).operand }
4
+
5
+ it 'type' do
6
+ should eq [:var, :type]
7
+ end
8
+
9
+ it 'foo' do
10
+ should eq [:val, 'foo']
11
+ end
12
+
13
+ it 'env(foo)' do
14
+ should eq [:call, :env, [[:val, 'foo']]]
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ describe Travis::Conditions::V1::Parser, 'regex' do
2
+ let(:str) { |e| e.description }
3
+ let(:subject) { described_class.new(str).regex }
4
+
5
+ it '^.*-bar$' do
6
+ should eq [:reg, '^.*-bar$']
7
+ end
8
+
9
+ it '/^.* bar$/' do
10
+ should eq [:reg, '^.* bar$']
11
+ end
12
+ end
@@ -0,0 +1,40 @@
1
+ describe Travis::Conditions::V1::Parser, 'space' do
2
+ let(:str) { |e| e.description }
3
+
4
+ let(:subject) do
5
+ parser = described_class.new(str)
6
+ parser.space { parser.word }
7
+ end
8
+
9
+ it 'foo' do
10
+ should eq 'foo'
11
+ end
12
+
13
+ it ' foo' do
14
+ should eq 'foo'
15
+ end
16
+
17
+ it 'foo ' do
18
+ should eq 'foo'
19
+ end
20
+
21
+ it ' foo ' do
22
+ should eq 'foo'
23
+ end
24
+
25
+ it "foo\t" do
26
+ should eq 'foo'
27
+ end
28
+
29
+ it "\tfoo" do
30
+ should eq 'foo'
31
+ end
32
+
33
+ it "foo\n" do
34
+ should eq 'foo'
35
+ end
36
+
37
+ it "\nfoo" do
38
+ should eq 'foo'
39
+ end
40
+ end
@@ -0,0 +1,84 @@
1
+ describe Travis::Conditions::V1::Parser, 'term' do
2
+ let(:str) { |e| e.description }
3
+ let(:subject) { described_class.new(str).term }
4
+
5
+ it 'type = "foo"' do
6
+ should eq [:eq, [:var, :type], [:val, 'foo']]
7
+ end
8
+
9
+ it '"foo" = type' do
10
+ should eq [:eq, [:val, 'foo'], [:var, :type]]
11
+ end
12
+
13
+ it 'type = env(foo)' do
14
+ should eq [:eq, [:var, :type], [:call, :env, [[:val, 'foo']]]]
15
+ end
16
+
17
+ it 'env(foo) = type' do
18
+ should eq [:eq, [:call, :env, [[:val, 'foo']]], [:var, :type]]
19
+ end
20
+
21
+ it '"foo" = env(foo)' do
22
+ should eq [:eq, [:val, 'foo'], [:call, :env, [[:val, 'foo']]]]
23
+ end
24
+
25
+ it 'env(foo) = "foo"' do
26
+ should eq [:eq, [:call, :env, [[:val, 'foo']]], [:val, 'foo']]
27
+ end
28
+
29
+ it 'type = type' do
30
+ should eq [:eq, [:var, :type], [:var, :type]]
31
+ end
32
+
33
+ it '"foo" = "foo"' do
34
+ should eq [:eq, [:val, 'foo'], [:val, 'foo']]
35
+ end
36
+
37
+ it 'env(foo) = env(bar)' do
38
+ should eq [:eq, [:call, :env, [[:val, 'foo']]], [:call, :env, [[:val, 'bar']]]]
39
+ end
40
+
41
+ it 'tag =~ foo' do
42
+ should eq [:match, [:var, :tag], [:reg, 'foo']]
43
+ end
44
+
45
+ it 'tag =~ /foo/' do
46
+ should eq [:match, [:var, :tag], [:reg, 'foo']]
47
+ end
48
+
49
+ it 'tag =~ env(foo)' do
50
+ should eq [:match, [:var, :tag], [:reg, [:call, :env, [[:val, 'foo']]]]]
51
+ end
52
+
53
+ it 'tag =~ concat(^foo-, env(foo))' do
54
+ should eq [:match, [:var, :tag], [:reg, [:call, :concat, [[:val, "^foo-"], [:call, :env, [[:val, 'foo']]]]]]]
55
+ end
56
+
57
+ it 'type IN (foo)' do
58
+ should eq [:in, [:var, :type], [[:val, 'foo']]]
59
+ end
60
+
61
+ it '"foo" IN (foo)' do
62
+ should eq [:in, [:val, 'foo'], [[:val, 'foo']]]
63
+ end
64
+
65
+ it 'env(foo) IN (foo)' do
66
+ should eq [:in, [:call, :env, [[:val, 'foo']]], [[:val, 'foo']]]
67
+ end
68
+
69
+ it 'type IS present' do
70
+ should eq [:is, [:var, :type], :present]
71
+ end
72
+
73
+ it '"foo" IS present' do
74
+ should eq [:is, [:val, 'foo'], :present]
75
+ end
76
+
77
+ it 'env(foo) IS present' do
78
+ should eq [:is, [:call, :env, [[:val, 'foo']]], :present]
79
+ end
80
+
81
+ it 'sender = sender-foo' do
82
+ should eq [:eq, [:var, :sender], [:val, 'sender-foo']]
83
+ end
84
+ end
@@ -0,0 +1,24 @@
1
+ describe Travis::Conditions::V1::Parser, 'val' do
2
+ let(:str) { |e| e.description }
3
+ let(:subject) { described_class.new(str).val }
4
+
5
+ it 'foo' do
6
+ should eq [:val, 'foo']
7
+ end
8
+
9
+ it '"foo"' do
10
+ should eq [:val, 'foo']
11
+ end
12
+
13
+ it "'foo'" do
14
+ should eq [:val, 'foo']
15
+ end
16
+
17
+ it 'typescript' do
18
+ should eq [:val, 'typescript']
19
+ end
20
+
21
+ it 'sender-foo' do
22
+ should eq [:val, 'sender-foo']
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ describe Travis::Conditions::V1::Parser, 'var' do
2
+ let(:str) { |e| e.description }
3
+ let(:subject) { described_class.new(str).var }
4
+
5
+ it 'type' do
6
+ should eq [:var, :type]
7
+ end
8
+
9
+ it 'repo' do
10
+ should eq [:var, :repo]
11
+ end
12
+
13
+ it 'nope' do
14
+ should be_nil
15
+ end
16
+ end
@@ -0,0 +1,486 @@
1
+ describe Travis::Conditions::V1::Parser do
2
+ let(:str) { |e| e.description }
3
+ let(:subject) { described_class.new(str).parse }
4
+
5
+ # single term
6
+
7
+ it '1' do
8
+ should eq \
9
+ [:val, '1']
10
+ end
11
+
12
+ it 'true' do
13
+ should eq \
14
+ [:val, 'true']
15
+ end
16
+
17
+ it 'type' do
18
+ should eq \
19
+ [:var, :type]
20
+ end
21
+
22
+ it 'env(FOO)' do
23
+ should eq \
24
+ [:call, :env, [[:val, 'FOO']]]
25
+ end
26
+
27
+ # one operand
28
+
29
+ it '1=1' do
30
+ should eq \
31
+ [:eq, [:val, '1'], [:val, '1']]
32
+ end
33
+
34
+ it 'true=true' do
35
+ should eq \
36
+ [:eq, [:val, 'true'], [:val, 'true']]
37
+ end
38
+
39
+ it 'true!=false' do
40
+ should eq \
41
+ [:not_eq, [:val, 'true'], [:val, 'false']]
42
+ end
43
+
44
+ it '1 = 1' do
45
+ should eq \
46
+ [:eq, [:val, '1'], [:val, '1']]
47
+ end
48
+
49
+ it 'true = true' do
50
+ should eq \
51
+ [:eq, [:val, 'true'], [:val, 'true']]
52
+ end
53
+
54
+ it 'type = foo' do
55
+ should eq \
56
+ [:eq, [:var, :type], [:val, 'foo']]
57
+ end
58
+
59
+ it '(type = foo)' do
60
+ should eq \
61
+ [:eq, [:var, :type], [:val, 'foo']]
62
+ end
63
+
64
+ # two operands
65
+
66
+ it 'type = foo OR type = bar' do
67
+ should eq \
68
+ [:or,
69
+ [:eq, [:var, :type], [:val, 'foo']],
70
+ [:eq, [:var, :type], [:val, 'bar']]]
71
+ end
72
+
73
+ it '(type = foo OR type = bar)' do
74
+ should eq \
75
+ [:or,
76
+ [:eq, [:var, :type], [:val, 'foo']],
77
+ [:eq, [:var, :type], [:val, 'bar']]]
78
+ end
79
+
80
+ # three operands
81
+
82
+ it 'type = foo OR type = bar OR type = baz' do
83
+ should eq \
84
+ [:or,
85
+ [:or,
86
+ [:eq, [:var, :type], [:val, 'foo']],
87
+ [:eq, [:var, :type], [:val, 'bar']]],
88
+ [:eq, [:var, :type], [:val, 'baz']]]
89
+ end
90
+
91
+ it 'type = foo AND type = bar OR type = baz' do
92
+ should eq \
93
+ [:or,
94
+ [:and,
95
+ [:eq, [:var, :type], [:val, 'foo']],
96
+ [:eq, [:var, :type], [:val, 'bar']]],
97
+ [:eq, [:var, :type], [:val, 'baz']]]
98
+ end
99
+
100
+ it 'type = foo OR type = bar AND type = baz' do
101
+ should eq \
102
+ [:or,
103
+ [:eq, [:var, :type], [:val, 'foo']],
104
+ [:and,
105
+ [:eq, [:var, :type], [:val, 'bar']],
106
+ [:eq, [:var, :type], [:val, 'baz']]]]
107
+ end
108
+
109
+ it 'type = foo AND type = bar AND type = baz' do
110
+ should eq \
111
+ [:and,
112
+ [:and,
113
+ [:eq, [:var, :type], [:val, 'foo']],
114
+ [:eq, [:var, :type], [:val, 'bar']]],
115
+ [:eq, [:var, :type], [:val, 'baz']]]
116
+ end
117
+
118
+ it '(type = foo OR type = bar OR type = baz)' do
119
+ should eq \
120
+ [:or,
121
+ [:or,
122
+ [:eq, [:var, :type], [:val, 'foo']],
123
+ [:eq, [:var, :type], [:val, 'bar']]],
124
+ [:eq, [:var, :type], [:val, 'baz']]]
125
+ end
126
+
127
+ it '(type = foo OR type = bar) AND type = baz' do
128
+ should eq \
129
+ [:and,
130
+ [:or,
131
+ [:eq, [:var, :type], [:val, 'foo']],
132
+ [:eq, [:var, :type], [:val, 'bar']]],
133
+ [:eq, [:var, :type], [:val, 'baz']]]
134
+ end
135
+
136
+ it 'type = foo AND (type = bar OR type = baz)' do
137
+ should eq \
138
+ [:and,
139
+ [:eq, [:var, :type], [:val, 'foo']],
140
+ [:or,
141
+ [:eq, [:var, :type], [:val, 'bar']],
142
+ [:eq, [:var, :type], [:val, 'baz']]]]
143
+ end
144
+
145
+ # four operands
146
+
147
+ it '(type = foo OR type = bar) AND (type = baz OR type = buz)' do
148
+ should eq \
149
+ [:and,
150
+ [:or,
151
+ [:eq, [:var, :type], [:val, 'foo']],
152
+ [:eq, [:var, :type], [:val, 'bar']]],
153
+ [:or,
154
+ [:eq, [:var, :type], [:val, 'baz']],
155
+ [:eq, [:var, :type], [:val, 'buz']]]]
156
+ end
157
+
158
+ it 'type = foo AND (type = bar OR type = baz) AND type = buz' do
159
+ should eq \
160
+ [:and,
161
+ [:and,
162
+ [:eq, [:var, :type], [:val, 'foo']],
163
+ [:or,
164
+ [:eq, [:var, :type], [:val, 'bar']],
165
+ [:eq, [:var, :type], [:val, 'baz']]]],
166
+ [:eq, [:var, :type], [:val, 'buz']]]
167
+ end
168
+
169
+ it 'type = foo AND (type = bar OR type = baz OR type = buz)' do
170
+ should eq \
171
+ [:and,
172
+ [:eq, [:var, :type], [:val, 'foo']],
173
+ [:or,
174
+ [:or,
175
+ [:eq, [:var, :type], [:val, 'bar']],
176
+ [:eq, [:var, :type], [:val, 'baz']]],
177
+ [:eq, [:var, :type], [:val, 'buz']]]]
178
+ end
179
+
180
+ it '(type = foo AND (type = bar OR type = baz)) OR type = buz' do
181
+ should eq \
182
+ [:or,
183
+ [:and,
184
+ [:eq, [:var, :type], [:val, 'foo']],
185
+ [:or,
186
+ [:eq, [:var, :type], [:val, 'bar']],
187
+ [:eq, [:var, :type], [:val, 'baz']]]],
188
+ [:eq, [:var, :type], [:val, 'buz']]]
189
+ end
190
+
191
+ # one operand negated
192
+
193
+ it 'NOT type = foo' do
194
+ should eq \
195
+ [:not, [:eq, [:var, :type], [:val, 'foo']]]
196
+ end
197
+
198
+ # two operands negated
199
+
200
+ it 'NOT type = foo OR type = bar' do
201
+ should eq \
202
+ [:or,
203
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
204
+ [:eq, [:var, :type], [:val, 'bar']]]
205
+ end
206
+
207
+ it 'type = foo OR NOT type = bar' do
208
+ should eq \
209
+ [:or,
210
+ [:eq, [:var, :type], [:val, 'foo']],
211
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]]
212
+ end
213
+
214
+ it 'NOT type = foo OR NOT type = bar' do
215
+ should eq \
216
+ [:or,
217
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
218
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]]
219
+ end
220
+
221
+ it 'NOT (type = foo OR type = bar)' do
222
+ should eq \
223
+ [:not,
224
+ [:or, [:eq, [:var, :type], [:val, 'foo']],
225
+ [:eq, [:var, :type], [:val, 'bar']]]]
226
+ end
227
+
228
+ # three operands negated
229
+
230
+ it 'NOT type = foo OR type = bar OR type = baz' do
231
+ should eq \
232
+ [:or,
233
+ [:or,
234
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
235
+ [:eq, [:var, :type], [:val, 'bar']]],
236
+ [:eq, [:var, :type], [:val, 'baz']]]
237
+ end
238
+
239
+ it '(NOT type = foo OR type = bar OR type = baz)' do
240
+ should eq \
241
+ [:or,
242
+ [:or,
243
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
244
+ [:eq, [:var, :type], [:val, 'bar']]],
245
+ [:eq, [:var, :type], [:val, 'baz']]]
246
+ end
247
+
248
+ it 'type = foo OR NOT type = bar OR type = baz' do
249
+ should eq \
250
+ [:or,
251
+ [:or,
252
+ [:eq, [:var, :type], [:val, 'foo']],
253
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]],
254
+ [:eq, [:var, :type], [:val, 'baz']]]
255
+ end
256
+
257
+ it '(type = foo OR NOT type = bar OR type = baz)' do
258
+ should eq \
259
+ [:or,
260
+ [:or,
261
+ [:eq, [:var, :type], [:val, 'foo']],
262
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]],
263
+ [:eq, [:var, :type], [:val, 'baz']]]
264
+ end
265
+
266
+ it 'type = foo OR type = bar OR NOT type = baz' do
267
+ should eq \
268
+ [:or,
269
+ [:or,
270
+ [:eq, [:var, :type], [:val, 'foo']],
271
+ [:eq, [:var, :type], [:val, 'bar']]],
272
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
273
+ end
274
+
275
+ it '(type = foo OR type = bar OR NOT type = baz)' do
276
+ should eq \
277
+ [:or,
278
+ [:or,
279
+ [:eq, [:var, :type], [:val, 'foo']],
280
+ [:eq, [:var, :type], [:val, 'bar']]],
281
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
282
+ end
283
+
284
+ it 'NOT type = foo OR NOT type = bar OR type = baz' do
285
+ should eq \
286
+ [:or,
287
+ [:or,
288
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
289
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]],
290
+ [:eq, [:var, :type], [:val, 'baz']]]
291
+ end
292
+
293
+ it '(NOT type = foo OR NOT type = bar OR type = baz)' do
294
+ should eq \
295
+ [:or,
296
+ [:or,
297
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
298
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]],
299
+ [:eq, [:var, :type], [:val, 'baz']]]
300
+ end
301
+
302
+ it 'NOT type = foo OR type = bar OR NOT type = baz' do
303
+ should eq \
304
+ [:or,
305
+ [:or,
306
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
307
+ [:eq, [:var, :type], [:val, 'bar']]],
308
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
309
+ end
310
+
311
+ it '(NOT type = foo OR type = bar OR NOT type = baz)' do
312
+ should eq \
313
+ [:or,
314
+ [:or,
315
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
316
+ [:eq, [:var, :type], [:val, 'bar']]],
317
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
318
+ end
319
+
320
+ it 'type = foo OR NOT type = bar OR NOT type = baz' do
321
+ should eq \
322
+ [:or,
323
+ [:or,
324
+ [:eq, [:var, :type], [:val, 'foo']],
325
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]],
326
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
327
+ end
328
+
329
+ it '(type = foo OR NOT type = bar OR NOT type = baz)' do
330
+ should eq \
331
+ [:or,
332
+ [:or,
333
+ [:eq, [:var, :type], [:val, 'foo']],
334
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]],
335
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
336
+ end
337
+
338
+ it 'NOT type = foo OR NOT type = bar OR NOT type = baz' do
339
+ should eq \
340
+ [:or,
341
+ [:or,
342
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
343
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]],
344
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
345
+ end
346
+
347
+ it '(NOT type = foo OR NOT type = bar OR NOT type = baz)' do
348
+ should eq \
349
+ [:or,
350
+ [:or,
351
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
352
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]],
353
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
354
+ end
355
+
356
+ it 'NOT (type = foo OR type = bar OR type = baz)' do
357
+ should eq \
358
+ [:not,
359
+ [:or,
360
+ [:or,
361
+ [:eq, [:var, :type], [:val, 'foo']],
362
+ [:eq, [:var, :type], [:val, 'bar']]],
363
+ [:eq, [:var, :type], [:val, 'baz']]]]
364
+ end
365
+
366
+ it 'NOT (type = foo OR type = bar) AND type = baz' do
367
+ should eq \
368
+ [:and,
369
+ [:not,
370
+ [:or,
371
+ [:eq, [:var, :type], [:val, 'foo']],
372
+ [:eq, [:var, :type], [:val, 'bar']]]],
373
+ [:eq, [:var, :type], [:val, 'baz']]]
374
+ end
375
+
376
+ it '(type = foo OR type = bar) AND NOT type = baz' do
377
+ should eq \
378
+ [:and,
379
+ [:or,
380
+ [:eq, [:var, :type], [:val, 'foo']],
381
+ [:eq, [:var, :type], [:val, 'bar']]],
382
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
383
+ end
384
+
385
+ it 'NOT (type = foo OR type = bar) AND NOT type = baz' do
386
+ should eq \
387
+ [:and,
388
+ [:not,
389
+ [:or,
390
+ [:eq, [:var, :type], [:val, 'foo']],
391
+ [:eq, [:var, :type], [:val, 'bar']]]],
392
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
393
+ end
394
+
395
+ it '(NOT type = foo OR type = bar) AND NOT type = baz' do
396
+ should eq \
397
+ [:and,
398
+ [:or,
399
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
400
+ [:eq, [:var, :type], [:val, 'bar']]],
401
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
402
+ end
403
+
404
+ it '(type = foo OR NOT type = bar) AND NOT type = baz' do
405
+ should eq \
406
+ [:and,
407
+ [:or,
408
+ [:eq, [:var, :type], [:val, 'foo']],
409
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]],
410
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]
411
+ end
412
+
413
+ # four operands negated
414
+
415
+ it 'NOT (type = foo OR type = bar) AND NOT (type = baz OR type = buz)' do
416
+ should eq \
417
+ [:and,
418
+ [:not,
419
+ [:or,
420
+ [:eq, [:var, :type], [:val, 'foo']],
421
+ [:eq, [:var, :type], [:val, 'bar']]]],
422
+ [:not,
423
+ [:or,
424
+ [:eq, [:var, :type], [:val, 'baz']],
425
+ [:eq, [:var, :type], [:val, 'buz']]]]]
426
+ end
427
+
428
+ it '(NOT type = foo OR NOT type = bar) AND (NOT type = baz OR NOT type = buz)' do
429
+ should eq \
430
+ [:and,
431
+ [:or,
432
+ [:not, [:eq, [:var, :type], [:val, 'foo']]],
433
+ [:not, [:eq, [:var, :type], [:val, 'bar']]]],
434
+ [:or,
435
+ [:not, [:eq, [:var, :type], [:val, 'baz']]],
436
+ [:not, [:eq, [:var, :type], [:val, 'buz']]]]]
437
+ end
438
+
439
+ it 'NOT type = foo AND NOT (type = bar OR type = baz) AND NOT type = buz' do
440
+ should eq \
441
+ [:and,
442
+ [:and,
443
+ [:not,
444
+ [:eq, [:var, :type], [:val, 'foo']]],
445
+ [:not,
446
+ [:or,
447
+ [:eq, [:var, :type], [:val, 'bar']],
448
+ [:eq, [:var, :type], [:val, 'baz']]]]],
449
+ [:not, [:eq, [:var, :type], [:val, 'buz']]]]
450
+ end
451
+
452
+ it 'NOT type = foo AND (NOT type = bar OR NOT type = baz) AND NOT type = buz' do
453
+ should eq \
454
+ [:and,
455
+ [:and,
456
+ [:not,
457
+ [:eq, [:var, :type], [:val, 'foo']]],
458
+ [:or,
459
+ [:not, [:eq, [:var, :type], [:val, 'bar']]],
460
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]],
461
+ [:not, [:eq, [:var, :type], [:val, 'buz']]]]
462
+ end
463
+
464
+ it 'NOT (NOT type = foo AND NOT (NOT type = bar OR NOT type = baz)) OR NOT type = buz' do
465
+ should eq \
466
+ [:or,
467
+ [:not,
468
+ [:and,
469
+ [:not,
470
+ [:eq, [:var, :type], [:val, 'foo']]],
471
+ [:not,
472
+ [:or,
473
+ [:not, [:eq, [:var, :type], [:val, 'bar']]],
474
+ [:not, [:eq, [:var, :type], [:val, 'baz']]]]]]],
475
+ [:not,
476
+ [:eq, [:var, :type], [:val, 'buz']]]]
477
+ end
478
+
479
+ it 'branch = $FOO' do
480
+ expect { subject }.to raise_error(Travis::Conditions::ParseError)
481
+ end
482
+
483
+ it '$FOO = bar' do
484
+ expect { subject }.to raise_error(Travis::Conditions::ParseError)
485
+ end
486
+ end