reapack-index 1.0beta4 → 1.0rc2
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/README.md +5 -3
- data/lib/reapack/index.rb +31 -130
- data/lib/reapack/index/cdetector.rb +33 -19
- data/lib/reapack/index/cli.rb +12 -6
- data/lib/reapack/index/cli/options.rb +7 -1
- data/lib/reapack/index/gem_version.rb +1 -1
- data/lib/reapack/index/git.rb +5 -1
- data/lib/reapack/index/provides.rb +8 -4
- data/lib/reapack/index/scanner.rb +129 -0
- data/lib/reapack/index/source.rb +9 -3
- data/lib/reapack/index/version.rb +1 -1
- data/reapack-index.gemspec +2 -1
- data/setup/reapack-index.nsi +15 -2
- data/test/cli/test_check.rb +25 -19
- data/test/cli/test_scan.rb +59 -1
- data/test/data/index.xml +5 -2
- data/test/index/test_provides.rb +64 -10
- data/test/index/test_scan.rb +24 -84
- data/test/test_cdetector.rb +121 -72
- data/test/test_cli.rb +6 -0
- data/test/test_git.rb +6 -0
- data/test/test_index.rb +89 -57
- data/test/test_provides.rb +21 -10
- data/test/test_scanner.rb +191 -0
- data/test/test_source.rb +37 -8
- data/test/test_version.rb +3 -4
- metadata +21 -6
- data/test/data/noindex.lua +0 -1
data/test/data/index.xml
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<index version="1" commit="f572d396fae9206628714fb2ce00f72e94f2258f">
|
2
|
+
<index version="1" commit="f572d396fae9206628714fb2ce00f72e94f2258f" name="Test">
|
3
3
|
<category name="Category Name">
|
4
4
|
<reapack name="Hello World.lua" type="script">
|
5
5
|
<version name="1.0" author="cfillion">
|
6
6
|
<changelog><![CDATA[Fixed a division by zero error.]]></changelog>
|
7
|
-
<source
|
7
|
+
<source>https://google.com/Category%20Name/Hello%20World.lua</source>
|
8
8
|
</version>
|
9
9
|
</reapack>
|
10
10
|
</category>
|
11
|
+
<description>
|
12
|
+
<link>https://github.com/cfillion/reapack-index</link>
|
13
|
+
</description>
|
11
14
|
</index>
|
data/test/index/test_provides.rb
CHANGED
@@ -7,7 +7,7 @@ class TestIndex::Provides < MiniTest::Test
|
|
7
7
|
|
8
8
|
def test_simple
|
9
9
|
index = ReaPack::Index.new @dummy_path
|
10
|
-
index.url_template = 'http://host/$path'
|
10
|
+
index.url_template = 'http://host/$path?$package'
|
11
11
|
|
12
12
|
index.files = [
|
13
13
|
'Category/script.lua',
|
@@ -28,9 +28,9 @@ class TestIndex::Provides < MiniTest::Test
|
|
28
28
|
<category name="Category">
|
29
29
|
<reapack name="script.lua" type="script">
|
30
30
|
<version name="1.0">
|
31
|
-
<source
|
32
|
-
<source platform="windows" file="../Resources/unicode.dat">http://host/Resources/unicode.dat</source>
|
33
|
-
<source
|
31
|
+
<source main="true">http://host/Category/script.lua?Category/script.lua</source>
|
32
|
+
<source platform="windows" file="../Resources/unicode.dat">http://host/Resources/unicode.dat?Category/script.lua</source>
|
33
|
+
<source file="test.png">http://host/Category/test.png?Category/script.lua</source>
|
34
34
|
</version>
|
35
35
|
</reapack>
|
36
36
|
</category>
|
@@ -75,8 +75,8 @@ class TestIndex::Provides < MiniTest::Test
|
|
75
75
|
<category name="Category">
|
76
76
|
<reapack name="script.lua" type="script">
|
77
77
|
<version name="1.0">
|
78
|
-
<source platform="darwin">http://host/Category/script.lua</source>
|
79
|
-
<source platform="win64">http://host/Category/script.lua</source>
|
78
|
+
<source main="true" platform="darwin">http://host/Category/script.lua</source>
|
79
|
+
<source main="true" platform="win64">http://host/Category/script.lua</source>
|
80
80
|
</version>
|
81
81
|
</reapack>
|
82
82
|
</category>
|
@@ -142,7 +142,7 @@ class TestIndex::Provides < MiniTest::Test
|
|
142
142
|
index.scan index.files.first, <<-IN
|
143
143
|
@version 1.0
|
144
144
|
@provides
|
145
|
-
[windows] Data
|
145
|
+
[windows] Data/{a,b}.*
|
146
146
|
test*
|
147
147
|
IN
|
148
148
|
|
@@ -152,10 +152,10 @@ class TestIndex::Provides < MiniTest::Test
|
|
152
152
|
<category name="Category">
|
153
153
|
<reapack name="script.lua" type="script">
|
154
154
|
<version name="1.0">
|
155
|
-
<source
|
155
|
+
<source main="true">http://host/Category/script.lua</source>
|
156
156
|
<source platform="windows" file="Data/a.dat">http://host/Category/Data/a.dat</source>
|
157
157
|
<source platform="windows" file="Data/b.dat">http://host/Category/Data/b.dat</source>
|
158
|
-
<source
|
158
|
+
<source file="test.txt">http://host/Category/test.txt</source>
|
159
159
|
</version>
|
160
160
|
</reapack>
|
161
161
|
</category>
|
@@ -262,7 +262,7 @@ class TestIndex::Provides < MiniTest::Test
|
|
262
262
|
<category name="Other">
|
263
263
|
<reapack name="test1.lua" type="script">
|
264
264
|
<version name="1.0">
|
265
|
-
<source
|
265
|
+
<source file="background.png">http://irrelevant</source>
|
266
266
|
</version>
|
267
267
|
</reapack>
|
268
268
|
</category>
|
@@ -299,4 +299,58 @@ class TestIndex::Provides < MiniTest::Test
|
|
299
299
|
@provides file
|
300
300
|
IN
|
301
301
|
end
|
302
|
+
|
303
|
+
def test_main
|
304
|
+
index = ReaPack::Index.new @dummy_path
|
305
|
+
index.url_template = 'http://host/$path'
|
306
|
+
index.files = [
|
307
|
+
'Category/script.lua',
|
308
|
+
'Category/a.dat',
|
309
|
+
'Category/b.dat',
|
310
|
+
]
|
311
|
+
|
312
|
+
index.scan index.files.first, <<-IN
|
313
|
+
@version 1.0
|
314
|
+
@provides
|
315
|
+
[main] a.dat
|
316
|
+
[nomain] .
|
317
|
+
[nomain] b.dat
|
318
|
+
IN
|
319
|
+
|
320
|
+
expected = <<-XML
|
321
|
+
<?xml version="1.0" encoding="utf-8"?>
|
322
|
+
<index version="1">
|
323
|
+
<category name="Category">
|
324
|
+
<reapack name="script.lua" type="script">
|
325
|
+
<version name="1.0">
|
326
|
+
<source main="true" file="a.dat">http://host/Category/a.dat</source>
|
327
|
+
<source>http://host/Category/script.lua</source>
|
328
|
+
<source file="b.dat">http://host/Category/b.dat</source>
|
329
|
+
</version>
|
330
|
+
</reapack>
|
331
|
+
</category>
|
332
|
+
</index>
|
333
|
+
XML
|
334
|
+
|
335
|
+
index.write!
|
336
|
+
assert_equal expected, File.read(index.path)
|
337
|
+
end
|
338
|
+
|
339
|
+
def test_main_self
|
340
|
+
index = ReaPack::Index.new @dummy_path
|
341
|
+
index.url_template = 'http://host/$path'
|
342
|
+
index.files = [
|
343
|
+
'Category/script.lua',
|
344
|
+
'Category/a.dat',
|
345
|
+
'Category/b.dat',
|
346
|
+
]
|
347
|
+
|
348
|
+
index.scan index.files.first, <<-IN
|
349
|
+
@version 1.0
|
350
|
+
@provides .
|
351
|
+
IN
|
352
|
+
|
353
|
+
index.write!
|
354
|
+
assert_match 'main="true"', File.read(index.path)
|
355
|
+
end
|
302
356
|
end
|
data/test/index/test_scan.rb
CHANGED
@@ -44,7 +44,7 @@ class TestIndex::Scan < MiniTest::Test
|
|
44
44
|
<reapack name="Instrument Track.lua" type="script">
|
45
45
|
<version name="1.0">
|
46
46
|
<changelog><![CDATA[Hello World]]></changelog>
|
47
|
-
<source
|
47
|
+
<source main="true">http://host/Category/Path/Instrument%20Track.lua</source>
|
48
48
|
</version>
|
49
49
|
</reapack>
|
50
50
|
</category>
|
@@ -109,22 +109,11 @@ class TestIndex::Scan < MiniTest::Test
|
|
109
109
|
assert index.modified?, 'index is not modified'
|
110
110
|
assert_equal '1 modified package, 1 modified version', index.changelog
|
111
111
|
|
112
|
-
expected = <<-XML
|
113
|
-
<?xml version="1.0" encoding="utf-8"?>
|
114
|
-
<index version="1" commit="#{@commit}">
|
115
|
-
<category name="Category Name">
|
116
|
-
<reapack name="Hello World.lua" type="script">
|
117
|
-
<version name="1.0">
|
118
|
-
<changelog><![CDATA[New Changelog!]]></changelog>
|
119
|
-
<source platform="all">http://google.com/Category%20Name/Hello%20World.lua</source>
|
120
|
-
</version>
|
121
|
-
</reapack>
|
122
|
-
</category>
|
123
|
-
</index>
|
124
|
-
XML
|
125
|
-
|
126
112
|
index.write @dummy_path
|
127
|
-
|
113
|
+
contents = File.read @dummy_path
|
114
|
+
|
115
|
+
assert_match @commit, contents
|
116
|
+
assert_match 'New Changelog!', contents
|
128
117
|
end
|
129
118
|
|
130
119
|
def test_edit_version_amend_unmodified
|
@@ -144,33 +133,6 @@ class TestIndex::Scan < MiniTest::Test
|
|
144
133
|
assert_empty index.changelog
|
145
134
|
end
|
146
135
|
|
147
|
-
def test_missing_version
|
148
|
-
index = ReaPack::Index.new @dummy_path
|
149
|
-
index.url_template = 'http://host/$path'
|
150
|
-
index.files = ['cat/test.lua']
|
151
|
-
|
152
|
-
error = assert_raises ReaPack::Index::Error do
|
153
|
-
index.scan index.files.first, 'no version tag here'
|
154
|
-
end
|
155
|
-
|
156
|
-
assert_equal "missing tag 'version'", error.message
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_empty_changelog
|
160
|
-
index = ReaPack::Index.new @dummy_path
|
161
|
-
index.url_template = 'http://host/$path'
|
162
|
-
index.files = ['cat/test.lua']
|
163
|
-
|
164
|
-
error = assert_raises ReaPack::Index::Error do
|
165
|
-
index.scan index.files.first, <<-IN
|
166
|
-
@version 1.0
|
167
|
-
@changelog
|
168
|
-
IN
|
169
|
-
end
|
170
|
-
|
171
|
-
assert_equal "missing value for tag 'changelog'", error.message
|
172
|
-
end
|
173
|
-
|
174
136
|
def test_author
|
175
137
|
index = ReaPack::Index.new @dummy_path
|
176
138
|
index.url_template = 'http://host/$path'
|
@@ -185,38 +147,6 @@ class TestIndex::Scan < MiniTest::Test
|
|
185
147
|
assert_match '<version name="1.0" author="cfillion">', File.read(index.path)
|
186
148
|
end
|
187
149
|
|
188
|
-
def test_author_boolean
|
189
|
-
index = ReaPack::Index.new @dummy_path
|
190
|
-
index.url_template = 'http://host/$path'
|
191
|
-
index.files = ['cat/test.lua']
|
192
|
-
|
193
|
-
error = assert_raises ReaPack::Index::Error do
|
194
|
-
index.scan index.files.first, <<-IN
|
195
|
-
@version 1.0
|
196
|
-
@author
|
197
|
-
IN
|
198
|
-
end
|
199
|
-
|
200
|
-
assert_equal "missing value for tag 'author'", error.message
|
201
|
-
end
|
202
|
-
|
203
|
-
def test_author_multiline
|
204
|
-
index = ReaPack::Index.new @dummy_path
|
205
|
-
index.url_template = 'http://host/$path'
|
206
|
-
index.files = ['cat/test.lua']
|
207
|
-
|
208
|
-
error = assert_raises ReaPack::Index::Error do
|
209
|
-
index.scan index.files.first, <<-IN
|
210
|
-
@version 1.0
|
211
|
-
@author
|
212
|
-
hello
|
213
|
-
world
|
214
|
-
IN
|
215
|
-
end
|
216
|
-
|
217
|
-
assert_equal "tag 'author' must be singleline", error.message
|
218
|
-
end
|
219
|
-
|
220
150
|
def test_noindex
|
221
151
|
index = ReaPack::Index.new @real_path
|
222
152
|
|
@@ -234,13 +164,23 @@ class TestIndex::Scan < MiniTest::Test
|
|
234
164
|
assert_equal true, index.modified?
|
235
165
|
assert_equal '1 removed package', index.changelog
|
236
166
|
|
237
|
-
expected = <<-XML
|
238
|
-
<?xml version="1.0" encoding="utf-8"?>
|
239
|
-
<index version="1" commit="#{@commit}"/>
|
240
|
-
XML
|
241
|
-
|
242
167
|
index.write @dummy_path
|
243
|
-
|
168
|
+
contents = File.read @dummy_path
|
169
|
+
|
170
|
+
assert_match @commit, contents
|
171
|
+
refute_match '<category', contents
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_metapackage
|
175
|
+
index = ReaPack::Index.new @dummy_path
|
176
|
+
index.url_template = 'http://host/$path'
|
177
|
+
index.files = ['Category/script.lua', 'Category/test']
|
178
|
+
|
179
|
+
error = assert_raises ReaPack::Index::Error do
|
180
|
+
index.scan index.files.first, "@version 1.0\n@metapackage"
|
181
|
+
end
|
182
|
+
|
183
|
+
assert_equal 'no files provided', error.message
|
244
184
|
end
|
245
185
|
|
246
186
|
def test_version_time
|
@@ -272,7 +212,7 @@ class TestIndex::Scan < MiniTest::Test
|
|
272
212
|
<category name="Extensions">
|
273
213
|
<reapack name="reapack.ext" type="extension">
|
274
214
|
<version name="1.0">
|
275
|
-
<source
|
215
|
+
<source file="reaper_reapack.so">http://example.com/reaper_reapack.so</source>
|
276
216
|
</version>
|
277
217
|
</reapack>
|
278
218
|
</category>
|
@@ -296,7 +236,7 @@ class TestIndex::Scan < MiniTest::Test
|
|
296
236
|
<category name="Dynamics">
|
297
237
|
<reapack name="super_compressor.jsfx" type="effect">
|
298
238
|
<version name="1.0">
|
299
|
-
<source
|
239
|
+
<source main="true">http://host/Dynamics/super_compressor.jsfx</source>
|
300
240
|
</version>
|
301
241
|
</reapack>
|
302
242
|
</category>
|
@@ -320,7 +260,7 @@ class TestIndex::Scan < MiniTest::Test
|
|
320
260
|
<category name="Grooves">
|
321
261
|
<reapack name="sws.data" type="data">
|
322
262
|
<version name="1.0">
|
323
|
-
<source
|
263
|
+
<source file="sws/test.mid">http://host/Grooves/sws/test.mid</source>
|
324
264
|
</version>
|
325
265
|
</reapack>
|
326
266
|
</category>
|
data/test/test_cdetector.rb
CHANGED
@@ -3,94 +3,98 @@ class TestConflictDetector < MiniTest::Test
|
|
3
3
|
|
4
4
|
def test_unique
|
5
5
|
cd = ReaPack::Index::ConflictDetector.new
|
6
|
-
cd['
|
7
|
-
cd['
|
6
|
+
cd['pkg'].push :grp, :all, 'file1.lua'
|
7
|
+
cd['pkg'].push :grp, :all, 'file2.lua'
|
8
8
|
|
9
|
-
assert_nil cd
|
10
|
-
assert_nil cd.resolve(
|
9
|
+
assert_nil cd['pkg'].resolve
|
10
|
+
assert_nil cd.resolve(:grp, 'pkg')
|
11
|
+
assert_nil cd.resolve(:grp)
|
11
12
|
end
|
12
13
|
|
13
14
|
def test_duplicates
|
14
15
|
cd = ReaPack::Index::ConflictDetector.new
|
15
|
-
cd['
|
16
|
-
cd['
|
17
|
-
cd['
|
18
|
-
cd['
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
cd['pkg'].push :grp, :all, 'file1.lua'
|
17
|
+
cd['pkg'].push :grp, :all, 'file1.lua'
|
18
|
+
cd['pkg'].push :grp, :all, 'file2.lua'
|
19
|
+
cd['pkg'].push :grp, :all, 'file2.lua'
|
20
|
+
|
21
|
+
expected = ["duplicate file 'file1.lua'", "duplicate file 'file2.lua'"]
|
22
|
+
assert_equal expected, cd['pkg'].resolve
|
23
|
+
assert_equal expected, cd.resolve(:grp, 'pkg')
|
24
|
+
assert_equal expected, cd.resolve(:grp)
|
22
25
|
end
|
23
26
|
|
24
27
|
def test_same_platform
|
25
28
|
cd = ReaPack::Index::ConflictDetector.new
|
26
|
-
cd['
|
27
|
-
cd['
|
29
|
+
cd['test'].push :grp, :windows, 'file.lua'
|
30
|
+
cd['test'].push :grp, :windows, 'file.lua'
|
28
31
|
|
29
|
-
assert_equal ["duplicate file 'file.lua' on windows"], cd.resolve(
|
30
|
-
assert_nil cd.resolve(
|
32
|
+
assert_equal ["duplicate file 'file.lua' on windows"], cd.resolve(:grp)
|
33
|
+
assert_nil cd.resolve(:other_bucket)
|
31
34
|
end
|
32
35
|
|
33
36
|
def test_unmatching_platform
|
34
37
|
cd = ReaPack::Index::ConflictDetector.new
|
35
|
-
cd['
|
36
|
-
cd['
|
38
|
+
cd['test'].push :grp, :darwin, 'file.lua'
|
39
|
+
cd['test'].push :grp, :windows, 'file.lua'
|
37
40
|
|
38
|
-
assert_nil cd.resolve(
|
41
|
+
assert_nil cd.resolve(:grp)
|
39
42
|
end
|
40
43
|
|
41
44
|
def test_subplatform
|
42
45
|
cd = ReaPack::Index::ConflictDetector.new
|
43
|
-
cd['
|
44
|
-
cd['
|
46
|
+
cd['test'].push :grp, :all, 'file.lua'
|
47
|
+
cd['test'].push :grp, :windows, 'file.lua'
|
45
48
|
|
46
|
-
assert_equal ["duplicate file 'file.lua' on windows"], cd.resolve(
|
49
|
+
assert_equal ["duplicate file 'file.lua' on windows"], cd.resolve(:grp)
|
47
50
|
end
|
48
51
|
|
49
52
|
def test_subsubplatform
|
50
53
|
cd = ReaPack::Index::ConflictDetector.new
|
51
|
-
cd['
|
52
|
-
cd['
|
54
|
+
cd['test'].push :grp, :all, 'file.lua'
|
55
|
+
cd['test'].push :grp, :win32, 'file.lua'
|
53
56
|
|
54
|
-
assert_equal ["duplicate file 'file.lua' on win32"], cd.resolve(
|
57
|
+
assert_equal ["duplicate file 'file.lua' on win32"], cd.resolve(:grp)
|
55
58
|
end
|
56
59
|
|
57
60
|
def test_conflicts
|
58
61
|
cd = ReaPack::Index::ConflictDetector.new
|
59
|
-
cd['
|
62
|
+
cd['package1.lua'].push :grp, :all, 'file1.lua'
|
60
63
|
|
61
|
-
cd['
|
62
|
-
cd['
|
64
|
+
cd['package2.lua'].push :grp, :all, 'file1.lua'
|
65
|
+
cd['package2.lua'].push :grp, :all, 'file2.lua'
|
63
66
|
|
64
|
-
cd['
|
67
|
+
cd['package3.lua'].push :grp, :windows, 'file2.lua'
|
65
68
|
|
66
|
-
cd['
|
69
|
+
cd['package4.lua'].push :grp, :darwin, 'file1.lua'
|
67
70
|
|
68
|
-
assert_nil cd.resolve(
|
71
|
+
assert_nil cd.resolve(:grp, 'not_specified.lua'), 'id = not_specified'
|
69
72
|
|
70
73
|
assert_equal ["'file1.lua' conflicts with 'package2.lua'"],
|
71
|
-
cd.resolve(
|
74
|
+
cd.resolve(:grp, 'package1.lua'), 'id = package1'
|
75
|
+
assert_equal cd.resolve(:grp, 'package1.lua'), cd['package1.lua'].resolve
|
72
76
|
|
73
77
|
assert_equal ["'file1.lua' conflicts with 'package1.lua'",
|
74
78
|
"'file2.lua' conflicts with 'package3.lua' on windows"],
|
75
|
-
cd.resolve(
|
79
|
+
cd.resolve(:grp, 'package2.lua'), 'id = package2'
|
76
80
|
|
77
81
|
assert_equal ["'file2.lua' conflicts with 'package2.lua'"],
|
78
|
-
cd.resolve(
|
82
|
+
cd.resolve(:grp, 'package3.lua'), 'id = package3'
|
79
83
|
|
80
84
|
# this conflict might happen on every platform,
|
81
85
|
# so it should not be reported it as darwin-only
|
82
86
|
assert_equal ["'file1.lua' conflicts with 'package1.lua'"],
|
83
|
-
cd.resolve(
|
87
|
+
cd.resolve(:grp, 'package4.lua'), 'id = package4'
|
84
88
|
end
|
85
89
|
|
86
90
|
def test_conflicts_bidirectional
|
87
91
|
cd1 = ReaPack::Index::ConflictDetector.new
|
88
92
|
|
89
|
-
a1 = cd1['
|
90
|
-
a1.push :all, 'file.lua'
|
93
|
+
a1 = cd1['a']
|
94
|
+
a1.push :grp, :all, 'file.lua'
|
91
95
|
|
92
|
-
b1 = cd1['
|
93
|
-
b1.push :windows, 'file.lua'
|
96
|
+
b1 = cd1['b']
|
97
|
+
b1.push :grp, :windows, 'file.lua'
|
94
98
|
|
95
99
|
assert_equal ["'file.lua' conflicts with 'b' on windows"],
|
96
100
|
a1.resolve, 'id = a'
|
@@ -98,73 +102,90 @@ class TestConflictDetector < MiniTest::Test
|
|
98
102
|
b1.resolve, 'id = b'
|
99
103
|
|
100
104
|
cd2 = ReaPack::Index::ConflictDetector.new
|
101
|
-
a2 = cd1['
|
102
|
-
a2.push :windows, 'file.lua'
|
105
|
+
a2 = cd1['a']
|
106
|
+
a2.push :grp, :windows, 'file.lua'
|
103
107
|
|
104
|
-
b2 = cd1['
|
105
|
-
b2.push :all, 'file.lua'
|
108
|
+
b2 = cd1['b']
|
109
|
+
b2.push :grp, :all, 'file.lua'
|
106
110
|
|
107
111
|
assert_equal a1.resolve, a2.resolve
|
108
112
|
assert_equal b1.resolve, b2.resolve
|
109
113
|
end
|
110
114
|
|
111
|
-
def
|
115
|
+
def test_platform_selection
|
112
116
|
cd1 = ReaPack::Index::ConflictDetector.new
|
113
|
-
cd1['
|
114
|
-
cd1['
|
115
|
-
cd1['
|
117
|
+
cd1['a'].push :grp1, :all, 'file.lua'
|
118
|
+
cd1['b'].push :grp1, :windows, 'file.lua'
|
119
|
+
cd1['c'].push :grp1, :win32, 'file.lua'
|
116
120
|
|
117
121
|
assert_equal ["'file.lua' conflicts with 'b' on windows"],
|
118
|
-
cd1.resolve(
|
122
|
+
cd1.resolve(:grp1, 'a'), 'id = a (grp1)'
|
123
|
+
|
124
|
+
cd1['a'].push :grp2, :all, 'file.lua'
|
125
|
+
cd1['b'].push :grp2, :darwin, 'file.lua'
|
126
|
+
cd1['c'].push :grp2, :win32, 'file.lua'
|
127
|
+
|
128
|
+
assert_equal ["'file.lua' conflicts with 'b' on darwin"],
|
129
|
+
cd1.resolve(:grp2, 'a'), 'id = a (grp2)'
|
119
130
|
end
|
120
131
|
|
121
132
|
def test_duplicate_platform_selection
|
122
133
|
cd = ReaPack::Index::ConflictDetector.new
|
123
|
-
cd['
|
124
|
-
cd['
|
125
|
-
assert_equal ["duplicate file 'file.lua' on windows"], cd.resolve(
|
134
|
+
cd['test'].push :grp, :windows, 'file.lua'
|
135
|
+
cd['test'].push :grp, :all, 'file.lua'
|
136
|
+
assert_equal ["duplicate file 'file.lua' on windows"], cd.resolve(:grp)
|
126
137
|
|
127
|
-
cd['
|
128
|
-
assert_equal ["duplicate file 'file.lua'"], cd.resolve(
|
138
|
+
cd['test'].push :grp, :all, 'file.lua'
|
139
|
+
assert_equal ["duplicate file 'file.lua'"], cd.resolve(:grp)
|
129
140
|
end
|
130
141
|
|
131
142
|
def test_platform_same_level
|
132
143
|
cd1 = ReaPack::Index::ConflictDetector.new
|
133
|
-
cd1['
|
134
|
-
cd1['
|
135
|
-
cd1['
|
144
|
+
cd1['test'].push :grp, :all, 'file.lua'
|
145
|
+
cd1['test'].push :grp, :win32, 'file.lua' # win32 first
|
146
|
+
cd1['test'].push :grp, :darwin32, 'file.lua'
|
136
147
|
|
137
|
-
assert_equal ["duplicate file 'file.lua' on win32"], cd1.resolve(
|
148
|
+
assert_equal ["duplicate file 'file.lua' on win32"], cd1.resolve(:grp)
|
138
149
|
|
139
150
|
cd2 = ReaPack::Index::ConflictDetector.new
|
140
|
-
cd2['
|
141
|
-
cd2['
|
142
|
-
cd2['
|
151
|
+
cd2['test'].push :grp, :all, 'file.lua'
|
152
|
+
cd2['test'].push :grp, :darwin32, 'file.lua' # darwin32 first
|
153
|
+
cd2['test'].push :grp, :win32, 'file.lua'
|
143
154
|
|
144
|
-
assert_equal cd1.resolve(
|
155
|
+
assert_equal cd1.resolve(:grp), cd2.resolve(:grp)
|
145
156
|
end
|
146
157
|
|
147
158
|
def test_remove_by_key
|
148
159
|
cd = ReaPack::Index::ConflictDetector.new
|
149
|
-
cd['
|
160
|
+
cd['test'].push :grp, :all, 'file'
|
150
161
|
|
151
|
-
cd['
|
152
|
-
cd['
|
162
|
+
cd['test'].clear
|
163
|
+
cd['test'].push :grp, :all, 'file'
|
153
164
|
|
154
|
-
assert_equal nil, cd.resolve(
|
165
|
+
assert_equal nil, cd.resolve(:grp, 'test')
|
155
166
|
end
|
156
167
|
|
157
168
|
def test_clone
|
158
169
|
cd1 = ReaPack::Index::ConflictDetector.new
|
159
|
-
cd1['
|
170
|
+
cd1['test'].push :grp, :all, 'file'
|
160
171
|
|
161
172
|
cd2 = cd1.clone
|
162
173
|
|
163
|
-
cd1['
|
164
|
-
assert_nil cd2.resolve(
|
174
|
+
cd1['test'].push :grp, :all, 'file'
|
175
|
+
assert_nil cd2.resolve(:grp)
|
176
|
+
|
177
|
+
cd2['test'].push :grp, :all, 'file'
|
178
|
+
refute_nil cd2.resolve(:grp)
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_clear
|
182
|
+
cd = ReaPack::Index::ConflictDetector.new
|
183
|
+
cd['test'].push :grp, :all, 'file'
|
184
|
+
|
185
|
+
cd.clear
|
186
|
+
cd['test'].push :grp, :all, 'file'
|
165
187
|
|
166
|
-
|
167
|
-
refute_nil cd2.resolve('grp')
|
188
|
+
assert_equal nil, cd.resolve(:grp, 'test')
|
168
189
|
end
|
169
190
|
|
170
191
|
def test_load_xml
|
@@ -194,6 +215,21 @@ class TestConflictDetector < MiniTest::Test
|
|
194
215
|
<source platform="all" file="../Other/test1.lua">http://cross/category</source>
|
195
216
|
</version>
|
196
217
|
</reapack>
|
218
|
+
<reapack name="no_platform.lua" type="script">
|
219
|
+
<version name="1.0">
|
220
|
+
<source file="picture">http://cross/category</source>
|
221
|
+
</version>
|
222
|
+
</reapack>
|
223
|
+
<reapack name="weird_platform.lua" type="script">
|
224
|
+
<version name="1.0">
|
225
|
+
<source platform="bacon" file="picture">http://cross/category</source>
|
226
|
+
</version>
|
227
|
+
</reapack>
|
228
|
+
<reapack name="explicit_type.lua" type="script">
|
229
|
+
<version name="1.0">
|
230
|
+
<source type="effect" file="picture">http://cross/category</source>
|
231
|
+
</version>
|
232
|
+
</reapack>
|
197
233
|
</category>
|
198
234
|
</index>
|
199
235
|
XML
|
@@ -203,12 +239,25 @@ class TestConflictDetector < MiniTest::Test
|
|
203
239
|
|
204
240
|
assert_equal ["'Other/test1.lua' conflicts with 'Other/test2.lua'",
|
205
241
|
"duplicate file 'Other/background.png' on win32"],
|
206
|
-
cd
|
242
|
+
cd['Other/test1.lua'].resolve, 'test1'
|
207
243
|
|
208
244
|
assert_equal ["'Other/test1.lua' conflicts with 'Other/test1.lua'"],
|
209
|
-
cd
|
245
|
+
cd['Other/test2.lua'].resolve, 'test2'
|
210
246
|
|
211
247
|
assert_equal ["'Other/test1.lua' conflicts with 'Other/test1.lua'"],
|
212
|
-
cd
|
248
|
+
cd['Scripts/test3.lua'].resolve, 'test3'
|
249
|
+
|
250
|
+
cd['Scripts/no_platform.lua'].resolve
|
251
|
+
cd['Scripts/weird_platform.lua'].resolve
|
252
|
+
|
253
|
+
assert_nil cd['Scripts/explicit_type.lua'].resolve
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_unknown_platform
|
257
|
+
cd = ReaPack::Index::ConflictDetector.new
|
258
|
+
cd['test1'].push :grp, :unknown, 'file'
|
259
|
+
cd['test2'].push :grp, :all, 'file'
|
260
|
+
|
261
|
+
assert_equal ["'file' conflicts with 'test2'"], cd['test1'].resolve
|
213
262
|
end
|
214
263
|
end
|