fig 2.0.0.pre.alpha.3 → 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/application_configuration.rb +2 -1
- data/lib/fig/command/options/parser.rb +4 -2
- data/lib/fig/command/options.rb +1 -1
- data/lib/fig/command.rb +17 -8
- data/lib/fig/figrc.rb +41 -14
- data/lib/fig/protocol/file.rb +3 -1
- data/lib/fig/protocol/ftp.rb +5 -5
- data/lib/fig/repository.rb +15 -11
- data/lib/fig/spec_utils.rb +312 -0
- data/lib/fig/url_access_disallowed_error.rb +5 -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 +58 -7
@@ -0,0 +1,596 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
|
+
|
5
|
+
require 'fig/command/package_loader'
|
6
|
+
require 'fig/operating_system'
|
7
|
+
require 'fig/repository'
|
8
|
+
|
9
|
+
ECHO_COMMAND = Fig::OperatingSystem.windows? ? '@echo' : 'echo'
|
10
|
+
|
11
|
+
describe 'Fig' do
|
12
|
+
describe 'publishing (without retrieval)' do
|
13
|
+
context 'starting with a clean home and remote repository' do
|
14
|
+
before(:each) do
|
15
|
+
clean_up_test_environment
|
16
|
+
set_up_test_environment
|
17
|
+
cleanup_home_and_remote
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'complains when multiple assets have the same base name' do
|
21
|
+
input = <<-END
|
22
|
+
archive http://some-host/duplicate-archive.tar.gz
|
23
|
+
archive http://some-other-host/duplicate-archive.tar.gz
|
24
|
+
config default end
|
25
|
+
END
|
26
|
+
|
27
|
+
out, err, exit_code =
|
28
|
+
fig(%w<--publish foo/1.2.3>, input, :no_raise_on_error => true)
|
29
|
+
|
30
|
+
err.should =~ /multiple assets/
|
31
|
+
err.should =~ /duplicate-archive\.tar\.gz/
|
32
|
+
exit_code.should_not == 0
|
33
|
+
end
|
34
|
+
|
35
|
+
%w< archive resource >.each do
|
36
|
+
|asset_type|
|
37
|
+
|
38
|
+
it "complains when #{asset_type}s refer to a URL with a base name the same as the resources tarball" do
|
39
|
+
input = <<-END
|
40
|
+
#{asset_type} http://some-host/#{Fig::Repository::RESOURCES_FILE}
|
41
|
+
config default end
|
42
|
+
END
|
43
|
+
|
44
|
+
out, err, exit_code =
|
45
|
+
fig(%w<--publish foo/1.2.3>, input, :no_raise_on_error => true)
|
46
|
+
|
47
|
+
err.should =~
|
48
|
+
/cannot have an asset with the name "#{Regexp.escape(Fig::Repository::RESOURCES_FILE)}"/
|
49
|
+
exit_code.should_not == 0
|
50
|
+
end
|
51
|
+
|
52
|
+
it "complains when #{asset_type}s refer to non-existent local paths" do
|
53
|
+
out, err, exit_code =
|
54
|
+
fig(
|
55
|
+
[
|
56
|
+
%w<--publish foo/1.2.3>,
|
57
|
+
"--#{asset_type}",
|
58
|
+
'does not exist.zip',
|
59
|
+
%w<--set VARIABLE=VALUE>
|
60
|
+
].flatten,
|
61
|
+
:no_raise_on_error => true
|
62
|
+
)
|
63
|
+
|
64
|
+
err.should =~ /\bcould not find file\b/i
|
65
|
+
err.should =~ /\bdoes not exist\b/
|
66
|
+
exit_code.should_not == 0
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it "complains when globbing for archives picks up a file with the same as the resources tarball" do
|
71
|
+
IO.write(
|
72
|
+
"#{CURRENT_DIRECTORY}/#{Fig::Repository::RESOURCES_FILE}", ''
|
73
|
+
)
|
74
|
+
|
75
|
+
input = <<-END
|
76
|
+
archive *
|
77
|
+
config default end
|
78
|
+
END
|
79
|
+
|
80
|
+
out, err, exit_code =
|
81
|
+
fig(%w<--publish foo/1.2.3>, input, :no_raise_on_error => true)
|
82
|
+
|
83
|
+
err.should =~
|
84
|
+
/cannot have an asset with the name "#{Regexp.escape(Fig::Repository::RESOURCES_FILE)}"/
|
85
|
+
exit_code.should_not == 0
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'publishes to remote repository' do
|
89
|
+
input = <<-END
|
90
|
+
config default
|
91
|
+
set FOO=BAR
|
92
|
+
end
|
93
|
+
END
|
94
|
+
|
95
|
+
fig(%w<--publish foo/1.2.3>, input)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'publishes a package named "config"' do
|
99
|
+
fig(%w<--publish config/1.2.3 --set VARIABLE=VALUE>)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'publishes a package with a "config" config' do
|
103
|
+
input = <<-END
|
104
|
+
config config
|
105
|
+
set FOO=BAR
|
106
|
+
end
|
107
|
+
END
|
108
|
+
|
109
|
+
fig(%w<--publish foo/1.2.3>, input)
|
110
|
+
end
|
111
|
+
|
112
|
+
it %q<--publish complains if local repository isn't in the expected format version> do
|
113
|
+
input = <<-END
|
114
|
+
config default
|
115
|
+
set FOO=BAR
|
116
|
+
end
|
117
|
+
END
|
118
|
+
|
119
|
+
set_local_repository_format_to_future_version()
|
120
|
+
out, err, exit_code =
|
121
|
+
fig(%w<--publish foo/1.2.3>, input, :no_raise_on_error => true)
|
122
|
+
err.should =~
|
123
|
+
/Local repository is in version \d+ format. This version of fig can only deal with repositories in version \d+ format\./
|
124
|
+
exit_code.should_not == 0
|
125
|
+
end
|
126
|
+
|
127
|
+
it %q<--publish-local complains if local repository isn't in the expected format version> do
|
128
|
+
input = <<-END
|
129
|
+
config default
|
130
|
+
set FOO=BAR
|
131
|
+
end
|
132
|
+
END
|
133
|
+
|
134
|
+
set_local_repository_format_to_future_version()
|
135
|
+
out, err, exit_code = fig(
|
136
|
+
%w<--publish-local foo/1.2.3>,
|
137
|
+
input,
|
138
|
+
:no_raise_on_error => true
|
139
|
+
)
|
140
|
+
err.should =~
|
141
|
+
/Local repository is in version \d+ format. This version of fig can only deal with repositories in version \d+ format\./
|
142
|
+
exit_code.should_not == 0
|
143
|
+
end
|
144
|
+
|
145
|
+
it %q<complains if remote repository isn't in the expected format version> do
|
146
|
+
input = <<-END
|
147
|
+
config default
|
148
|
+
set FOO=BAR
|
149
|
+
end
|
150
|
+
END
|
151
|
+
|
152
|
+
set_remote_repository_format_to_future_version()
|
153
|
+
out, err, exit_code =
|
154
|
+
fig(%w<--publish foo/1.2.3>, input, :no_raise_on_error => true)
|
155
|
+
err.should =~
|
156
|
+
/Remote repository is in version \d+ format. This version of fig can only deal with repositories in version \d+ format\./
|
157
|
+
exit_code.should_not == 0
|
158
|
+
end
|
159
|
+
|
160
|
+
describe 'overrides' do
|
161
|
+
before(:each) do
|
162
|
+
[3, 4, 5, 'command-line'].each do |point_ver|
|
163
|
+
fig(
|
164
|
+
[
|
165
|
+
'--publish',
|
166
|
+
"foo/1.2.#{point_ver}",
|
167
|
+
'--set',
|
168
|
+
"FOO=foo-v1.2.#{point_ver}"
|
169
|
+
].flatten
|
170
|
+
)
|
171
|
+
end
|
172
|
+
|
173
|
+
[0,1].each do |point_ver|
|
174
|
+
fig(
|
175
|
+
[
|
176
|
+
'--publish',
|
177
|
+
"blah/2.0.#{point_ver}",
|
178
|
+
'--set',
|
179
|
+
"BLAH=bla20#{point_ver}"
|
180
|
+
].flatten
|
181
|
+
)
|
182
|
+
end
|
183
|
+
|
184
|
+
input = <<-END
|
185
|
+
config default
|
186
|
+
include :nondefault
|
187
|
+
end
|
188
|
+
config nondefault
|
189
|
+
include foo/1.2.3
|
190
|
+
include blah/2.0.0
|
191
|
+
end
|
192
|
+
END
|
193
|
+
fig(%w<--publish bar/4.5.6>, input)
|
194
|
+
|
195
|
+
input = <<-END
|
196
|
+
# Multiple overrides will work for 'default', even if
|
197
|
+
# indirectly specified.
|
198
|
+
config default
|
199
|
+
include :nondefault
|
200
|
+
end
|
201
|
+
config nondefault
|
202
|
+
include foo/1.2.4
|
203
|
+
include blah/2.0.1
|
204
|
+
end
|
205
|
+
END
|
206
|
+
fig(%w<--publish baz/7.8.9>, input)
|
207
|
+
|
208
|
+
input = <<-END
|
209
|
+
config default
|
210
|
+
include foo/1.2.5
|
211
|
+
end
|
212
|
+
END
|
213
|
+
fig(%w<--publish cat/10.11.12>, input)
|
214
|
+
|
215
|
+
input = <<-END
|
216
|
+
config default
|
217
|
+
include bar/4.5.6
|
218
|
+
|
219
|
+
# Description of "multiple overrides" below out of date, however
|
220
|
+
# we need to ensure we don't break old package.fig files. Thus,
|
221
|
+
# we leave override statements on the same line as the include
|
222
|
+
# statements because overrides used to be part of include
|
223
|
+
# statements instead of being independent.
|
224
|
+
|
225
|
+
# Demonstrates the syntax for how a package overrides multiple
|
226
|
+
# dependencies (assuming the dependencies are resolved in a
|
227
|
+
# 'default' config section).
|
228
|
+
include baz/7.8.9:default override foo/1.2.3 override blah/2.0.0
|
229
|
+
include cat/10.11.12 override foo/1.2.3
|
230
|
+
end
|
231
|
+
END
|
232
|
+
fig(%w<--publish top/1>, input)
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'work from a published .fig file' do
|
236
|
+
fig(%w<--update --include top/1 --get FOO>)[0].should == 'foo-v1.2.3'
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'work from a package published based upon a command-line' do
|
240
|
+
fig(
|
241
|
+
%w<
|
242
|
+
command-line/some-version
|
243
|
+
--no-file
|
244
|
+
--publish
|
245
|
+
--include top/1
|
246
|
+
--override foo/1.2.command-line
|
247
|
+
>
|
248
|
+
)
|
249
|
+
fig(
|
250
|
+
%w<--no-file --include command-line/some-version --get FOO>
|
251
|
+
)[0].should == 'foo-v1.2.command-line'
|
252
|
+
end
|
253
|
+
|
254
|
+
it 'work from the command-line' do
|
255
|
+
fig(
|
256
|
+
%w<
|
257
|
+
--update
|
258
|
+
--include top/1
|
259
|
+
--override foo/1.2.command-line
|
260
|
+
--get FOO
|
261
|
+
>
|
262
|
+
)[0].should ==
|
263
|
+
'foo-v1.2.command-line'
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'fail with conflicting versions' do
|
267
|
+
out, err, exit_code =
|
268
|
+
fig(
|
269
|
+
%w<
|
270
|
+
package/version
|
271
|
+
--no-file
|
272
|
+
--publish
|
273
|
+
--include top/1
|
274
|
+
--override some-package/1.2.3
|
275
|
+
--override some-package/1.2.4
|
276
|
+
>,
|
277
|
+
:no_raise_on_error => true
|
278
|
+
)
|
279
|
+
err.should =~ /version conflict/i
|
280
|
+
err.should =~ /\bsome-package\b/
|
281
|
+
exit_code.should_not == 0
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
it 'complains if you publish without a package descriptor' do
|
286
|
+
out, err, exit_code = fig(%w<--publish>, :no_raise_on_error => true)
|
287
|
+
err.should =~ /need to specify a descriptor/i
|
288
|
+
exit_code.should_not == 0
|
289
|
+
end
|
290
|
+
|
291
|
+
it 'complains if you publish without a package version' do
|
292
|
+
out, err, exit_code = fig(%w<--publish foo>, :no_raise_on_error => true)
|
293
|
+
err.should =~ /version required/i
|
294
|
+
exit_code.should_not == 0
|
295
|
+
end
|
296
|
+
|
297
|
+
it 'refuses to overwrite existing version in remote repository without being forced' do
|
298
|
+
input = <<-END
|
299
|
+
config default
|
300
|
+
set FOO=SHEEP
|
301
|
+
end
|
302
|
+
END
|
303
|
+
fig(%w<--publish foo/1.2.3>, input)
|
304
|
+
fail unless File.exist? FIG_HOME + '/packages/foo/1.2.3/.fig'
|
305
|
+
fail unless File.exist? FIG_DOWNLOAD_DIR + '/foo/1.2.3/.fig'
|
306
|
+
fig(%w<--update --include foo/1.2.3 --get FOO>)[0].should == 'SHEEP'
|
307
|
+
|
308
|
+
input = <<-END
|
309
|
+
config default
|
310
|
+
set FOO=CHEESE
|
311
|
+
end
|
312
|
+
END
|
313
|
+
out, err, exit_code = fig(
|
314
|
+
%w<--publish foo/1.2.3>, input, :no_raise_on_error => true
|
315
|
+
)
|
316
|
+
exit_code.should_not == 0
|
317
|
+
fig(%w<--update --include foo/1.2.3 --get FOO>)[0].should == 'SHEEP'
|
318
|
+
|
319
|
+
fig(%w<--publish foo/1.2.3 --force>, input)
|
320
|
+
fig(%w<--update --include foo/1.2.3 --get FOO>)[0].should == 'CHEESE'
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'refuses to publish with --file and an environment variable option' do
|
324
|
+
IO.write("#{CURRENT_DIRECTORY}/example.fig", '')
|
325
|
+
|
326
|
+
out, err, exit_code =
|
327
|
+
fig(
|
328
|
+
%w<foo/1.2.3 --publish --file example.fig --set VARIABLE=VALUE>,
|
329
|
+
:no_raise_on_error => true
|
330
|
+
)
|
331
|
+
|
332
|
+
exit_code.should_not == 0
|
333
|
+
err.should =~
|
334
|
+
/cannot publish based upon\s+(?=.*option)(?=.*package\s+definition)/i
|
335
|
+
out.should == ''
|
336
|
+
end
|
337
|
+
|
338
|
+
it %q<--publish-local cleans up after prior local publishes of the same package version> do
|
339
|
+
a_file_unpublished = "#{CURRENT_DIRECTORY}/a-file.txt"
|
340
|
+
IO.write(a_file_unpublished, '')
|
341
|
+
|
342
|
+
input = <<-END
|
343
|
+
resource a-file.txt
|
344
|
+
|
345
|
+
config default end
|
346
|
+
END
|
347
|
+
|
348
|
+
fig(%w<--publish-local foo/1.2.3>, input)
|
349
|
+
|
350
|
+
a_file_published = "#{FIG_HOME}/runtime/foo/1.2.3/a-file.txt"
|
351
|
+
fail unless File.exist? a_file_published
|
352
|
+
|
353
|
+
File.unlink a_file_unpublished
|
354
|
+
|
355
|
+
another_file_unpublished = "#{CURRENT_DIRECTORY}/another-file.txt"
|
356
|
+
IO.write(another_file_unpublished, '')
|
357
|
+
|
358
|
+
input = <<-END
|
359
|
+
resource another-file.txt
|
360
|
+
|
361
|
+
config default end
|
362
|
+
END
|
363
|
+
|
364
|
+
fig(%w<--publish-local foo/1.2.3>, input)
|
365
|
+
|
366
|
+
another_file_published =
|
367
|
+
"#{FIG_HOME}/runtime/foo/1.2.3/another-file.txt"
|
368
|
+
fail unless File.exist? another_file_published
|
369
|
+
fail if File.exist? a_file_published # This is the real test.
|
370
|
+
end
|
371
|
+
|
372
|
+
describe 'with both a package.fig file in the current directory and an environment variable option' do
|
373
|
+
before(:each) do
|
374
|
+
IO.write(
|
375
|
+
"#{CURRENT_DIRECTORY}/#{Fig::Command::PackageLoader::DEFAULT_PACKAGE_FILE}",
|
376
|
+
<<-END_PACKAGE_DOT_FIG
|
377
|
+
config default
|
378
|
+
end
|
379
|
+
END_PACKAGE_DOT_FIG
|
380
|
+
)
|
381
|
+
end
|
382
|
+
|
383
|
+
it 'refuses to publish without --no-file' do
|
384
|
+
out, err, exit_code =
|
385
|
+
fig(
|
386
|
+
%w<foo/1.2.3 --publish --set VARIABLE=VALUE>,
|
387
|
+
:no_raise_on_error => true
|
388
|
+
)
|
389
|
+
|
390
|
+
exit_code.should_not == 0
|
391
|
+
err.should =~
|
392
|
+
/cannot publish based upon\s+(?=.*option)(?=.*package\s+definition)/i
|
393
|
+
out.should == ''
|
394
|
+
end
|
395
|
+
|
396
|
+
it 'publishes with --no-file' do
|
397
|
+
fig(%w<foo/1.2.3 --publish --set VARIABLE=VALUE --no-file>)
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
it 'includes the publish comment specified on the command-line' do
|
402
|
+
# Windows get newlines in command-line wrong, so we can't test that
|
403
|
+
# part of the value handling there.
|
404
|
+
comment = Fig::OperatingSystem.windows? ? " comment \t" :
|
405
|
+
"\n not indented \t\n\n indented\n\nnot indented \n\n"
|
406
|
+
|
407
|
+
fig(
|
408
|
+
[
|
409
|
+
%w<--publish comment/1.2.3 --set VARIABLE=VALUE --publish-comment>,
|
410
|
+
comment
|
411
|
+
]
|
412
|
+
)
|
413
|
+
|
414
|
+
out, * = fig(%w<--dump-package-definition-text comment/1.2.3>)
|
415
|
+
|
416
|
+
expected = Fig::OperatingSystem.windows? ? 'comment' :
|
417
|
+
"not indented\n#\n# indented\n#\n# not indented"
|
418
|
+
|
419
|
+
out.should be_start_with(
|
420
|
+
"# #{expected}\n#\n#\n# Publishing information"
|
421
|
+
)
|
422
|
+
end
|
423
|
+
|
424
|
+
it 'includes the publish comment specified in a file' do
|
425
|
+
file = "#{CURRENT_DIRECTORY}/comment.txt"
|
426
|
+
comment = "\n not indented \t\n\n indented\n\nnot indented \n\n"
|
427
|
+
IO.write(file, comment)
|
428
|
+
|
429
|
+
fig(
|
430
|
+
[
|
431
|
+
%w<
|
432
|
+
--publish comment-from-file/1.2.3
|
433
|
+
--set VARIABLE=VALUE
|
434
|
+
--publish-comment-file
|
435
|
+
>,
|
436
|
+
file
|
437
|
+
]
|
438
|
+
)
|
439
|
+
|
440
|
+
out, * = fig(%w<--dump-package-definition-text comment-from-file/1.2.3>)
|
441
|
+
|
442
|
+
expected = "not indented\n#\n# indented\n#\n# not indented"
|
443
|
+
|
444
|
+
out.should be_start_with(
|
445
|
+
"# #{expected}\n#\n#\n# Publishing information"
|
446
|
+
)
|
447
|
+
end
|
448
|
+
|
449
|
+
it 'includes the publish comment specified in a file and on the command-line' do
|
450
|
+
file = "#{CURRENT_DIRECTORY}/comment.txt"
|
451
|
+
IO.write(file, "«comment from file»")
|
452
|
+
|
453
|
+
fig(
|
454
|
+
[
|
455
|
+
%w<
|
456
|
+
--publish comment-from-file-and-command-line/1.2.3
|
457
|
+
--set VARIABLE=VALUE
|
458
|
+
--publish-comment-file
|
459
|
+
>,
|
460
|
+
file,
|
461
|
+
'--publish-comment',
|
462
|
+
'«comment from command-line»'
|
463
|
+
]
|
464
|
+
)
|
465
|
+
|
466
|
+
out, * = fig(
|
467
|
+
%w<
|
468
|
+
--dump-package-definition-text
|
469
|
+
comment-from-file-and-command-line/1.2.3
|
470
|
+
>
|
471
|
+
)
|
472
|
+
|
473
|
+
expected = "«comment from command-line»\n#\n# «comment from file»"
|
474
|
+
|
475
|
+
out.should be_start_with(
|
476
|
+
"# #{expected}\n#\n#\n# Publishing information"
|
477
|
+
)
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
context 'starting with a clean test environment' do
|
482
|
+
before(:each) do
|
483
|
+
clean_up_test_environment
|
484
|
+
set_up_test_environment
|
485
|
+
end
|
486
|
+
|
487
|
+
it 'publishes resource to remote repository' do
|
488
|
+
FileUtils.mkdir_p("#{CURRENT_DIRECTORY}/bin")
|
489
|
+
File.open("#{CURRENT_DIRECTORY}/bin/hello.bat", 'w') { |f| f << "#{ECHO_COMMAND} bar" }
|
490
|
+
if Fig::OperatingSystem.unix?
|
491
|
+
fail unless system "chmod +x #{CURRENT_DIRECTORY}/bin/hello.bat"
|
492
|
+
end
|
493
|
+
input = <<-END
|
494
|
+
resource bin/hello.bat
|
495
|
+
config default
|
496
|
+
append PATH=@/bin
|
497
|
+
end
|
498
|
+
END
|
499
|
+
fig(%w<--publish foo/1.2.3>, input)
|
500
|
+
fail unless File.exist? FIG_HOME + '/packages/foo/1.2.3/.fig'
|
501
|
+
fail unless File.exist? FIG_DOWNLOAD_DIR + '/foo/1.2.3/.fig'
|
502
|
+
fig(%w<--update --include foo/1.2.3 -- hello.bat>)[0].should == 'bar'
|
503
|
+
end
|
504
|
+
|
505
|
+
it 'publishes resource to remote repository using command line' do
|
506
|
+
FileUtils.mkdir_p("#{CURRENT_DIRECTORY}/bin")
|
507
|
+
File.open("#{CURRENT_DIRECTORY}/bin/hello.bat", 'w') { |f| f << "#{ECHO_COMMAND} bar" }
|
508
|
+
if Fig::OperatingSystem.unix?
|
509
|
+
fail unless system "chmod +x #{CURRENT_DIRECTORY}/bin/hello.bat"
|
510
|
+
end
|
511
|
+
fig(%w<--publish foo/1.2.3 --resource bin/hello.bat --append PATH=@/bin>)
|
512
|
+
fail unless File.exist? FIG_HOME + '/packages/foo/1.2.3/.fig'
|
513
|
+
fail unless File.exist? FIG_DOWNLOAD_DIR + '/foo/1.2.3/.fig'
|
514
|
+
fig(%w<--update --include foo/1.2.3 -- hello.bat>)[0].should == 'bar'
|
515
|
+
end
|
516
|
+
|
517
|
+
it 'publishes only to the local repo when told to' do
|
518
|
+
# This shouldn't matter because the remote repo shouldn't be looked at.
|
519
|
+
set_remote_repository_format_to_future_version()
|
520
|
+
|
521
|
+
FileUtils.mkdir_p("#{CURRENT_DIRECTORY}/bin")
|
522
|
+
File.open("#{CURRENT_DIRECTORY}/bin/hello.bat", 'w') { |f| f << "#{ECHO_COMMAND} bar" }
|
523
|
+
if Fig::OperatingSystem.unix?
|
524
|
+
fail unless system "chmod +x #{CURRENT_DIRECTORY}/bin/hello.bat"
|
525
|
+
end
|
526
|
+
fig(
|
527
|
+
%w<
|
528
|
+
--publish-local foo/1.2.3
|
529
|
+
--resource bin/hello.bat
|
530
|
+
--append PATH=@/bin
|
531
|
+
>
|
532
|
+
)
|
533
|
+
fail if File.exist? FIG_DOWNLOAD_DIR + '/foo/1.2.3/.fig'
|
534
|
+
fig(
|
535
|
+
%w<--update-if-missing --include foo/1.2.3 -- hello.bat>
|
536
|
+
)[0].should == 'bar'
|
537
|
+
end
|
538
|
+
|
539
|
+
it 'publishes a file containing an include statement without a version' do
|
540
|
+
set_up_test_environment()
|
541
|
+
|
542
|
+
input = <<-END_INPUT
|
543
|
+
config default
|
544
|
+
include foo # no version; need to be able to publish anyway. *sigh*
|
545
|
+
end
|
546
|
+
END_INPUT
|
547
|
+
|
548
|
+
out, err = fig(%w<--publish foo/1.2.3>, input)
|
549
|
+
|
550
|
+
out.should == ''
|
551
|
+
err.should =~
|
552
|
+
/No version in the package descriptor of "foo" in an include statement \(line/
|
553
|
+
end
|
554
|
+
|
555
|
+
it 'updates local packages if they already exist' do
|
556
|
+
FileUtils.mkdir_p("#{CURRENT_DIRECTORY}/bin")
|
557
|
+
File.open("#{CURRENT_DIRECTORY}/bin/hello.bat", 'w') { |f| f << "#{ECHO_COMMAND} sheep" }
|
558
|
+
if Fig::OperatingSystem.unix?
|
559
|
+
fail unless system "chmod +x #{CURRENT_DIRECTORY}/bin/hello.bat"
|
560
|
+
end
|
561
|
+
fig(
|
562
|
+
%w<
|
563
|
+
--publish-local foo/1.2.3
|
564
|
+
--resource bin/hello.bat
|
565
|
+
--append PATH=@/bin
|
566
|
+
>
|
567
|
+
)
|
568
|
+
fail if File.exist? FIG_DOWNLOAD_DIR + '/foo/1.2.3/.fig'
|
569
|
+
fig(
|
570
|
+
%w<
|
571
|
+
--update-if-missing
|
572
|
+
--include foo/1.2.3
|
573
|
+
-- hello.bat
|
574
|
+
>
|
575
|
+
)[0].should == 'sheep'
|
576
|
+
|
577
|
+
File.open("#{CURRENT_DIRECTORY}/bin/hello.bat", 'w') {
|
578
|
+
|f| f << "#{ECHO_COMMAND} cheese"
|
579
|
+
}
|
580
|
+
if Fig::OperatingSystem.unix?
|
581
|
+
fail unless system "chmod +x #{CURRENT_DIRECTORY}/bin/hello.bat"
|
582
|
+
end
|
583
|
+
fig(
|
584
|
+
%w<
|
585
|
+
--publish-local foo/1.2.3
|
586
|
+
--resource bin/hello.bat
|
587
|
+
--append PATH=@/bin
|
588
|
+
>
|
589
|
+
)
|
590
|
+
fail if File.exist? FIG_DOWNLOAD_DIR + '/foo/1.2.3/.fig'
|
591
|
+
fig(%w<--update-if-missing --include foo/1.2.3 -- hello.bat>)[0].should ==
|
592
|
+
'cheese'
|
593
|
+
end
|
594
|
+
end
|
595
|
+
end
|
596
|
+
end
|