reapack-index 1.0beta3 → 1.0beta4
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/.travis.yml +1 -1
- data/README.md +11 -113
- data/Rakefile +1 -1
- data/lib/reapack/index.rb +159 -109
- data/lib/reapack/index/cdetector.rb +120 -0
- data/lib/reapack/index/cli.rb +127 -161
- data/lib/reapack/index/cli/options.rb +29 -10
- data/lib/reapack/index/gem_version.rb +1 -1
- data/lib/reapack/index/git.rb +189 -0
- data/lib/reapack/index/metadata.rb +2 -2
- data/lib/reapack/index/named_node.rb +17 -12
- data/lib/reapack/index/package.rb +16 -9
- data/lib/reapack/index/provides.rb +46 -0
- data/lib/reapack/index/source.rb +59 -0
- data/lib/reapack/index/version.rb +3 -52
- data/reapack-index.gemspec +7 -6
- data/setup/reapack-index.nsi +9 -5
- data/test/cli/test_check.rb +190 -0
- data/test/cli/test_metadata.rb +194 -0
- data/test/cli/test_scan.rb +326 -0
- data/test/data/index.xml +1 -1
- data/test/helper.rb +90 -1
- data/test/index/test_metadata.rb +111 -0
- data/test/index/test_provides.rb +302 -0
- data/test/index/test_scan.rb +333 -0
- data/test/test_cdetector.rb +214 -0
- data/test/test_cli.rb +69 -797
- data/test/test_git.rb +139 -0
- data/test/test_index.rb +109 -703
- data/test/test_metadata.rb +2 -2
- data/test/test_named_node.rb +50 -42
- data/test/test_package.rb +15 -26
- data/test/test_provides.rb +68 -0
- data/test/test_source.rb +115 -0
- data/test/test_version.rb +10 -63
- metadata +33 -22
data/test/test_git.rb
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.expand_path '../helper', __FILE__
|
2
|
+
|
3
|
+
class TestGit < MiniTest::Test
|
4
|
+
include GitHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@path, @repo = init_git
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
FileUtils.rm_r @path
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_path
|
15
|
+
realpath = Pathname.new(@path).realpath
|
16
|
+
assert_equal realpath.to_s, @git.path
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_relative_path
|
20
|
+
assert_equal 'test', @git.relative_path(File.join(@git.path, 'test'))
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_guess_url_template
|
24
|
+
assert_nil @git.guess_url_template
|
25
|
+
|
26
|
+
@repo.remotes.create 'origin', 'git@github.com:User/Repo.git'
|
27
|
+
assert_match "https://github.com/User/Repo/raw/$commit/$path",
|
28
|
+
@git.guess_url_template
|
29
|
+
|
30
|
+
@repo.remotes.set_url 'origin', 'https://github.com/User/Repo.git'
|
31
|
+
assert_match "https://github.com/User/Repo/raw/$commit/$path",
|
32
|
+
@git.guess_url_template
|
33
|
+
|
34
|
+
@repo.remotes.set_url 'origin', 'scp://weird/url'
|
35
|
+
assert_nil @git.guess_url_template
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_create_initial_commit
|
39
|
+
index = @repo.index
|
40
|
+
index.add @git.relative_path(mkfile('ignored_staged'))
|
41
|
+
index.write
|
42
|
+
|
43
|
+
mkfile 'ignored'
|
44
|
+
|
45
|
+
assert_equal true, @git.empty?
|
46
|
+
commit = @git.create_commit 'initial commit', [mkfile('file')]
|
47
|
+
assert_equal false, @git.empty?
|
48
|
+
|
49
|
+
assert_equal commit, @git.last_commit
|
50
|
+
assert_equal 'initial commit', commit.message
|
51
|
+
assert_equal ['file'], commit.each_diff.map {|d| d.file }
|
52
|
+
assert_equal ['file'], commit.filelist
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_create_subsequent_commit
|
56
|
+
initial = @git.create_commit 'initial commit', [mkfile('file1')]
|
57
|
+
|
58
|
+
mkfile 'ignored'
|
59
|
+
|
60
|
+
index = @repo.index
|
61
|
+
index.add @git.relative_path(mkfile('ignored_staged'))
|
62
|
+
index.write
|
63
|
+
|
64
|
+
commit = @git.create_commit 'second commit', [mkfile('file2')]
|
65
|
+
refute_equal initial, commit
|
66
|
+
assert_equal 'second commit', commit.message
|
67
|
+
assert_equal ['file2'], commit.each_diff.map {|d| d.file }
|
68
|
+
assert_equal ['file1', 'file2'], commit.filelist
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_commit_info
|
72
|
+
commit = @git.create_commit "initial commit\ndescription", [mkfile('file')]
|
73
|
+
assert_equal "initial commit\ndescription", commit.message
|
74
|
+
assert_equal 'initial commit', commit.summary
|
75
|
+
|
76
|
+
assert commit.id.start_with?(commit.short_id)
|
77
|
+
assert_equal 7, commit.short_id.size
|
78
|
+
|
79
|
+
assert_kind_of Time, commit.time
|
80
|
+
assert_equal ['file'], commit.filelist
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_diff
|
84
|
+
hash = proc {|c|
|
85
|
+
c.each_diff.map {|d| [d.status, d.file, d.new_content] }
|
86
|
+
}
|
87
|
+
|
88
|
+
c1 = @git.create_commit 'initial commit', [mkfile('file1', 'initial')]
|
89
|
+
assert_equal [[:added, 'file1', 'initial']], hash[c1]
|
90
|
+
|
91
|
+
c2 = @git.create_commit 'second commit',
|
92
|
+
[mkfile('file1', 'second'), mkfile('file2')]
|
93
|
+
assert_equal [[:modified, 'file1', 'second'], [:added, 'file2', '']], hash[c2]
|
94
|
+
|
95
|
+
file1 = File.join @git.path, 'file1'
|
96
|
+
File.delete file1
|
97
|
+
c3 = @git.create_commit 'second commit', [file1]
|
98
|
+
assert_equal [[:deleted, 'file1', nil]], hash[c3]
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_commits_since
|
102
|
+
assert_equal [], @git.commits_since(nil)
|
103
|
+
c1 = @git.create_commit 'first', []
|
104
|
+
|
105
|
+
assert_equal [c1], @git.commits_since(nil)
|
106
|
+
assert_equal [], @git.commits_since(c1.id)
|
107
|
+
|
108
|
+
c2 = @git.create_commit 'second', []
|
109
|
+
assert_equal [c1, c2], @git.commits_since(nil)
|
110
|
+
assert_equal [c2], @git.commits_since(c1.id)
|
111
|
+
|
112
|
+
INVALID_HASHES.each {|hash|
|
113
|
+
assert_equal [c1, c2], @git.commits_since(hash)
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_get_commit
|
118
|
+
c = @git.create_commit 'first', []
|
119
|
+
assert_equal c, @git.get_commit(c.id)
|
120
|
+
|
121
|
+
INVALID_HASHES.each {|hash|
|
122
|
+
assert_nil @git.get_commit(hash)
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_multibyte_filename
|
127
|
+
filename = "\342\200\224.lua"
|
128
|
+
|
129
|
+
@git.create_commit 'initial commit', [mkfile(filename)]
|
130
|
+
assert_equal filename, @git.last_commit.each_diff.first.file
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_invalid_char_sequence
|
134
|
+
content = "\x97"
|
135
|
+
@git.create_commit 'initial commit', [mkfile('test.lua', content)]
|
136
|
+
|
137
|
+
assert_equal content, @git.last_commit.each_diff.first.new_content
|
138
|
+
end
|
139
|
+
end
|
data/test/test_index.rb
CHANGED
@@ -1,22 +1,42 @@
|
|
1
1
|
require File.expand_path '../helper', __FILE__
|
2
2
|
|
3
3
|
class TestIndex < MiniTest::Test
|
4
|
-
|
5
|
-
@real_path = File.expand_path '../data/index.xml', __FILE__
|
6
|
-
@dummy_path = Dir::Tmpname.create('index.xml') {|path| path }
|
4
|
+
include IndexHelper
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
File.delete @dummy_path if File.exist? @dummy_path
|
6
|
+
def test_is_type
|
7
|
+
assert_equal [false, true, true, false],
|
8
|
+
[nil, 'script', :script, :hello].map {|t| ReaPack::Index.is_type? t }
|
13
9
|
end
|
14
10
|
|
15
11
|
def test_type_of
|
16
|
-
|
12
|
+
assert_equal [nil, nil, nil, :script, :script, :extension, :effect, :data],
|
13
|
+
[
|
14
|
+
'src/main.cpp', 'src/noext', 'in_root',
|
15
|
+
'Cat/test.lua', 'Cat/test.eel',
|
16
|
+
'Cat/test.ext',
|
17
|
+
'Cat/test.jsfx',
|
18
|
+
'Cat/test.data',
|
19
|
+
].map {|fn| ReaPack::Index.type_of fn }
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_resolve_type
|
23
|
+
expected = [
|
24
|
+
nil,
|
25
|
+
:script, :script, :script,
|
26
|
+
:effect, :effect, :effect,
|
27
|
+
:extension, :extension,
|
28
|
+
:data,
|
29
|
+
]
|
30
|
+
|
31
|
+
actual = [
|
32
|
+
'hello',
|
33
|
+
:script, 'lua', 'eel',
|
34
|
+
'effect', :jsfx, 'jsfx',
|
35
|
+
'extension', 'ext',
|
36
|
+
'data',
|
37
|
+
].map {|fn| ReaPack::Index.resolve_type fn }
|
17
38
|
|
18
|
-
assert_equal
|
19
|
-
assert_equal :script, ReaPack::Index.type_of('Track/instrument_track.eel')
|
39
|
+
assert_equal expected, actual
|
20
40
|
end
|
21
41
|
|
22
42
|
def test_url_template
|
@@ -30,10 +50,10 @@ class TestIndex < MiniTest::Test
|
|
30
50
|
assert_equal 'https://google.com/$path', index.url_template
|
31
51
|
|
32
52
|
error = assert_raises ReaPack::Index::Error do
|
33
|
-
index.url_template = 'no path placeholder!
|
53
|
+
index.url_template = 'test' # no path placeholder!
|
34
54
|
end
|
35
55
|
|
36
|
-
assert_match
|
56
|
+
assert_match "missing $path placeholder in 'test'", error.message
|
37
57
|
assert_equal 'https://google.com/$path', index.url_template
|
38
58
|
|
39
59
|
index.url_template = nil
|
@@ -47,10 +67,10 @@ class TestIndex < MiniTest::Test
|
|
47
67
|
index.url_template = 'scp://cfillion.tk/$path'
|
48
68
|
end
|
49
69
|
|
50
|
-
assert_match /invalid
|
70
|
+
assert_match /invalid template/i, error.message
|
51
71
|
end
|
52
72
|
|
53
|
-
def
|
73
|
+
def test_file_list
|
54
74
|
index = ReaPack::Index.new @dummy_path
|
55
75
|
assert_empty index.files
|
56
76
|
|
@@ -58,20 +78,23 @@ class TestIndex < MiniTest::Test
|
|
58
78
|
assert_equal ['a', 'b/c'], index.files
|
59
79
|
end
|
60
80
|
|
61
|
-
def test_validate_standalone
|
62
|
-
refute_nil ReaPack::Index.validate_file @real_path # not a valid script
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_validate_noindex
|
66
|
-
assert_nil ReaPack::Index.validate_file \
|
67
|
-
File.expand_path '../data/noindex.lua', __FILE__
|
68
|
-
end
|
69
|
-
|
70
81
|
def test_read
|
71
82
|
index = ReaPack::Index.new @real_path
|
72
83
|
|
73
84
|
assert_equal 1, index.version
|
74
|
-
assert_equal
|
85
|
+
assert_equal 'f572d396fae9206628714fb2ce00f72e94f2258f', index.commit
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_read_invalid
|
89
|
+
File.write @dummy_path, "\33"
|
90
|
+
assert_raises ReaPack::Index::Error do
|
91
|
+
ReaPack::Index.new @dummy_path
|
92
|
+
end
|
93
|
+
|
94
|
+
File.write @dummy_path, "\0"
|
95
|
+
assert_raises ReaPack::Index::Error do
|
96
|
+
ReaPack::Index.new @dummy_path
|
97
|
+
end
|
75
98
|
end
|
76
99
|
|
77
100
|
def test_new
|
@@ -111,523 +134,73 @@ class TestIndex < MiniTest::Test
|
|
111
134
|
FileUtils.rm_r dirname if File.exist? dirname
|
112
135
|
end
|
113
136
|
|
114
|
-
def
|
115
|
-
index = ReaPack::Index.new @dummy_path
|
116
|
-
|
117
|
-
index.scan 'src/main.cpp', String.new
|
118
|
-
index.write!
|
119
|
-
|
120
|
-
expected = <<-XML
|
121
|
-
<?xml version="1.0" encoding="utf-8"?>
|
122
|
-
<index version="1"/>
|
123
|
-
XML
|
124
|
-
|
125
|
-
assert_equal expected, File.read(@dummy_path)
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_new_package
|
129
|
-
index = ReaPack::Index.new @dummy_path
|
130
|
-
index.files = ['Category/Path/Instrument Track.lua']
|
131
|
-
index.url_template = 'http://host/$path'
|
132
|
-
|
133
|
-
index.scan index.files.first, <<-IN
|
134
|
-
@version 1.0
|
135
|
-
@changelog Hello World
|
136
|
-
IN
|
137
|
-
|
138
|
-
assert_equal true, index.modified?
|
139
|
-
assert_equal '1 new category, 1 new package, 1 new version', index.changelog
|
140
|
-
|
141
|
-
index.write!
|
142
|
-
|
143
|
-
assert_equal false, index.modified?
|
144
|
-
assert_empty index.changelog
|
145
|
-
|
146
|
-
expected = <<-XML
|
147
|
-
<?xml version="1.0" encoding="utf-8"?>
|
148
|
-
<index version="1">
|
149
|
-
<category name="Category/Path">
|
150
|
-
<reapack name="Instrument Track.lua" type="script">
|
151
|
-
<version name="1.0">
|
152
|
-
<changelog><![CDATA[Hello World]]></changelog>
|
153
|
-
<source platform="all">http://host/Category/Path/Instrument%20Track.lua</source>
|
154
|
-
</version>
|
155
|
-
</reapack>
|
156
|
-
</category>
|
157
|
-
</index>
|
158
|
-
XML
|
159
|
-
|
160
|
-
assert_equal expected, File.read(index.path)
|
161
|
-
end
|
162
|
-
|
163
|
-
def test_default_category
|
164
|
-
index = ReaPack::Index.new @dummy_path
|
165
|
-
index.files = ['script.lua', 'Hello/World']
|
166
|
-
index.url_template = 'http://host/$path'
|
167
|
-
|
168
|
-
index.scan index.files.first, <<-IN
|
169
|
-
@version 1.0
|
170
|
-
@provides Hello/World
|
171
|
-
IN
|
172
|
-
|
173
|
-
expected = <<-XML
|
174
|
-
<?xml version="1.0" encoding="utf-8"?>
|
175
|
-
<index version="1">
|
176
|
-
<category name="Other">
|
177
|
-
<reapack name="script.lua" type="script">
|
178
|
-
<version name="1.0">
|
179
|
-
<source platform="all">http://host/script.lua</source>
|
180
|
-
<source platform="all" file="Hello/World">http://host/Hello/World</source>
|
181
|
-
</version>
|
182
|
-
</reapack>
|
183
|
-
</category>
|
184
|
-
</index>
|
185
|
-
XML
|
186
|
-
|
187
|
-
index.write!
|
188
|
-
assert_equal expected, File.read(index.path)
|
189
|
-
end
|
190
|
-
|
191
|
-
def test_edit_version_amend_off
|
192
|
-
index = ReaPack::Index.new @real_path
|
193
|
-
assert_equal false, index.amend
|
194
|
-
|
195
|
-
index.url_template = 'http://google.com/$path'
|
196
|
-
index.files = ['Category Name/Hello World.lua']
|
197
|
-
|
198
|
-
index.scan index.files.first, <<-IN
|
199
|
-
@version 1.0
|
200
|
-
@changelog New Changelog!
|
201
|
-
IN
|
202
|
-
|
203
|
-
assert_equal false, index.modified?
|
204
|
-
assert_empty index.changelog
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_edit_version_amend_on
|
208
|
-
index = ReaPack::Index.new @real_path
|
209
|
-
index.amend = true
|
210
|
-
assert_equal true, index.amend
|
211
|
-
|
212
|
-
index.url_template = 'http://google.com/$path'
|
213
|
-
index.files = ['Category Name/Hello World.lua']
|
214
|
-
|
215
|
-
index.scan index.files.first, <<-IN
|
216
|
-
@version 1.0
|
217
|
-
@changelog New Changelog!
|
218
|
-
IN
|
219
|
-
|
220
|
-
assert index.modified?, 'index is not modified'
|
221
|
-
assert_equal '1 modified package, 1 modified version', index.changelog
|
222
|
-
|
223
|
-
expected = <<-XML
|
224
|
-
<?xml version="1.0" encoding="utf-8"?>
|
225
|
-
<index version="1" commit="#{@commit}">
|
226
|
-
<category name="Category Name">
|
227
|
-
<reapack name="Hello World.lua" type="script">
|
228
|
-
<version name="1.0">
|
229
|
-
<changelog><![CDATA[New Changelog!]]></changelog>
|
230
|
-
<source platform="all">http://google.com/Category%20Name/Hello%20World.lua</source>
|
231
|
-
</version>
|
232
|
-
</reapack>
|
233
|
-
</category>
|
234
|
-
</index>
|
235
|
-
XML
|
236
|
-
|
237
|
-
index.write @dummy_path
|
238
|
-
assert_equal expected, File.read(@dummy_path)
|
239
|
-
end
|
240
|
-
|
241
|
-
def test_edit_version_amend_unmodified
|
242
|
-
index = ReaPack::Index.new @real_path
|
243
|
-
index.amend = true
|
244
|
-
|
245
|
-
index.url_template = 'https://google.com/$path'
|
246
|
-
index.files = ['Category Name/Hello World.lua']
|
247
|
-
|
248
|
-
index.scan index.files.first, <<-IN
|
249
|
-
@version 1.0
|
250
|
-
@author cfillion
|
251
|
-
@changelog Fixed a division by zero error.
|
252
|
-
IN
|
253
|
-
|
254
|
-
assert_equal false, index.modified?
|
255
|
-
assert_empty index.changelog
|
256
|
-
end
|
257
|
-
|
258
|
-
def test_file_unlisted
|
137
|
+
def test_make_url_defaut_branch
|
259
138
|
index = ReaPack::Index.new @dummy_path
|
260
|
-
index.
|
261
|
-
|
262
|
-
|
263
|
-
index.scan 'unlisted.lua', '@version 1.0'
|
264
|
-
end
|
265
|
-
|
266
|
-
assert_equal 'unlisted.lua: No such file or directory', error.message
|
267
|
-
|
268
|
-
expected = <<-XML
|
269
|
-
<?xml version="1.0" encoding="utf-8"?>
|
270
|
-
<index version="1"/>
|
271
|
-
XML
|
139
|
+
index.files = ['Category/script.lua']
|
140
|
+
index.url_template = 'http://host/$commit/$path'
|
141
|
+
index.commit = nil
|
272
142
|
|
273
|
-
|
274
|
-
|
143
|
+
assert_match 'http://host/master/Category/script.lua',
|
144
|
+
index.make_url('Category/script.lua')
|
275
145
|
end
|
276
146
|
|
277
147
|
def test_make_url_without_template
|
278
148
|
index = ReaPack::Index.new @dummy_path
|
279
149
|
index.files = ['script.lua']
|
280
150
|
|
151
|
+
assert_equal nil, index.url_template
|
152
|
+
index.make_url 'script.lua', 'ok if explicit template'
|
153
|
+
|
281
154
|
error = assert_raises ReaPack::Index::Error do
|
282
|
-
|
155
|
+
index.make_url 'script.lua'
|
283
156
|
end
|
284
157
|
|
285
|
-
assert_match /url template
|
286
|
-
end
|
287
|
-
|
288
|
-
def test_make_url_defaut_branch
|
289
|
-
index = ReaPack::Index.new @dummy_path
|
290
|
-
index.files = ['Category/script.lua']
|
291
|
-
index.url_template = 'http://host/$commit/$path'
|
292
|
-
|
293
|
-
index.commit = nil
|
294
|
-
|
295
|
-
index.scan index.files.first, '@version 1.0'
|
296
|
-
|
297
|
-
expected = <<-XML
|
298
|
-
<?xml version="1.0" encoding="utf-8"?>
|
299
|
-
<index version="1">
|
300
|
-
<category name="Category">
|
301
|
-
<reapack name="script.lua" type="script">
|
302
|
-
<version name="1.0">
|
303
|
-
<source platform="all">http://host/master/Category/script.lua</source>
|
304
|
-
</version>
|
305
|
-
</reapack>
|
306
|
-
</category>
|
307
|
-
</index>
|
308
|
-
XML
|
309
|
-
|
310
|
-
index.write!
|
311
|
-
assert_equal expected, File.read(@dummy_path)
|
158
|
+
assert_match /url template/i, error.message
|
312
159
|
end
|
313
160
|
|
314
161
|
def test_make_url_commit
|
315
162
|
index = ReaPack::Index.new @dummy_path
|
316
163
|
index.files = ['Category/script.lua']
|
317
164
|
index.url_template = 'http://host/$commit/$path'
|
318
|
-
|
319
165
|
index.commit = @commit
|
320
166
|
|
321
|
-
|
322
|
-
|
323
|
-
expected = <<-XML
|
324
|
-
<?xml version="1.0" encoding="utf-8"?>
|
325
|
-
<index version="1" commit="#{@commit}">
|
326
|
-
<category name="Category">
|
327
|
-
<reapack name="script.lua" type="script">
|
328
|
-
<version name="1.0">
|
329
|
-
<source platform="all">http://host/#{@commit}/Category/script.lua</source>
|
330
|
-
</version>
|
331
|
-
</reapack>
|
332
|
-
</category>
|
333
|
-
</index>
|
334
|
-
XML
|
335
|
-
|
336
|
-
index.write!
|
337
|
-
assert_equal expected, File.read(@dummy_path)
|
167
|
+
assert_equal "http://host/#{@commit}/Category/script.lua",
|
168
|
+
index.make_url('Category/script.lua')
|
338
169
|
end
|
339
170
|
|
340
|
-
def
|
171
|
+
def test_make_url_unlisted
|
341
172
|
index = ReaPack::Index.new @dummy_path
|
342
|
-
index.
|
343
|
-
index.
|
344
|
-
|
345
|
-
error = assert_raises ReaPack::Index::Error do
|
346
|
-
index.scan index.files.first, 'no version tag here'
|
347
|
-
end
|
348
|
-
|
349
|
-
assert_match 'missing tag "version"', error.message
|
350
|
-
end
|
173
|
+
index.commit = @commit
|
174
|
+
index.url_template = 'http://google.com/$path'
|
351
175
|
|
352
|
-
|
353
|
-
index = ReaPack::Index.new @dummy_path
|
354
|
-
index.url_template = 'http://host/$path'
|
355
|
-
index.files = ['test.lua']
|
176
|
+
index.make_url 'unlisted.lua', 'ok with url template'
|
356
177
|
|
357
178
|
error = assert_raises ReaPack::Index::Error do
|
358
|
-
|
359
|
-
@version 1.0
|
360
|
-
@changelog
|
361
|
-
IN
|
179
|
+
index.make_url 'unlisted.lua'
|
362
180
|
end
|
363
181
|
|
364
|
-
|
182
|
+
assert_equal "file not found 'unlisted.lua'", error.message
|
365
183
|
end
|
366
184
|
|
367
|
-
def
|
185
|
+
def test_reset_index_after_error
|
368
186
|
index = ReaPack::Index.new @dummy_path
|
187
|
+
index.commit = @commit
|
369
188
|
index.url_template = 'http://host/$path'
|
370
|
-
index.files = ['Category/script.lua']
|
371
189
|
|
372
|
-
index.scan
|
373
|
-
@version 1.0
|
374
|
-
@author cfillion
|
375
|
-
IN
|
190
|
+
assert_raises { index.scan 'cat/not_listed.lua', '@version 1.0' }
|
376
191
|
|
377
192
|
expected = <<-XML
|
378
193
|
<?xml version="1.0" encoding="utf-8"?>
|
379
|
-
<index version="1"
|
380
|
-
<category name="Category">
|
381
|
-
<reapack name="script.lua" type="script">
|
382
|
-
<version name="1.0" author="cfillion">
|
383
|
-
<source platform="all">http://host/Category/script.lua</source>
|
384
|
-
</version>
|
385
|
-
</reapack>
|
386
|
-
</category>
|
387
|
-
</index>
|
194
|
+
<index version="1"/>
|
388
195
|
XML
|
389
196
|
|
390
197
|
index.write!
|
391
198
|
assert_equal expected, File.read(index.path)
|
392
199
|
end
|
393
200
|
|
394
|
-
def test_author_boolean
|
395
|
-
index = ReaPack::Index.new @dummy_path
|
396
|
-
index.url_template = 'http://host/$path'
|
397
|
-
index.files = ['test.lua']
|
398
|
-
|
399
|
-
error = assert_raises ReaPack::Index::Error do
|
400
|
-
index.scan index.files.first, <<-IN
|
401
|
-
@version 1.0
|
402
|
-
@author
|
403
|
-
IN
|
404
|
-
end
|
405
|
-
|
406
|
-
assert_match 'invalid value for tag "author"', error.message
|
407
|
-
end
|
408
|
-
|
409
|
-
def test_author_multiline
|
410
|
-
index = ReaPack::Index.new @dummy_path
|
411
|
-
index.url_template = 'http://host/$path'
|
412
|
-
index.files = ['test.lua']
|
413
|
-
|
414
|
-
error = assert_raises ReaPack::Index::Error do
|
415
|
-
index.scan index.files.first, <<-IN
|
416
|
-
@version 1.0
|
417
|
-
@author
|
418
|
-
hello
|
419
|
-
world
|
420
|
-
IN
|
421
|
-
end
|
422
|
-
|
423
|
-
assert_equal 'invalid metadata: invalid value for tag "author"', error.message
|
424
|
-
end
|
425
|
-
|
426
|
-
def test_provides
|
427
|
-
index = ReaPack::Index.new @dummy_path
|
428
|
-
index.url_template = 'http://host/$path'
|
429
|
-
|
430
|
-
index.files = [
|
431
|
-
'Category/script.lua',
|
432
|
-
'Resources/unicode.dat',
|
433
|
-
'Category/test.png',
|
434
|
-
]
|
435
|
-
|
436
|
-
index.scan index.files.first, <<-IN
|
437
|
-
@version 1.0
|
438
|
-
@provides
|
439
|
-
../Resources/unicode.dat
|
440
|
-
test.png
|
441
|
-
IN
|
442
|
-
|
443
|
-
expected = <<-XML
|
444
|
-
<?xml version="1.0" encoding="utf-8"?>
|
445
|
-
<index version="1">
|
446
|
-
<category name="Category">
|
447
|
-
<reapack name="script.lua" type="script">
|
448
|
-
<version name="1.0">
|
449
|
-
<source platform="all">http://host/Category/script.lua</source>
|
450
|
-
<source platform="all" file="../Resources/unicode.dat">http://host/Resources/unicode.dat</source>
|
451
|
-
<source platform="all" file="test.png">http://host/Category/test.png</source>
|
452
|
-
</version>
|
453
|
-
</reapack>
|
454
|
-
</category>
|
455
|
-
</index>
|
456
|
-
XML
|
457
|
-
|
458
|
-
index.write!
|
459
|
-
assert_equal expected, File.read(@dummy_path)
|
460
|
-
end
|
461
|
-
|
462
|
-
def test_provides_unlisted
|
463
|
-
index = ReaPack::Index.new @dummy_path
|
464
|
-
index.url_template = 'http://host/$path'
|
465
|
-
index.files = ['Category/script.lua']
|
466
|
-
|
467
|
-
error = assert_raises ReaPack::Index::Error do
|
468
|
-
index.scan index.files.first, <<-IN
|
469
|
-
@version 1.0
|
470
|
-
@provides
|
471
|
-
test.png
|
472
|
-
IN
|
473
|
-
end
|
474
|
-
|
475
|
-
assert_equal 'Category/test.png: No such file or directory', error.message
|
476
|
-
end
|
477
|
-
|
478
|
-
def test_provides_duplicate
|
479
|
-
index = ReaPack::Index.new @dummy_path
|
480
|
-
index.url_template = 'http://host/$path'
|
481
|
-
|
482
|
-
error = assert_raises ReaPack::Index::Error do
|
483
|
-
index.scan 'script.lua', <<-IN
|
484
|
-
@version 1.0
|
485
|
-
@provides
|
486
|
-
test.png
|
487
|
-
test.png http://url.com
|
488
|
-
IN
|
489
|
-
end
|
490
|
-
|
491
|
-
assert_match 'invalid value for tag "provides": duplicate file (test.png)',
|
492
|
-
error.message
|
493
|
-
end
|
494
|
-
|
495
|
-
def test_provides_duplicate_platforms
|
496
|
-
index = ReaPack::Index.new @dummy_path
|
497
|
-
index.url_template = 'http://host/$path'
|
498
|
-
index.files = ['script.lua', 'test.png', 'test.png']
|
499
|
-
|
500
|
-
index.scan index.files.first, <<-IN
|
501
|
-
@version 1.0
|
502
|
-
@provides
|
503
|
-
[windows] test.png
|
504
|
-
[darwin] test.png
|
505
|
-
IN
|
506
|
-
end
|
507
|
-
|
508
|
-
def test_invalid_platform
|
509
|
-
index = ReaPack::Index.new @dummy_path
|
510
|
-
index.url_template = 'http://host/$path'
|
511
|
-
|
512
|
-
error = assert_raises ReaPack::Index::Error do
|
513
|
-
index.scan 'test.lua', <<-IN
|
514
|
-
@version 1.0
|
515
|
-
@provides
|
516
|
-
[hello] test.png
|
517
|
-
IN
|
518
|
-
end
|
519
|
-
|
520
|
-
assert_match 'invalid value for tag "provides": invalid platform hello',
|
521
|
-
error.message
|
522
|
-
end
|
523
|
-
|
524
|
-
def test_provides_platform
|
525
|
-
index = ReaPack::Index.new @dummy_path
|
526
|
-
index.url_template = 'http://host/$path'
|
527
|
-
|
528
|
-
index.files = [
|
529
|
-
'Category/script.lua',
|
530
|
-
'Category/winall.png',
|
531
|
-
'Category/win32bit.png',
|
532
|
-
'Category/win64bit.png',
|
533
|
-
'Category/osxall.png',
|
534
|
-
'Category/osx32bit.png',
|
535
|
-
'Category/osx64bit.png',
|
536
|
-
]
|
537
|
-
|
538
|
-
index.scan index.files.first, <<-IN
|
539
|
-
@version 1.0
|
540
|
-
@provides
|
541
|
-
[windows] winall.png
|
542
|
-
[win32] win32bit.png
|
543
|
-
[win64]win64bit.png
|
544
|
-
[ darwin ] osxall.png
|
545
|
-
[darwin32] osx32bit.png
|
546
|
-
[darwin64] osx64bit.png
|
547
|
-
IN
|
548
|
-
|
549
|
-
expected = <<-XML
|
550
|
-
<?xml version="1.0" encoding="utf-8"?>
|
551
|
-
<index version="1">
|
552
|
-
<category name="Category">
|
553
|
-
<reapack name="script.lua" type="script">
|
554
|
-
<version name="1.0">
|
555
|
-
<source platform="all">http://host/Category/script.lua</source>
|
556
|
-
<source platform="windows" file="winall.png">http://host/Category/winall.png</source>
|
557
|
-
<source platform="win32" file="win32bit.png">http://host/Category/win32bit.png</source>
|
558
|
-
<source platform="win64" file="win64bit.png">http://host/Category/win64bit.png</source>
|
559
|
-
<source platform="darwin" file="osxall.png">http://host/Category/osxall.png</source>
|
560
|
-
<source platform="darwin32" file="osx32bit.png">http://host/Category/osx32bit.png</source>
|
561
|
-
<source platform="darwin64" file="osx64bit.png">http://host/Category/osx64bit.png</source>
|
562
|
-
</version>
|
563
|
-
</reapack>
|
564
|
-
</category>
|
565
|
-
</index>
|
566
|
-
XML
|
567
|
-
|
568
|
-
index.write!
|
569
|
-
assert_equal expected, File.read(@dummy_path)
|
570
|
-
end
|
571
|
-
|
572
|
-
def test_main_platform
|
573
|
-
index = ReaPack::Index.new @dummy_path
|
574
|
-
index.url_template = 'http://host/$path'
|
575
|
-
index.files = ['Category/script.lua']
|
576
|
-
|
577
|
-
index.scan index.files.first, <<-IN
|
578
|
-
@version 1.0
|
579
|
-
@provides
|
580
|
-
[darwin] .
|
581
|
-
[win64] script.lua
|
582
|
-
IN
|
583
|
-
|
584
|
-
expected = <<-XML
|
585
|
-
<?xml version="1.0" encoding="utf-8"?>
|
586
|
-
<index version="1">
|
587
|
-
<category name="Category">
|
588
|
-
<reapack name="script.lua" type="script">
|
589
|
-
<version name="1.0">
|
590
|
-
<source platform="darwin">http://host/Category/script.lua</source>
|
591
|
-
<source platform="win64">http://host/Category/script.lua</source>
|
592
|
-
</version>
|
593
|
-
</reapack>
|
594
|
-
</category>
|
595
|
-
</index>
|
596
|
-
XML
|
597
|
-
|
598
|
-
index.write!
|
599
|
-
assert_equal expected, File.read(@dummy_path)
|
600
|
-
end
|
601
|
-
|
602
|
-
def test_provides_custom_url
|
603
|
-
index = ReaPack::Index.new @dummy_path
|
604
|
-
index.files = ['Category/script.lua']
|
605
|
-
|
606
|
-
index.scan index.files.first, <<-IN
|
607
|
-
@version 1.0
|
608
|
-
@provides
|
609
|
-
script.lua http://google.com/download/$commit/$version/$path
|
610
|
-
IN
|
611
|
-
|
612
|
-
expected = <<-XML
|
613
|
-
<?xml version="1.0" encoding="utf-8"?>
|
614
|
-
<index version="1">
|
615
|
-
<category name="Category">
|
616
|
-
<reapack name="script.lua" type="script">
|
617
|
-
<version name="1.0">
|
618
|
-
<source platform="all">http://google.com/download/master/1.0/Category/script.lua</source>
|
619
|
-
</version>
|
620
|
-
</reapack>
|
621
|
-
</category>
|
622
|
-
</index>
|
623
|
-
XML
|
624
|
-
|
625
|
-
index.write!
|
626
|
-
assert_equal expected, File.read(@dummy_path)
|
627
|
-
end
|
628
|
-
|
629
201
|
def test_remove
|
630
202
|
index = ReaPack::Index.new @real_path
|
203
|
+
index.commit = @commit
|
631
204
|
|
632
205
|
index.remove 'Category Name/Hello World.lua'
|
633
206
|
|
@@ -652,242 +225,75 @@ class TestIndex < MiniTest::Test
|
|
652
225
|
assert_empty index.changelog
|
653
226
|
end
|
654
227
|
|
655
|
-
def
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
assert_equal false, index.modified?
|
661
|
-
end
|
662
|
-
|
663
|
-
def test_noindex_remove
|
664
|
-
index = ReaPack::Index.new @real_path
|
665
|
-
|
666
|
-
index.scan 'Category Name/Hello World.lua', '@noindex'
|
667
|
-
|
668
|
-
assert_equal true, index.modified?
|
669
|
-
assert_equal '1 removed package', index.changelog
|
670
|
-
|
671
|
-
expected = <<-XML
|
672
|
-
<?xml version="1.0" encoding="utf-8"?>
|
673
|
-
<index version="1" commit="#{@commit}"/>
|
674
|
-
XML
|
675
|
-
|
676
|
-
index.write @dummy_path
|
677
|
-
assert_equal expected, File.read(@dummy_path)
|
678
|
-
end
|
679
|
-
|
680
|
-
def test_version_time
|
681
|
-
index = ReaPack::Index.new @dummy_path
|
682
|
-
index.url_template = 'http://host/$path'
|
683
|
-
index.files = ['Category/script.lua']
|
684
|
-
|
685
|
-
index.time = Time.new 2016, 2, 11, 20, 16, 40, -5 * 3600
|
686
|
-
|
687
|
-
index.scan index.files.first, '@version 1.0'
|
688
|
-
|
689
|
-
expected = <<-XML
|
690
|
-
<?xml version="1.0" encoding="utf-8"?>
|
691
|
-
<index version="1">
|
692
|
-
<category name="Category">
|
693
|
-
<reapack name="script.lua" type="script">
|
694
|
-
<version name="1.0" time="2016-02-12T01:16:40Z">
|
695
|
-
<source platform="all">http://host/Category/script.lua</source>
|
696
|
-
</version>
|
697
|
-
</reapack>
|
698
|
-
</category>
|
228
|
+
def test_sort_tags
|
229
|
+
File.write @dummy_path, <<-XML
|
230
|
+
<index>
|
231
|
+
<metadata/>
|
232
|
+
<category name="zebra"/>
|
699
233
|
</index>
|
700
234
|
XML
|
701
235
|
|
702
|
-
index.write!
|
703
|
-
assert_equal expected, File.read(index.path)
|
704
|
-
end
|
705
|
-
|
706
|
-
def test_add_anonymous_link
|
707
|
-
index = ReaPack::Index.new @dummy_path
|
708
|
-
|
709
|
-
assert_equal 0, index.links(:website).size
|
710
|
-
index.eval_link :website, 'http://test.com'
|
711
|
-
assert_equal 1, index.links(:website).size
|
712
|
-
|
713
|
-
assert_equal '1 new website link, empty index', index.changelog
|
714
|
-
|
715
|
-
index.write!
|
716
|
-
end
|
717
|
-
|
718
|
-
def test_add_named_link
|
719
236
|
index = ReaPack::Index.new @dummy_path
|
720
|
-
|
721
|
-
assert_equal 0, index.links(:website).size
|
722
|
-
index.eval_link :website, 'Test=http://test.com/hello=world'
|
723
|
-
assert_equal 1, index.links(:website).size
|
724
|
-
|
725
|
-
assert_equal '1 new website link, empty index', index.changelog
|
726
|
-
|
727
237
|
index.write!
|
728
|
-
expected = <<-XML
|
729
|
-
<?xml version="1.0" encoding="utf-8"?>
|
730
|
-
<index version="1">
|
731
|
-
<metadata>
|
732
|
-
<link rel="website" href="http://test.com/hello=world">Test</link>
|
733
|
-
</metadata>
|
734
|
-
</index>
|
735
|
-
XML
|
736
238
|
|
737
|
-
index.
|
738
|
-
assert_equal expected, File.read(@dummy_path)
|
239
|
+
assert_match /<category.+<metadata/m, File.read(index.path)
|
739
240
|
end
|
740
241
|
|
741
|
-
def
|
742
|
-
index = ReaPack::Index.new @
|
743
|
-
index.
|
744
|
-
index.
|
745
|
-
|
746
|
-
|
747
|
-
index.eval_link :website, 'Test=http://test.com/hello'
|
748
|
-
assert_equal '1 new website link, 1 modified website link, empty index',
|
749
|
-
index.changelog
|
750
|
-
end
|
751
|
-
|
752
|
-
def test_remove_link_by_name
|
753
|
-
index = ReaPack::Index.new @dummy_path
|
754
|
-
index.eval_link :website, 'Test=http://test.com'
|
755
|
-
index.eval_link :website, '-Test'
|
756
|
-
assert_equal '1 new website link, 1 removed website link, empty index', index.changelog
|
242
|
+
def test_remove_clear_cdetector
|
243
|
+
index = ReaPack::Index.new @real_path
|
244
|
+
index.url_template = 'http://host/$path'
|
245
|
+
index.files = ['Category Name/Hello World.lua', 'Category Name/test.lua']
|
246
|
+
index.remove index.files.first
|
247
|
+
index.scan index.files.last, "@version 2.0\n@provides Hello World.lua"
|
757
248
|
end
|
758
249
|
|
759
|
-
def
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
250
|
+
def test_sort_categories
|
251
|
+
File.write @dummy_path, <<-XML
|
252
|
+
<index>
|
253
|
+
<category name="zebra"/>
|
254
|
+
<category name="bee"/>
|
255
|
+
</index>
|
256
|
+
XML
|
765
257
|
|
766
|
-
def test_description
|
767
258
|
index = ReaPack::Index.new @dummy_path
|
768
259
|
index.write!
|
769
260
|
|
770
|
-
|
771
|
-
assert_equal false, index.modified?
|
772
|
-
|
773
|
-
index.description = 'Hello World'
|
774
|
-
refute_empty index.description
|
775
|
-
assert_equal true, index.modified?
|
776
|
-
assert_equal '1 modified metadata', index.changelog
|
777
|
-
|
778
|
-
index.write!
|
779
|
-
|
780
|
-
index.description = 'Hello World'
|
781
|
-
assert_equal false, index.modified?
|
261
|
+
assert_match /bee.+zebra/m, File.read(index.path)
|
782
262
|
end
|
783
263
|
|
784
|
-
def
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
@provides
|
791
|
-
reaper_reapack.so http://example.com/$path
|
792
|
-
IN
|
793
|
-
|
794
|
-
expected = <<-XML
|
795
|
-
<?xml version="1.0" encoding="utf-8"?>
|
796
|
-
<index version="1">
|
797
|
-
<category name="Extensions">
|
798
|
-
<reapack name="reapack.ext" type="extension">
|
799
|
-
<version name="1.0">
|
800
|
-
<source platform="all" file="reaper_reapack.so">http://example.com/reaper_reapack.so</source>
|
801
|
-
</version>
|
802
|
-
</reapack>
|
264
|
+
def test_sort_packages
|
265
|
+
File.write @dummy_path, <<-XML
|
266
|
+
<index>
|
267
|
+
<category name="Other">
|
268
|
+
<reapack name="zebra.lua"/>
|
269
|
+
<reapack name="bee.lua"/>
|
803
270
|
</category>
|
804
271
|
</index>
|
805
272
|
XML
|
806
273
|
|
807
|
-
index.write!
|
808
|
-
assert_equal expected, File.read(@dummy_path)
|
809
|
-
end
|
810
|
-
|
811
|
-
def test_effect
|
812
274
|
index = ReaPack::Index.new @dummy_path
|
813
|
-
index.
|
814
|
-
index.files = ['Dynamics/super_compressor.jsfx']
|
275
|
+
index.write!
|
815
276
|
|
816
|
-
|
277
|
+
assert_match /bee.+zebra/m, File.read(index.path)
|
278
|
+
end
|
817
279
|
|
818
|
-
|
280
|
+
def test_dont_sort_versions
|
281
|
+
original = <<-XML
|
819
282
|
<?xml version="1.0" encoding="utf-8"?>
|
820
283
|
<index version="1">
|
821
|
-
<category name="
|
822
|
-
<reapack name="
|
823
|
-
<version name="
|
824
|
-
|
825
|
-
</version>
|
284
|
+
<category name="Other">
|
285
|
+
<reapack name="test.lua">
|
286
|
+
<version name="z"/>
|
287
|
+
<version name="a"/>
|
826
288
|
</reapack>
|
827
289
|
</category>
|
828
290
|
</index>
|
829
291
|
XML
|
830
292
|
|
831
|
-
|
832
|
-
assert_equal expected, File.read(@dummy_path)
|
833
|
-
end
|
834
|
-
|
835
|
-
def test_sort_tags
|
836
|
-
index = ReaPack::Index.new @dummy_path
|
837
|
-
index.url_template = 'http://host/$path'
|
838
|
-
index.files = ['Hello/world.lua']
|
839
|
-
|
840
|
-
index.description = 'hello'
|
841
|
-
|
842
|
-
index.scan index.files.first, '@version 1.0'
|
843
|
-
|
844
|
-
index.write!
|
845
|
-
assert_match /<category.+<metadata>/m, File.read(@dummy_path)
|
846
|
-
end
|
847
|
-
|
848
|
-
def test_sort_categories
|
293
|
+
File.write @dummy_path, original
|
849
294
|
index = ReaPack::Index.new @dummy_path
|
850
|
-
index.url_template = 'http://host/$path'
|
851
|
-
index.files = ['zebra/agent.lua', 'bee/agent.lua']
|
852
|
-
|
853
|
-
index.scan index.files.first, '@version 1.0'
|
854
|
-
index.scan index.files.last, '@version 1.0'
|
855
|
-
|
856
295
|
index.write!
|
857
|
-
assert_match /bee.+zebra/m, File.read(@dummy_path)
|
858
|
-
end
|
859
296
|
|
860
|
-
|
861
|
-
index = ReaPack::Index.new @dummy_path
|
862
|
-
index.url_template = 'http://host/$path'
|
863
|
-
index.files = ['zebra.lua', 'bee.lua']
|
864
|
-
|
865
|
-
index.scan index.files.first, '@version 1.0'
|
866
|
-
index.scan index.files.last, '@version 1.0'
|
867
|
-
|
868
|
-
index.write!
|
869
|
-
assert_match /bee.+zebra/m, File.read(@dummy_path)
|
870
|
-
end
|
871
|
-
|
872
|
-
def test_name
|
873
|
-
index = ReaPack::Index.new @dummy_path
|
874
|
-
assert_empty index.name
|
875
|
-
|
876
|
-
index.name = 'Hello World'
|
877
|
-
assert_equal '1 modified metadata, empty index', index.changelog
|
878
|
-
|
879
|
-
error = assert_raises ReaPack::Index::Error do index.name = '.'; end
|
880
|
-
assert_raises ReaPack::Index::Error do index.name = 'hello/world'; end
|
881
|
-
assert_equal "Invalid name: '.'", error.message
|
882
|
-
|
883
|
-
assert_equal 'Hello World', index.name
|
884
|
-
|
885
|
-
expected = <<-XML
|
886
|
-
<?xml version="1.0" encoding="utf-8"?>
|
887
|
-
<index version="1" name="Hello World"/>
|
888
|
-
XML
|
889
|
-
|
890
|
-
index.write!
|
891
|
-
assert_equal expected, File.read(@dummy_path)
|
297
|
+
assert_equal original, File.read(index.path)
|
892
298
|
end
|
893
299
|
end
|