fig 2.0.0.pre.alpha.4 → 2.0.0.pre.alpha.5
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.
- checksums.yaml +4 -4
- data/lib/fig/spec_utils.rb +312 -0
- data/lib/fig/version.rb +1 -1
- data/spec/application_configuration_spec.rb +73 -0
- data/spec/command/clean_spec.rb +62 -0
- data/spec/command/command_line_vs_package_spec.rb +32 -0
- data/spec/command/dump_package_definition_spec.rb +104 -0
- data/spec/command/environment_variables_spec.rb +62 -0
- data/spec/command/grammar_asset_spec.rb +391 -0
- data/spec/command/grammar_command_spec.rb +88 -0
- data/spec/command/grammar_environment_variable_spec.rb +384 -0
- data/spec/command/grammar_retrieve_spec.rb +74 -0
- data/spec/command/grammar_spec.rb +87 -0
- data/spec/command/grammar_spec_helper.rb +23 -0
- data/spec/command/include_file_spec.rb +73 -0
- data/spec/command/listing_spec.rb +1574 -0
- data/spec/command/miscellaneous_spec.rb +145 -0
- data/spec/command/publish_local_and_updates_spec.rb +32 -0
- data/spec/command/publishing_retrieval_spec.rb +423 -0
- data/spec/command/publishing_spec.rb +596 -0
- data/spec/command/running_commands_spec.rb +354 -0
- data/spec/command/suppress_includes_spec.rb +65 -0
- data/spec/command/suppress_warning_include_statement_missing_version_spec.rb +134 -0
- data/spec/command/update_lock_response_spec.rb +47 -0
- data/spec/command/usage_errors_spec.rb +481 -0
- data/spec/command_options_spec.rb +184 -0
- data/spec/command_spec.rb +49 -0
- data/spec/deparser/v1_spec.rb +64 -0
- data/spec/environment_variables_spec.rb +91 -0
- data/spec/figrc_spec.rb +144 -0
- data/spec/parser_spec.rb +398 -0
- data/spec/repository_spec.rb +117 -0
- data/spec/runtime_environment_spec.rb +357 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/split_repo_url_spec.rb +190 -0
- data/spec/statement/asset_spec.rb +203 -0
- data/spec/statement/configuration_spec.rb +41 -0
- data/spec/support/formatters/seed_spitter.rb +12 -0
- data/spec/working_directory_maintainer_spec.rb +102 -0
- metadata +42 -5
@@ -0,0 +1,384 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/grammar_spec_helper')
|
3
|
+
|
4
|
+
describe 'Fig' do
|
5
|
+
ILLEGAL_CHARACTERS_IN_V0_PATH_STATEMENTS = %w< ; : < > | >
|
6
|
+
|
7
|
+
describe %q<uses the correct grammar version in the package definition created for publishing> do
|
8
|
+
before(:each) do
|
9
|
+
clean_up_test_environment
|
10
|
+
set_up_test_environment
|
11
|
+
end
|
12
|
+
|
13
|
+
ENVIRONMENT_VARIABLE_PUBLISHED_QUOTING_EXAMPLES = {
|
14
|
+
[%q<VARIABLE='foo\'bar'>, 1] => [
|
15
|
+
%q<VARIABLE=foo\'bar>,
|
16
|
+
%q<VARIABLE="foo'bar">,
|
17
|
+
%q<VARIABLE='foo\'bar'>
|
18
|
+
],
|
19
|
+
[%q<VARIABLE='foobar\''>, 1] => [
|
20
|
+
%q<VARIABLE=foobar\'>,
|
21
|
+
%q<VARIABLE="foobar'">,
|
22
|
+
%q<VARIABLE='foobar\''>
|
23
|
+
],
|
24
|
+
[%q<VARIABLE='foobar"'>, 1] => [
|
25
|
+
%q<VARIABLE=foobar\">,
|
26
|
+
%q<VARIABLE="foobar\"">,
|
27
|
+
%q<VARIABLE='foobar"'>
|
28
|
+
],
|
29
|
+
[%q<VARIABLE='foo"bar'>, 1] => [
|
30
|
+
%q<VARIABLE=foo\"bar>,
|
31
|
+
%q<VARIABLE="foo\"bar">,
|
32
|
+
%q<VARIABLE='foo"bar'>
|
33
|
+
],
|
34
|
+
[%q<VARIABLE='foo#bar'>, 1] => [
|
35
|
+
%q<VARIABLE="foo#bar">,
|
36
|
+
%q<VARIABLE='foo#bar'>
|
37
|
+
],
|
38
|
+
[%q<VARIABLE=foo@bar>, 0] => [
|
39
|
+
%q<VARIABLE=foo@bar>,
|
40
|
+
%q<VARIABLE="foo@bar">,
|
41
|
+
],
|
42
|
+
[%q<VARIABLE=foo\@bar>, 0] => [
|
43
|
+
%q<VARIABLE=foo\@bar>,
|
44
|
+
%q<VARIABLE="foo\@bar">,
|
45
|
+
%q<VARIABLE='foo@bar'>
|
46
|
+
],
|
47
|
+
[%q<VARIABLE=foo\\\\bar>, 0] => [
|
48
|
+
%q<VARIABLE=foo\\\\bar>,
|
49
|
+
%q<VARIABLE="foo\\\\bar">,
|
50
|
+
%q<VARIABLE='foo\\\\bar'>
|
51
|
+
]
|
52
|
+
}
|
53
|
+
|
54
|
+
shared_examples_for 'environment variable option' do
|
55
|
+
|assignment_type|
|
56
|
+
|
57
|
+
it 'with simple value' do
|
58
|
+
fig(
|
59
|
+
[%w<--publish foo/1.2.3>, "--#{assignment_type}", 'VARIABLE=VALUE'],
|
60
|
+
:fork => false
|
61
|
+
)
|
62
|
+
|
63
|
+
out, * = check_published_grammar_version(0)
|
64
|
+
|
65
|
+
out.should =~ / \b #{assignment_type} \s+ VARIABLE=VALUE \b /x
|
66
|
+
end
|
67
|
+
|
68
|
+
{
|
69
|
+
'unquoted' => %q<>,
|
70
|
+
'double quoted' => %q<">,
|
71
|
+
'single quoted' => %q<'>
|
72
|
+
}.each do
|
73
|
+
|name, quote|
|
74
|
+
|
75
|
+
it "with #{name} whitespace" do
|
76
|
+
fig(
|
77
|
+
[
|
78
|
+
%w<--publish foo/1.2.3>,
|
79
|
+
"--#{assignment_type}",
|
80
|
+
"VARIABLE=#{quote}foo bar#{quote}"
|
81
|
+
],
|
82
|
+
:fork => false
|
83
|
+
)
|
84
|
+
|
85
|
+
out, * = check_published_grammar_version(1)
|
86
|
+
|
87
|
+
out.should =~ / \b #{assignment_type} \s+ VARIABLE='foo[ ]bar' /x
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
ENVIRONMENT_VARIABLE_PUBLISHED_QUOTING_EXAMPLES.each do
|
92
|
+
|expected, inputs|
|
93
|
+
|
94
|
+
result, version = *expected
|
95
|
+
|
96
|
+
inputs.each do
|
97
|
+
|value|
|
98
|
+
|
99
|
+
it "with «#{value}»" do
|
100
|
+
fig(
|
101
|
+
[ %w<--publish foo/1.2.3>, "--#{assignment_type}", value ],
|
102
|
+
:fork => false
|
103
|
+
)
|
104
|
+
|
105
|
+
out, * = check_published_grammar_version(version)
|
106
|
+
|
107
|
+
out.should =~ / \b #{assignment_type} \s+ #{Regexp.quote result} /x
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
it "with «VARIABLE=foo#bar»" do
|
113
|
+
fig(
|
114
|
+
[
|
115
|
+
%w<--publish foo/1.2.3>,
|
116
|
+
"--#{assignment_type}",
|
117
|
+
%q<VARIABLE=foo#bar>
|
118
|
+
],
|
119
|
+
:fork => false
|
120
|
+
)
|
121
|
+
|
122
|
+
out, * = check_published_grammar_version(1)
|
123
|
+
|
124
|
+
out.should =~ / \b #{assignment_type} \s+ VARIABLE='foo[#]bar' /x
|
125
|
+
end
|
126
|
+
|
127
|
+
{
|
128
|
+
'unquoted' => %q<>,
|
129
|
+
'double quoted' => %q<">
|
130
|
+
}.each do
|
131
|
+
|name, quote|
|
132
|
+
|
133
|
+
it "with #{name}, unescaped at sign, but forced to v1 grammar" do
|
134
|
+
fig(
|
135
|
+
[
|
136
|
+
%w<--publish foo/1.2.3>,
|
137
|
+
"--#{assignment_type}",
|
138
|
+
'VARIABLE_WITH_WHITESPACE_TO_FORCE=v1 grammar',
|
139
|
+
"--#{assignment_type}",
|
140
|
+
"VARIABLE=#{quote}foo@bar#{quote}"
|
141
|
+
],
|
142
|
+
:fork => false
|
143
|
+
)
|
144
|
+
|
145
|
+
out, * = check_published_grammar_version(1)
|
146
|
+
|
147
|
+
out.should =~ / \b #{assignment_type} \s+ VARIABLE="foo@bar" /x
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe 'for --set' do
|
153
|
+
it_behaves_like 'environment variable option', 'set'
|
154
|
+
|
155
|
+
ILLEGAL_CHARACTERS_IN_V0_PATH_STATEMENTS.each do
|
156
|
+
|character|
|
157
|
+
|
158
|
+
it "for «#{character}»" do
|
159
|
+
fig(
|
160
|
+
[
|
161
|
+
%w<--publish foo/1.2.3 --set>,
|
162
|
+
"VARIABLE=#{character}"
|
163
|
+
],
|
164
|
+
:fork => false
|
165
|
+
)
|
166
|
+
|
167
|
+
out, * = check_published_grammar_version(0)
|
168
|
+
|
169
|
+
out.should =~ / \b set \s+ VARIABLE=#{Regexp.quote character} [^'] /x
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe 'for --add' do
|
175
|
+
it_behaves_like 'environment variable option', 'add'
|
176
|
+
|
177
|
+
ILLEGAL_CHARACTERS_IN_V0_PATH_STATEMENTS.each do
|
178
|
+
|character|
|
179
|
+
|
180
|
+
it "for «VARIABLE=#{character}»" do
|
181
|
+
fig(
|
182
|
+
[
|
183
|
+
%w<--publish foo/1.2.3 --append>,
|
184
|
+
"VARIABLE=#{character}"
|
185
|
+
],
|
186
|
+
:fork => false
|
187
|
+
)
|
188
|
+
|
189
|
+
out, * = check_published_grammar_version(1)
|
190
|
+
|
191
|
+
out.should =~ / \b add \s+ VARIABLE='#{Regexp.quote character}' /x
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
shared_examples_for 'environment variable statement' do
|
197
|
+
|assignment_type|
|
198
|
+
|
199
|
+
it 'with simple value' do
|
200
|
+
out, * = check_published_grammar_version(0, <<-"END_INPUT")
|
201
|
+
grammar v1
|
202
|
+
config default
|
203
|
+
#{assignment_type} VARIABLE=VALUE
|
204
|
+
end
|
205
|
+
END_INPUT
|
206
|
+
|
207
|
+
out.should =~ / \b #{assignment_type} \s+ VARIABLE=VALUE \b /x
|
208
|
+
end
|
209
|
+
|
210
|
+
{
|
211
|
+
'double quoted' => %q<">,
|
212
|
+
'single quoted' => %q<'>
|
213
|
+
}.each do
|
214
|
+
|name, quote|
|
215
|
+
|
216
|
+
it "with #{name} whitespace" do
|
217
|
+
out, * = check_published_grammar_version(1, <<-"END_INPUT")
|
218
|
+
grammar v1
|
219
|
+
config default
|
220
|
+
#{assignment_type} VARIABLE=#{quote}foo bar#{quote}
|
221
|
+
end
|
222
|
+
END_INPUT
|
223
|
+
|
224
|
+
out.should =~ / \b #{assignment_type} \s+ VARIABLE='foo[ ]bar' /x
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
ENVIRONMENT_VARIABLE_PUBLISHED_QUOTING_EXAMPLES.each do
|
229
|
+
|expected, inputs|
|
230
|
+
|
231
|
+
result, version = *expected
|
232
|
+
|
233
|
+
inputs.each do
|
234
|
+
|value|
|
235
|
+
|
236
|
+
it "with «#{value}»" do
|
237
|
+
out, * = check_published_grammar_version(version, <<-"END_INPUT")
|
238
|
+
grammar v1
|
239
|
+
config default
|
240
|
+
#{assignment_type} #{value}
|
241
|
+
end
|
242
|
+
END_INPUT
|
243
|
+
|
244
|
+
out.should =~ / \b #{assignment_type} \s+ #{Regexp.quote result} /x
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
describe 'for set statement in v1 grammar' do
|
251
|
+
it_behaves_like 'environment variable statement', 'set'
|
252
|
+
|
253
|
+
ILLEGAL_CHARACTERS_IN_V0_PATH_STATEMENTS.each do
|
254
|
+
|character|
|
255
|
+
|
256
|
+
it "for «#{character}»" do
|
257
|
+
out, * = check_published_grammar_version(0, <<-"END_INPUT")
|
258
|
+
grammar v1
|
259
|
+
config default
|
260
|
+
set VARIABLE=#{character}
|
261
|
+
end
|
262
|
+
END_INPUT
|
263
|
+
|
264
|
+
out.should =~ / \b set \s+ VARIABLE=#{Regexp.quote character} [^'] /x
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
describe 'for add statement in v1 grammar' do
|
270
|
+
it_behaves_like 'environment variable statement', 'add'
|
271
|
+
|
272
|
+
ILLEGAL_CHARACTERS_IN_V0_PATH_STATEMENTS.each do
|
273
|
+
|character|
|
274
|
+
|
275
|
+
it "for «#{character}»" do
|
276
|
+
out, * = check_published_grammar_version(1, <<-"END_INPUT")
|
277
|
+
grammar v1
|
278
|
+
config default
|
279
|
+
add VARIABLE=#{character}
|
280
|
+
end
|
281
|
+
END_INPUT
|
282
|
+
|
283
|
+
out.should =~ / \b add \s+ VARIABLE='#{Regexp.quote character}' /x
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
describe %q<rejects path statements from v0 package definition files containing> do
|
290
|
+
before(:each) do
|
291
|
+
clean_up_test_environment
|
292
|
+
set_up_test_environment
|
293
|
+
end
|
294
|
+
|
295
|
+
ILLEGAL_CHARACTERS_IN_V0_PATH_STATEMENTS.each do
|
296
|
+
|character|
|
297
|
+
|
298
|
+
it %Q<«#{character}»> do
|
299
|
+
input = <<-END
|
300
|
+
grammar v0
|
301
|
+
config default
|
302
|
+
add VARIABLE=x#{character}x
|
303
|
+
end
|
304
|
+
END
|
305
|
+
|
306
|
+
out, err, exit_code =
|
307
|
+
fig [], input, :no_raise_on_error => true, :fork => false
|
308
|
+
err.should =~
|
309
|
+
/value of path variable VARIABLE.*contains.*"#{Regexp.quote character}"/
|
310
|
+
out.should == ''
|
311
|
+
exit_code.should_not == 0
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
it %Q<«'»> do
|
316
|
+
input = <<-END
|
317
|
+
grammar v0
|
318
|
+
config default
|
319
|
+
add VARIABLE=x'x
|
320
|
+
end
|
321
|
+
END
|
322
|
+
|
323
|
+
out, err, exit_code =
|
324
|
+
fig [], input, :no_raise_on_error => true, :fork => false
|
325
|
+
err.should =~ /value of VARIABLE.*contains.*single quote/
|
326
|
+
out.should == ''
|
327
|
+
exit_code.should_not == 0
|
328
|
+
end
|
329
|
+
|
330
|
+
it %Q<«"»> do
|
331
|
+
input = <<-END
|
332
|
+
grammar v0
|
333
|
+
config default
|
334
|
+
add VARIABLE=x"x
|
335
|
+
end
|
336
|
+
END
|
337
|
+
|
338
|
+
out, err, exit_code =
|
339
|
+
fig [], input, :no_raise_on_error => true, :fork => false
|
340
|
+
err.should =~ /value of VARIABLE.*contains.*double quote/
|
341
|
+
out.should == ''
|
342
|
+
exit_code.should_not == 0
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
describe %q<rejects set statements from v0 package definition files containing> do
|
347
|
+
before(:each) do
|
348
|
+
clean_up_test_environment
|
349
|
+
set_up_test_environment
|
350
|
+
end
|
351
|
+
|
352
|
+
it %Q<«'»> do
|
353
|
+
input = <<-END
|
354
|
+
grammar v0
|
355
|
+
config default
|
356
|
+
set VARIABLE=x'x
|
357
|
+
end
|
358
|
+
END
|
359
|
+
|
360
|
+
out, err, exit_code =
|
361
|
+
fig [], input, :no_raise_on_error => true, :fork => false
|
362
|
+
err.should =~ /value of VARIABLE.*contains.*single quote/
|
363
|
+
out.should == ''
|
364
|
+
exit_code.should_not == 0
|
365
|
+
end
|
366
|
+
|
367
|
+
it %Q<«"»> do
|
368
|
+
input = <<-END
|
369
|
+
grammar v0
|
370
|
+
config default
|
371
|
+
set VARIABLE=x"x
|
372
|
+
end
|
373
|
+
END
|
374
|
+
|
375
|
+
out, err, exit_code =
|
376
|
+
fig [], input, :no_raise_on_error => true, :fork => false
|
377
|
+
err.should =~ /value of VARIABLE.*contains.*double quote/
|
378
|
+
out.should == ''
|
379
|
+
exit_code.should_not == 0
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
# vim: set fileencoding=utf8 :
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/grammar_spec_helper')
|
3
|
+
|
4
|
+
describe 'Fig' do
|
5
|
+
before(:each) do
|
6
|
+
clean_up_test_environment
|
7
|
+
set_up_test_environment
|
8
|
+
end
|
9
|
+
|
10
|
+
describe %q<uses the correct grammar version in the package definition created for publishing> do
|
11
|
+
it 'from v1 file input with a simple, unquoted retrieve statement' do
|
12
|
+
check_published_grammar_version 0, <<-'END'
|
13
|
+
grammar v1
|
14
|
+
retrieve variable->value
|
15
|
+
END
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'from v1 file input with a simple, single-quoted retrieve statement (v1 currently, should change to v0 eventually)' do
|
19
|
+
check_published_grammar_version 0, <<-'END'
|
20
|
+
grammar v1
|
21
|
+
retrieve variable->'value'
|
22
|
+
END
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'from v1 file input with a package-expanded, single-quoted retrieve statement' do
|
26
|
+
check_published_grammar_version 0, <<-'END'
|
27
|
+
grammar v1
|
28
|
+
retrieve variable->"value[package]value"
|
29
|
+
END
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'from v1 file input with package-escaped, single-quoted retrieve statement' do
|
33
|
+
# Backslashes are not allowed in v0 grammar, at all. Not even to escape
|
34
|
+
# "[package]".
|
35
|
+
check_published_grammar_version 1, <<-'END'
|
36
|
+
grammar v1
|
37
|
+
retrieve variable->"value\[package]value"
|
38
|
+
END
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'from v1 file input with a retrieve statement containing whitespace' do
|
42
|
+
check_published_grammar_version 1, <<-'END'
|
43
|
+
grammar v1
|
44
|
+
retrieve variable->"some value"
|
45
|
+
END
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'from v1 file input with a retrieve statement containing an octothorpe' do
|
49
|
+
check_published_grammar_version 1, <<-'END'
|
50
|
+
grammar v1
|
51
|
+
retrieve variable->"some#value"
|
52
|
+
END
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it %q<considers a retrieve path containing an unescaped square bracket that is not followed by "package]" to be a syntax error> do
|
57
|
+
input = <<-'END'
|
58
|
+
grammar v1
|
59
|
+
retrieve variable->value[something]value
|
60
|
+
END
|
61
|
+
|
62
|
+
out, err, exit_code = fig(
|
63
|
+
%w< --publish foo/1.2.3 >,
|
64
|
+
input,
|
65
|
+
:no_raise_on_error => true,
|
66
|
+
:fork => false
|
67
|
+
)
|
68
|
+
err.should =~ /\[something\]/
|
69
|
+
out.should == ''
|
70
|
+
exit_code.should_not == 0
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# vim: set fileencoding=utf8 :
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/grammar_spec_helper')
|
3
|
+
|
4
|
+
describe 'Fig' do
|
5
|
+
describe 'grammar statement' do
|
6
|
+
before(:each) do
|
7
|
+
clean_up_test_environment
|
8
|
+
set_up_test_environment
|
9
|
+
end
|
10
|
+
|
11
|
+
%w< 0 1 2 >.each do
|
12
|
+
|version|
|
13
|
+
|
14
|
+
it %Q<for v#{version} is accepted> do
|
15
|
+
input = <<-"END"
|
16
|
+
# A comment
|
17
|
+
grammar v#{version}
|
18
|
+
config default
|
19
|
+
set variable=foo
|
20
|
+
end
|
21
|
+
END
|
22
|
+
|
23
|
+
out, err = fig(%w<--get variable>, input, :fork => false)
|
24
|
+
err.should == ''
|
25
|
+
out.should == 'foo'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it %q<is not accepted if it isn't the first statement> do
|
30
|
+
skip 'user-friendly warning message not implemented yet' do
|
31
|
+
input = <<-END
|
32
|
+
config default
|
33
|
+
end
|
34
|
+
grammar v1
|
35
|
+
END
|
36
|
+
|
37
|
+
out, err, exit_code =
|
38
|
+
fig([], input, :no_raise_on_error => true, :fork => false)
|
39
|
+
err.should =~ /grammar statement wasn't first statement/i
|
40
|
+
out.should == ''
|
41
|
+
exit_code.should_not == 0
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it %q<is not accepted for future version> do
|
46
|
+
input = <<-END
|
47
|
+
grammar v31415269
|
48
|
+
config default
|
49
|
+
end
|
50
|
+
END
|
51
|
+
|
52
|
+
out, err, exit_code =
|
53
|
+
fig([], input, :no_raise_on_error => true, :fork => false)
|
54
|
+
err.should =~ /don't know how to parse grammar version/i
|
55
|
+
out.should == ''
|
56
|
+
exit_code.should_not == 0
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe %q<uses the correct grammar version in the package definition created for publishing> do
|
61
|
+
before(:each) do
|
62
|
+
clean_up_test_environment
|
63
|
+
set_up_test_environment
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'from unversioned file input with a "default" config' do
|
67
|
+
check_published_grammar_version(0, <<-'END')
|
68
|
+
config default
|
69
|
+
end
|
70
|
+
END
|
71
|
+
end
|
72
|
+
|
73
|
+
%w< 1 2 >.each do
|
74
|
+
|version|
|
75
|
+
|
76
|
+
it %Q<from v#{version} grammar file input with a "default" config> do
|
77
|
+
check_published_grammar_version(0, <<-"END")
|
78
|
+
grammar v#{version}
|
79
|
+
config default
|
80
|
+
end
|
81
|
+
END
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# vim: set fileencoding=utf8 :
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
3
|
+
|
4
|
+
def check_published_grammar_version(version, input = nil)
|
5
|
+
if input
|
6
|
+
fig %w< --publish foo/1.2.3 >, input, :fork => false
|
7
|
+
end
|
8
|
+
|
9
|
+
out, err =
|
10
|
+
fig(%w< foo/1.2.3 --dump-package-definition-text >, :fork => false)
|
11
|
+
|
12
|
+
if version == 0
|
13
|
+
out.should =~ /^# grammar v0\b/
|
14
|
+
else
|
15
|
+
out.should =~ / ^ grammar [ ] v #{version} \b/x
|
16
|
+
end
|
17
|
+
|
18
|
+
err.should == ''
|
19
|
+
|
20
|
+
return [out, err]
|
21
|
+
end
|
22
|
+
|
23
|
+
# vim: set fileencoding=utf8 :
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
|
+
|
5
|
+
describe 'Fig' do
|
6
|
+
def set_up_include_files()
|
7
|
+
cleanup_home_and_remote
|
8
|
+
base_included = "#{CURRENT_DIRECTORY}/included"
|
9
|
+
sub_included = "#{base_included}/subdirectory"
|
10
|
+
|
11
|
+
FileUtils.mkdir_p sub_included
|
12
|
+
|
13
|
+
IO.write "#{sub_included}/leaf.fig", <<-END_PACKAGE
|
14
|
+
grammar v2
|
15
|
+
config default
|
16
|
+
set SUB_PACKAGE=@/default
|
17
|
+
set SHOULD_BE_OVERRIDDEN='not overridden'
|
18
|
+
end
|
19
|
+
|
20
|
+
config non-default
|
21
|
+
set SUB_PACKAGE=@/non-default
|
22
|
+
end
|
23
|
+
|
24
|
+
config not-used
|
25
|
+
set SHOULD_NOT_BE_SET='was set'
|
26
|
+
end
|
27
|
+
END_PACKAGE
|
28
|
+
IO.write "#{base_included}/peer.fig", <<-END_PACKAGE
|
29
|
+
grammar v2
|
30
|
+
config default
|
31
|
+
set PEER='was set'
|
32
|
+
# Note path relative to this file and not to CURRENT_DIRECTORY.
|
33
|
+
include-file "subdirectory/leaf.fig":non-default
|
34
|
+
end
|
35
|
+
END_PACKAGE
|
36
|
+
IO.write "#{base_included}/base.fig", <<-END_PACKAGE
|
37
|
+
grammar v2
|
38
|
+
config default
|
39
|
+
include-file subdirectory/leaf.fig
|
40
|
+
include-file 'peer.fig'
|
41
|
+
|
42
|
+
set SHOULD_BE_OVERRIDDEN=overridden
|
43
|
+
end
|
44
|
+
END_PACKAGE
|
45
|
+
IO.write "#{CURRENT_DIRECTORY}/test.fig", <<-END_PACKAGE
|
46
|
+
grammar v2
|
47
|
+
retrieve SUB_PACKAGE->somewhere
|
48
|
+
config default
|
49
|
+
include-file 'included/base.fig'
|
50
|
+
end
|
51
|
+
END_PACKAGE
|
52
|
+
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'handles include-file' do
|
57
|
+
set_up_include_files
|
58
|
+
|
59
|
+
out, err, * = fig(
|
60
|
+
[
|
61
|
+
'--file', "#{CURRENT_DIRECTORY}/test.fig",
|
62
|
+
'--update',
|
63
|
+
'--list-variables',
|
64
|
+
],
|
65
|
+
:fork => false,
|
66
|
+
)
|
67
|
+
out.should =~ /^PEER=was set$/
|
68
|
+
out.should =~ %r<^SUB_PACKAGE=.*subdirectory/non-default$>
|
69
|
+
out.should =~ /^SHOULD_BE_OVERRIDDEN=overridden$/
|
70
|
+
out.should_not =~ /^SHOULD_NOT_BE_SET=/
|
71
|
+
err.should =~ /[Rr]etrieve.*SUB_PACKAGE.*ignored/
|
72
|
+
end
|
73
|
+
end
|