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,145 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
|
+
|
5
|
+
require 'fig/command/package_loader'
|
6
|
+
|
7
|
+
describe 'Fig' do
|
8
|
+
before(:each) do
|
9
|
+
clean_up_test_environment
|
10
|
+
set_up_test_environment
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'ignores comments' do
|
14
|
+
input = <<-END
|
15
|
+
# Some comment
|
16
|
+
config default
|
17
|
+
set FOO=BAR # Another comment
|
18
|
+
end
|
19
|
+
END
|
20
|
+
fig(%w<--get FOO>, input)[0].should == 'BAR'
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '--file' do
|
24
|
+
it 'reads from the value' do
|
25
|
+
dot_fig_file = "#{FIG_SPEC_BASE_DIRECTORY}/file-option-test.fig"
|
26
|
+
IO.write(dot_fig_file, <<-END)
|
27
|
+
config default
|
28
|
+
set FOO=BAR
|
29
|
+
end
|
30
|
+
END
|
31
|
+
fig(['--file', dot_fig_file, '--get', 'FOO'])[0].should == 'BAR'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'complains about the value not existing' do
|
35
|
+
out, err, exit_code =
|
36
|
+
fig(%w<--file does-not-exist --get FOO>, :no_raise_on_error => true)
|
37
|
+
out.should == ''
|
38
|
+
err.should =~ /does-not-exist/
|
39
|
+
exit_code.should_not == 0
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
[
|
44
|
+
Fig::Command::PackageLoader::DEFAULT_PACKAGE_FILE,
|
45
|
+
Fig::Command::PackageLoader::DEFAULT_APPLICATION_FILE,
|
46
|
+
].each do
|
47
|
+
|file_name|
|
48
|
+
|
49
|
+
it "ignores #{file_name} with the --no-file option" do
|
50
|
+
dot_fig_file = "#{FIG_SPEC_BASE_DIRECTORY}/#{file_name}"
|
51
|
+
IO.write(dot_fig_file, <<-END)
|
52
|
+
config default
|
53
|
+
set FOO=BAR
|
54
|
+
end
|
55
|
+
END
|
56
|
+
fig(%w<--no-file --get FOO>)[0].should == ''
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'complains about conflicting package versions' do
|
61
|
+
fig(%w<--publish foo/1.2.3 --set VARIABLE=VALUE>)
|
62
|
+
fig(%w<--publish foo/4.5.6 --set VARIABLE=VALUE>)
|
63
|
+
|
64
|
+
out, err, exit_code = fig(
|
65
|
+
%w<--update --include foo/1.2.3 --include foo/4.5.6>,
|
66
|
+
:no_raise_on_error => true
|
67
|
+
)
|
68
|
+
exit_code.should_not == 0
|
69
|
+
err.should =~ /version mismatch for package foo/i
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'emits the version number' do
|
73
|
+
%w/-v --version/.each do
|
74
|
+
|option|
|
75
|
+
|
76
|
+
it "descriptively with #{option}" do
|
77
|
+
(out, err, exitstatus) = fig([option])
|
78
|
+
exitstatus.should == 0
|
79
|
+
err.should == ''
|
80
|
+
out.should =~ %r<
|
81
|
+
\A # Start of string
|
82
|
+
\w+ # Some text...
|
83
|
+
\s+ # ... followed by some whitespace
|
84
|
+
.* # whatever (so test doesn't change as the text does)
|
85
|
+
\d+ \. \d+ \. \d+ # Some dotted number
|
86
|
+
>x
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'plainly with --version-plain' do
|
91
|
+
(out, err, exitstatus) =
|
92
|
+
fig %w< --version-plain >, :dont_strip_output => true
|
93
|
+
|
94
|
+
exitstatus.should == 0
|
95
|
+
err.should == ''
|
96
|
+
out.should =~ %r<
|
97
|
+
\A # Start of string
|
98
|
+
\d+ \. \d+ \. \d+ # Some dotted number
|
99
|
+
>x
|
100
|
+
out.should_not =~ %r< \n \z >x
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe 'emits help summary for' do
|
105
|
+
%w/-? -h --help/.each do
|
106
|
+
|option|
|
107
|
+
|
108
|
+
it option do
|
109
|
+
out, err = fig([option])
|
110
|
+
err.should == ''
|
111
|
+
out.should =~ / \b summary \b /xi
|
112
|
+
out.should =~ / \b fig \b /x
|
113
|
+
out.should =~ / --update \b /x
|
114
|
+
out.should =~ / --set \b /x
|
115
|
+
out.should =~ / --publish \b /x
|
116
|
+
out.should =~ / --options \b /x
|
117
|
+
out.should =~ / --help-long \b /x
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'emits full help with --help-long' do
|
123
|
+
out, err = fig(['--help-long'])
|
124
|
+
err.should == ''
|
125
|
+
out.should =~ / \b fig \b /x
|
126
|
+
out.should =~ / --update \b /x
|
127
|
+
out.should =~ / --set \b /x
|
128
|
+
out.should =~ / --publish \b /x
|
129
|
+
out.should =~ / --force \b /x
|
130
|
+
out.should =~ / --help \b /x
|
131
|
+
out.should =~ / --help-long \b /x
|
132
|
+
out.should =~ / --options \b /x
|
133
|
+
out.should =~ / \b FIG_DOWNLOAD_URL \b /x
|
134
|
+
out.should =~ / \b FIG_UPLOAD_URL \b /x
|
135
|
+
out.should =~ / \b FIG_HOME \b /x
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'emits option list with --options' do
|
139
|
+
out, err = fig(['--options'])
|
140
|
+
err.should == ''
|
141
|
+
out.should =~ / options: /ix
|
142
|
+
out.should =~ / --help \b /x
|
143
|
+
out.should =~ / --options \b /x
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
|
+
|
5
|
+
describe 'Fig' do
|
6
|
+
before(:each) do
|
7
|
+
clean_up_test_environment
|
8
|
+
set_up_test_environment
|
9
|
+
end
|
10
|
+
|
11
|
+
it %q<doesn't remove --publish-local packages during a failed --update.> do
|
12
|
+
fig %w<--publish-local publish-local/test --set foo=bar>
|
13
|
+
|
14
|
+
out, err, exit_code = fig(
|
15
|
+
%w<publish-local/test --get foo>, :fork => false
|
16
|
+
)
|
17
|
+
out.should == 'bar'
|
18
|
+
|
19
|
+
# Should not work because we didn't send it to the remote repo.
|
20
|
+
out, err, exit_code = fig(
|
21
|
+
%w<publish-local/test --update --get foo>,
|
22
|
+
:no_raise_on_error => true
|
23
|
+
)
|
24
|
+
exit_code.should_not == 0
|
25
|
+
|
26
|
+
# Should still work
|
27
|
+
out, err, exit_code = fig(
|
28
|
+
%w<publish-local/test --get foo>, :fork => false
|
29
|
+
)
|
30
|
+
out.should == 'bar'
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,423 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
|
+
|
5
|
+
require 'fig/operating_system'
|
6
|
+
|
7
|
+
describe 'Fig' do
|
8
|
+
describe 'publishing/retrieval' do
|
9
|
+
let(:publish_from_directory) { "#{FIG_SPEC_BASE_DIRECTORY}/publish-home" }
|
10
|
+
let(:lib_directory) { "#{publish_from_directory}/lib" }
|
11
|
+
let(:retrieve_directory) { "#{CURRENT_DIRECTORY}/retrieve" }
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
clean_up_test_environment
|
15
|
+
set_up_test_environment
|
16
|
+
FileUtils.mkdir_p CURRENT_DIRECTORY
|
17
|
+
FileUtils.mkdir_p lib_directory
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'retrieves resources' do
|
21
|
+
before(:each) do
|
22
|
+
IO.write("#{lib_directory}/a library", 'some library')
|
23
|
+
|
24
|
+
another_library = "#{lib_directory}/another library"
|
25
|
+
url = 'file://' + File.expand_path(another_library)
|
26
|
+
IO.write(another_library, 'some other library')
|
27
|
+
|
28
|
+
fig(
|
29
|
+
[
|
30
|
+
'--publish', 'prerequisite/1.2.3',
|
31
|
+
'--resource', 'lib/a library',
|
32
|
+
'--resource', url,
|
33
|
+
'--append', 'FOOPATH=@/lib/a library',
|
34
|
+
'--append', 'FOOPATH=@/another library'
|
35
|
+
].flatten,
|
36
|
+
:current_directory => publish_from_directory
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'and produces absolute path warning' do
|
41
|
+
input = <<-END
|
42
|
+
# Leading slash on path to test warning.
|
43
|
+
retrieve FOOPATH->/retrieve/[package]
|
44
|
+
config default
|
45
|
+
include prerequisite/1.2.3
|
46
|
+
end
|
47
|
+
END
|
48
|
+
out, err = fig(%w<--update-if-missing>, input)
|
49
|
+
File.read("#{retrieve_directory}/prerequisite/a library").should ==
|
50
|
+
'some library'
|
51
|
+
File.read("#{retrieve_directory}/prerequisite/another library").should ==
|
52
|
+
'some other library'
|
53
|
+
|
54
|
+
# Check for warning about the leading slash in FOOPATH looking like an
|
55
|
+
# absolute path.
|
56
|
+
err.should =~ /absolute/
|
57
|
+
err.should =~ /relative/
|
58
|
+
err.should =~ %r</retrieve/\[package\]>
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'and ignores the append statement in the updating config' do
|
62
|
+
input = <<-END
|
63
|
+
retrieve FOOPATH->retrieve/[package]
|
64
|
+
config default
|
65
|
+
include prerequisite/1.2.3
|
66
|
+
append FOOPATH=@/does/not/exist
|
67
|
+
end
|
68
|
+
END
|
69
|
+
fig(%w<--update-if-missing>, input)
|
70
|
+
File.read("#{retrieve_directory}/prerequisite/a library").should ==
|
71
|
+
'some library'
|
72
|
+
File.read("#{retrieve_directory}/prerequisite/another library").should ==
|
73
|
+
'some other library'
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'and can tell you where they came from' do
|
77
|
+
input = <<-END
|
78
|
+
retrieve FOOPATH->retrieve/[package]
|
79
|
+
config default
|
80
|
+
include prerequisite/1.2.3
|
81
|
+
end
|
82
|
+
END
|
83
|
+
out, * = fig(
|
84
|
+
[
|
85
|
+
'--update-if-missing',
|
86
|
+
'--source-package', "#{retrieve_directory}/prerequisite/a library",
|
87
|
+
],
|
88
|
+
input
|
89
|
+
)
|
90
|
+
|
91
|
+
out.should == 'prerequisite/1.2.3'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'retrieves resource that is a directory' do
|
96
|
+
IO.write("#{lib_directory}/a library", 'some library')
|
97
|
+
# To copy the contents of a directory, instead of the directory itself,
|
98
|
+
# use '/.' as a suffix to the directory name in 'append'.
|
99
|
+
input = <<-END
|
100
|
+
grammar v1
|
101
|
+
resource 'lib/a library'
|
102
|
+
config default
|
103
|
+
append FOOPATH=@/lib/.
|
104
|
+
end
|
105
|
+
END
|
106
|
+
fig(
|
107
|
+
%w<--publish prerequisite/1.2.3>,
|
108
|
+
input,
|
109
|
+
:current_directory => publish_from_directory
|
110
|
+
)
|
111
|
+
input = <<-END
|
112
|
+
retrieve FOOPATH->retrieve/[package]
|
113
|
+
config default
|
114
|
+
include prerequisite/1.2.3
|
115
|
+
end
|
116
|
+
END
|
117
|
+
fig(%w<--update-if-missing>, input)
|
118
|
+
File.read("#{retrieve_directory}/prerequisite/a library").should ==
|
119
|
+
'some library'
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'reports error for missing file in a package' do
|
123
|
+
IO.write("#{lib_directory}/a library", 'some library')
|
124
|
+
fig(
|
125
|
+
[
|
126
|
+
%w< --publish prerequisite/1.2.3 >,
|
127
|
+
'--resource', 'lib/a library',
|
128
|
+
'--append', 'FOOPATH=@/lib/a library',
|
129
|
+
],
|
130
|
+
:current_directory => publish_from_directory
|
131
|
+
)
|
132
|
+
FileUtils.rm("#{FIG_HOME}/runtime/prerequisite/1.2.3/lib/a library")
|
133
|
+
|
134
|
+
input = <<-END
|
135
|
+
retrieve FOOPATH->retrieve/[package]
|
136
|
+
config default
|
137
|
+
include prerequisite/1.2.3
|
138
|
+
end
|
139
|
+
END
|
140
|
+
out, err, exit_code = fig(
|
141
|
+
%w<--update-if-missing>, input, :no_raise_on_error => true
|
142
|
+
)
|
143
|
+
exit_code.should_not == 0
|
144
|
+
err.should =~
|
145
|
+
%r<the FOOPATH variable points to a path that does not exist>i
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'reports error for retrieve of source and destination being the same path' do
|
149
|
+
fig(%w<--publish prerequisite/1.2.3 --set SOME_PATH=.>)
|
150
|
+
|
151
|
+
input = <<-END
|
152
|
+
retrieve SOME_PATH->.
|
153
|
+
config default
|
154
|
+
include prerequisite/1.2.3
|
155
|
+
end
|
156
|
+
END
|
157
|
+
out, err = fig(%w<--update-if-missing>, input)
|
158
|
+
|
159
|
+
err.should =~ %r<skipping copying>i
|
160
|
+
err.should =~ %r<" [.] ">x
|
161
|
+
err.should =~ %r<to itself>i
|
162
|
+
end
|
163
|
+
|
164
|
+
it %q<preserves the path after '//' when copying files into your project directory while retrieving> do
|
165
|
+
include_directory = "#{publish_from_directory}/include"
|
166
|
+
FileUtils.mkdir_p(include_directory)
|
167
|
+
IO.write("#{include_directory}/hello.h", 'a header file')
|
168
|
+
IO.write("#{include_directory}/hello2.h", 'another header file')
|
169
|
+
input = <<-END
|
170
|
+
resource include/hello.h
|
171
|
+
resource include/hello2.h
|
172
|
+
config default
|
173
|
+
append INCLUDE=@//include/hello.h
|
174
|
+
append INCLUDE=@//include/hello2.h
|
175
|
+
end
|
176
|
+
END
|
177
|
+
fig(
|
178
|
+
%w<--publish prerequisite/1.2.3>,
|
179
|
+
input,
|
180
|
+
:current_directory => publish_from_directory
|
181
|
+
)
|
182
|
+
|
183
|
+
input = <<-END
|
184
|
+
retrieve INCLUDE->include2/[package]
|
185
|
+
config default
|
186
|
+
include prerequisite/1.2.3
|
187
|
+
end
|
188
|
+
END
|
189
|
+
fig %w<--update>, input
|
190
|
+
|
191
|
+
File.read(
|
192
|
+
"#{CURRENT_DIRECTORY}/include2/prerequisite/include/hello.h"
|
193
|
+
).should == 'a header file'
|
194
|
+
File.read(
|
195
|
+
"#{CURRENT_DIRECTORY}/include2/prerequisite/include/hello2.h"
|
196
|
+
).should == 'another header file'
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'updates without there being a copy of the package in the FIG_HOME left there from publishing' do
|
200
|
+
include_directory = "#{publish_from_directory}/include"
|
201
|
+
FileUtils.mkdir_p(include_directory)
|
202
|
+
IO.write("#{include_directory}/hello.h", 'a header file')
|
203
|
+
IO.write("#{include_directory}/hello2.h", 'another header file')
|
204
|
+
input = <<-END
|
205
|
+
resource include/hello.h
|
206
|
+
resource include/hello2.h
|
207
|
+
config default
|
208
|
+
append INCLUDE=@/include/hello.h
|
209
|
+
append INCLUDE=@/include/hello2.h
|
210
|
+
end
|
211
|
+
END
|
212
|
+
fig(
|
213
|
+
%w<--publish prerequisite/1.2.3>,
|
214
|
+
input,
|
215
|
+
:current_directory => publish_from_directory
|
216
|
+
)
|
217
|
+
|
218
|
+
FileUtils.rm_rf FIG_HOME
|
219
|
+
|
220
|
+
input = <<-END
|
221
|
+
retrieve INCLUDE->include2/[package]
|
222
|
+
config default
|
223
|
+
include prerequisite/1.2.3
|
224
|
+
end
|
225
|
+
END
|
226
|
+
fig %w<-u>, input
|
227
|
+
|
228
|
+
File.read(
|
229
|
+
"#{CURRENT_DIRECTORY}/include2/prerequisite/hello.h"
|
230
|
+
).should == 'a header file'
|
231
|
+
File.read(
|
232
|
+
"#{CURRENT_DIRECTORY}/include2/prerequisite/hello2.h"
|
233
|
+
).should == 'another header file'
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'packages multiple resources' do
|
237
|
+
IO.write("#{lib_directory}/a library", 'some library')
|
238
|
+
IO.write("#{lib_directory}/a library2", 'some other library')
|
239
|
+
input = <<-END
|
240
|
+
grammar v1
|
241
|
+
resource 'lib/a library'
|
242
|
+
resource 'lib/a library2'
|
243
|
+
config default
|
244
|
+
append FOOPATH="@/lib/a library"
|
245
|
+
append FOOPATH="@/lib/a library2"
|
246
|
+
end
|
247
|
+
END
|
248
|
+
fig(
|
249
|
+
%w<--publish prerequisite/1.2.3>,
|
250
|
+
input,
|
251
|
+
:current_directory => publish_from_directory
|
252
|
+
)
|
253
|
+
input = <<-END
|
254
|
+
retrieve FOOPATH->retrieve/[package]
|
255
|
+
config default
|
256
|
+
include prerequisite/1.2.3
|
257
|
+
end
|
258
|
+
END
|
259
|
+
fig(%w<-m>, input)
|
260
|
+
File.read("#{retrieve_directory}/prerequisite/a library").should ==
|
261
|
+
'some library'
|
262
|
+
File.read("#{retrieve_directory}/prerequisite/a library2").should ==
|
263
|
+
'some other library'
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'packages multiple resources with wildcards' do
|
267
|
+
IO.write("#{lib_directory}/foo.jar", 'some library')
|
268
|
+
IO.write("#{lib_directory}/bar.jar", 'some other library')
|
269
|
+
input = <<-END
|
270
|
+
resource **/*.jar
|
271
|
+
config default
|
272
|
+
append FOOPATH=@/lib/foo.jar
|
273
|
+
end
|
274
|
+
END
|
275
|
+
fig(
|
276
|
+
%w<--publish prerequisite/1.2.3>,
|
277
|
+
input,
|
278
|
+
:current_directory => publish_from_directory
|
279
|
+
)
|
280
|
+
input = <<-END
|
281
|
+
retrieve FOOPATH->retrieve/[package]
|
282
|
+
config default
|
283
|
+
include prerequisite/1.2.3
|
284
|
+
end
|
285
|
+
END
|
286
|
+
fig(%w<--update-if-missing>, input)
|
287
|
+
File.read("#{retrieve_directory}/prerequisite/foo.jar").should ==
|
288
|
+
'some library'
|
289
|
+
end
|
290
|
+
|
291
|
+
if Fig::OperatingSystem.unix?
|
292
|
+
it 'can publish and retrieve dangling symlinks' do
|
293
|
+
FileUtils.rm_rf(publish_from_directory)
|
294
|
+
FileUtils.mkdir_p(publish_from_directory)
|
295
|
+
|
296
|
+
File.symlink(
|
297
|
+
'does-not-exist', "#{publish_from_directory}/dangling-symlink"
|
298
|
+
)
|
299
|
+
input = <<-END
|
300
|
+
resource dangling-symlink
|
301
|
+
config default
|
302
|
+
set TEST_FILE=@/dangling-symlink
|
303
|
+
end
|
304
|
+
END
|
305
|
+
fig(
|
306
|
+
%w<--publish dependency/1.2.3>,
|
307
|
+
input,
|
308
|
+
:current_directory => publish_from_directory
|
309
|
+
)
|
310
|
+
|
311
|
+
FileUtils.rm_rf(publish_from_directory)
|
312
|
+
FileUtils.mkdir_p(publish_from_directory)
|
313
|
+
|
314
|
+
input = <<-END
|
315
|
+
retrieve TEST_FILE->.
|
316
|
+
config default
|
317
|
+
include dependency/1.2.3
|
318
|
+
end
|
319
|
+
END
|
320
|
+
fig(
|
321
|
+
%w<--publish dependent/1.2.3>,
|
322
|
+
input,
|
323
|
+
:current_directory => publish_from_directory
|
324
|
+
)
|
325
|
+
|
326
|
+
FileUtils.rm_rf(FIG_HOME)
|
327
|
+
|
328
|
+
File.exist?("#{CURRENT_DIRECTORY}/dangling-symlink") and
|
329
|
+
fail 'Symlink should not exist prior to using package.'
|
330
|
+
|
331
|
+
fig(%w<--update dependent/1.2.3 -- echo>)
|
332
|
+
File.symlink?("#{CURRENT_DIRECTORY}/dangling-symlink") or
|
333
|
+
fail 'Symlink should exist after using package.'
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
describe 'cleanup' do
|
338
|
+
let(:cleanup_dependency_basename) { 'from-dependency.txt' }
|
339
|
+
let(:cleanup_dependency_file) {
|
340
|
+
"#{CURRENT_DIRECTORY}/#{cleanup_dependency_basename}"
|
341
|
+
}
|
342
|
+
|
343
|
+
before(:each) do
|
344
|
+
FileUtils.rm_rf(publish_from_directory)
|
345
|
+
FileUtils.mkdir_p(publish_from_directory)
|
346
|
+
|
347
|
+
FileUtils.touch "#{publish_from_directory}/#{cleanup_dependency_basename}"
|
348
|
+
input = <<-END
|
349
|
+
resource #{cleanup_dependency_basename}
|
350
|
+
config default
|
351
|
+
set TEST_FILE=@/#{cleanup_dependency_basename}
|
352
|
+
end
|
353
|
+
END
|
354
|
+
fig(
|
355
|
+
%w<--publish dependency/1.2.3>,
|
356
|
+
input,
|
357
|
+
:current_directory => publish_from_directory
|
358
|
+
)
|
359
|
+
|
360
|
+
FileUtils.rm_rf(publish_from_directory)
|
361
|
+
FileUtils.mkdir_p(publish_from_directory)
|
362
|
+
|
363
|
+
input = <<-END
|
364
|
+
retrieve TEST_FILE->.
|
365
|
+
config default
|
366
|
+
include dependency/1.2.3
|
367
|
+
end
|
368
|
+
END
|
369
|
+
fig(
|
370
|
+
%w<--publish alpha/1.2.3>,
|
371
|
+
input,
|
372
|
+
:current_directory => publish_from_directory
|
373
|
+
)
|
374
|
+
fig(
|
375
|
+
%w<
|
376
|
+
--publish beta/1.2.3
|
377
|
+
--no-file
|
378
|
+
--set set_something=so-we-have-some-content
|
379
|
+
>
|
380
|
+
)
|
381
|
+
|
382
|
+
File.exist?(cleanup_dependency_file) and
|
383
|
+
fail 'File should not exist prior to using alpha.'
|
384
|
+
|
385
|
+
fig(%w<--update alpha/1.2.3 -- echo>)
|
386
|
+
File.exist?(cleanup_dependency_file) or
|
387
|
+
fail 'File should exist after using alpha.'
|
388
|
+
end
|
389
|
+
|
390
|
+
it 'happens with --update' do
|
391
|
+
fig(%w<--update beta/1.2.3 -- echo>)
|
392
|
+
File.exist?(cleanup_dependency_file) and
|
393
|
+
fail 'File should not exist after using beta.'
|
394
|
+
end
|
395
|
+
|
396
|
+
it 'does not happen with --update and --suppress-cleanup-of-retrieves' do
|
397
|
+
fig(%w<--update --suppress-cleanup-of-retrieves beta/1.2.3 -- echo>)
|
398
|
+
File.exist?(cleanup_dependency_file) or
|
399
|
+
fail 'File should exist after using beta.'
|
400
|
+
end
|
401
|
+
|
402
|
+
it 'does not happen without --update' do
|
403
|
+
fig(%w<beta/1.2.3 -- echo>)
|
404
|
+
File.exist?(cleanup_dependency_file) or
|
405
|
+
fail 'File should exist after using beta.'
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
it 'warns on unused retrieval' do
|
410
|
+
set_up_test_environment()
|
411
|
+
|
412
|
+
input = <<-END
|
413
|
+
retrieve UNREFERENCED_VARIABLE->somewhere
|
414
|
+
config default
|
415
|
+
set WHATEVER=SOMETHING
|
416
|
+
end
|
417
|
+
END
|
418
|
+
out, err, exit_code = fig(%w<--update-if-missing>, input)
|
419
|
+
|
420
|
+
err.should =~ /UNREFERENCED_VARIABLE.*was never referenced.*retrieve UNREFERENCED_VARIABLE->somewhere.*was ignored/
|
421
|
+
end
|
422
|
+
end
|
423
|
+
end
|