irpack 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +57 -0
- data/lib/irpack.rb +16 -38
- data/lib/irpack/application.rb +71 -115
- data/lib/irpack/packager.rb +1 -1
- data/lib/irpack/rake/generateexetask.rb +86 -0
- data/lib/irpack/specification.rb +182 -0
- data/test/fixtures/foo.rb +3 -0
- data/test/test_application.rb +90 -72
- data/test/test_generateexetask.rb +152 -0
- data/test/test_irpack.rb +17 -13
- data/test/test_packager.rb +4 -4
- data/test/test_specification.rb +237 -0
- data/test/utils.rb +1 -0
- metadata +10 -2
data/test/test_irpack.rb
CHANGED
@@ -24,6 +24,7 @@ freely, subject to the following restrictions:
|
|
24
24
|
|
25
25
|
require 'test/unit'
|
26
26
|
require 'irpack'
|
27
|
+
require 'irpack/specification'
|
27
28
|
require 'utils'
|
28
29
|
|
29
30
|
class TC_IRPack < Test::Unit::TestCase
|
@@ -60,7 +61,7 @@ class TC_IRPack < Test::Unit::TestCase
|
|
60
61
|
def test_ironruby_libraries
|
61
62
|
libs = IRPack.ironruby_libraries
|
62
63
|
assert(libs.size>0)
|
63
|
-
libs.each do |
|
64
|
+
libs.each do |dst, src|
|
64
65
|
assert_match(/^stdlib\/((ruby\/1\.9\.1|ironruby)\/.+)/, dst)
|
65
66
|
assert_match(/#{$1}$/, src)
|
66
67
|
assert(File.file?(src))
|
@@ -84,16 +85,18 @@ class TC_IRPack < Test::Unit::TestCase
|
|
84
85
|
RB
|
85
86
|
f.path
|
86
87
|
end
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
spec = IRPack::Specification.new
|
89
|
+
spec.files = {
|
90
|
+
'entry.rb' => entry,
|
91
|
+
'hello.rb' => hello,
|
90
92
|
}
|
91
|
-
|
92
|
-
|
93
|
-
assert_equal(
|
93
|
+
spec.output_file = tempfilename('.exe')
|
94
|
+
spec.entry_file = 'entry.rb'
|
95
|
+
assert_equal(File.expand_path(spec.output_file), IRPack.pack(spec))
|
96
|
+
assert_equal('Hello World!', `#{spec.output_file}`.chomp)
|
94
97
|
end
|
95
98
|
|
96
|
-
def
|
99
|
+
def test_pack_with_embed_stdlibs
|
97
100
|
entry = Tempfile.open(File.basename(__FILE__)) do |f|
|
98
101
|
f.write <<-RB
|
99
102
|
require 'stringio'
|
@@ -102,12 +105,13 @@ class TC_IRPack < Test::Unit::TestCase
|
|
102
105
|
RB
|
103
106
|
f.path
|
104
107
|
end
|
105
|
-
|
106
|
-
|
108
|
+
spec = IRPack::Specification.new {|spec|
|
109
|
+
spec.entry_file = entry
|
110
|
+
spec.output_file = tempfilename('.exe')
|
111
|
+
spec.embed_stdlibs = true
|
107
112
|
}
|
108
|
-
|
109
|
-
assert_equal(
|
110
|
-
assert_equal('Hello', `#{outfile}`.chomp)
|
113
|
+
assert_equal(File.expand_path(spec.output_file), IRPack.pack(spec))
|
114
|
+
assert_equal('Hello', `#{spec.output_file}`.chomp)
|
111
115
|
end
|
112
116
|
end
|
113
117
|
|
data/test/test_packager.rb
CHANGED
@@ -30,16 +30,16 @@ class TC_Packager < Test::Unit::TestCase
|
|
30
30
|
include Utils
|
31
31
|
|
32
32
|
SrcFiles = {
|
33
|
-
File.join(File.dirname(__FILE__), 'test_packager.rb')
|
34
|
-
File.join(File.dirname(__FILE__), 'test_cscompiler.rb')
|
33
|
+
'foo.rb' => File.join(File.dirname(__FILE__), 'test_packager.rb'),
|
34
|
+
'bar.rb' => File.join(File.dirname(__FILE__), 'test_cscompiler.rb'),
|
35
35
|
}
|
36
36
|
|
37
37
|
def test_pack
|
38
38
|
package_file = tempfilename
|
39
39
|
IRPack::Packager.pack(SrcFiles, package_file)
|
40
40
|
package = System::IO::Packaging::Package.open(package_file, System::IO::FileMode.open)
|
41
|
-
SrcFiles.each do |
|
42
|
-
uri = System::Uri.new(File.join('/',
|
41
|
+
SrcFiles.each do |dst, src|
|
42
|
+
uri = System::Uri.new(File.join('/', dst), System::UriKind.relative)
|
43
43
|
assert(package.part_exists(uri))
|
44
44
|
stream = package.get_part(uri).get_stream
|
45
45
|
bytes = System::Array[System::Byte].new(stream.length)
|
@@ -0,0 +1,237 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2011 Ryuichi Sakamoto.
|
3
|
+
|
4
|
+
This software is provided 'as-is', without any express or implied
|
5
|
+
warranty. In no event will the authors be held liable for any damages
|
6
|
+
arising from the use of this software.
|
7
|
+
|
8
|
+
Permission is granted to anyone to use this software for any purpose,
|
9
|
+
including commercial applications, and to alter it and redistribute it
|
10
|
+
freely, subject to the following restrictions:
|
11
|
+
|
12
|
+
1. The origin of this software must not be misrepresented; you must not
|
13
|
+
claim that you wrote the original software. If you use this software
|
14
|
+
in a product, an acknowledgment in the product documentation would be
|
15
|
+
appreciated but is not required.
|
16
|
+
|
17
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
18
|
+
misrepresented as being the original software.
|
19
|
+
|
20
|
+
3. This notice may not be removed or altered from any source
|
21
|
+
distribution.
|
22
|
+
=end
|
23
|
+
|
24
|
+
require 'test/unit'
|
25
|
+
require 'irpack/specification'
|
26
|
+
|
27
|
+
class TC_Specification < Test::Unit::TestCase
|
28
|
+
def test_construct
|
29
|
+
spec = IRPack::Specification.new
|
30
|
+
assert_nil(spec.output_file)
|
31
|
+
assert_nil(spec.entry_file)
|
32
|
+
assert_nil(spec.module_name)
|
33
|
+
assert(spec.files.empty?)
|
34
|
+
assert(spec.base_paths.empty?)
|
35
|
+
assert(!spec.compress)
|
36
|
+
assert_equal(:exe, spec.target)
|
37
|
+
assert(spec.embed_assemblies)
|
38
|
+
assert(!spec.embed_stdlibs)
|
39
|
+
assert_kind_of(IRPack::Specification::RuntimeOptions, spec.runtime_options)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_construct_with_block
|
43
|
+
arg = nil
|
44
|
+
spec = IRPack::Specification.new do |block_arg|
|
45
|
+
arg = block_arg
|
46
|
+
end
|
47
|
+
assert_same(arg, spec)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_map_entry_no_entry_file
|
51
|
+
spec = IRPack::Specification.new
|
52
|
+
assert_raise(ArgumentError) do
|
53
|
+
spec.map_entry
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_map_entry_no_base_paths
|
58
|
+
spec = IRPack::Specification.new
|
59
|
+
spec.entry_file = 'bin/main.rb'
|
60
|
+
assert_equal('bin/main.rb', spec.map_entry)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_map_entry_base_paths
|
64
|
+
spec = IRPack::Specification.new
|
65
|
+
spec.entry_file = 'foo/bar/main.rb'
|
66
|
+
spec.base_paths << 'foo'
|
67
|
+
assert_equal('bar/main.rb', spec.map_entry)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_map_files_no_entry_file
|
71
|
+
spec = IRPack::Specification.new
|
72
|
+
assert_raise(ArgumentError) do
|
73
|
+
spec.map_files
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_map_files_only_entry_file
|
78
|
+
spec = IRPack::Specification.new
|
79
|
+
spec.entry_file = 'foo.rb'
|
80
|
+
pack_files = spec.map_files
|
81
|
+
assert_equal(1, pack_files.size)
|
82
|
+
assert_equal(File.expand_path('foo.rb'), pack_files['foo.rb'])
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_map_files_with_file_array
|
86
|
+
files = [
|
87
|
+
'foo.rb',
|
88
|
+
'foo/bar.rb',
|
89
|
+
'foo/bar/baz.rb',
|
90
|
+
'hoge/fuga/piyo.rb',
|
91
|
+
]
|
92
|
+
spec = IRPack::Specification.new
|
93
|
+
spec.entry_file = files.first
|
94
|
+
spec.files = files
|
95
|
+
pack_files = spec.map_files
|
96
|
+
assert_equal(files.size, pack_files.size)
|
97
|
+
files.each do |file|
|
98
|
+
assert_equal(File.expand_path(file), pack_files[file])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_map_files_with_base_paths
|
103
|
+
files = [
|
104
|
+
'bin/foo.rb',
|
105
|
+
'lib/foo/bar.rb',
|
106
|
+
'lib/foo/bar/baz.rb',
|
107
|
+
'hoge/fuga/piyo.rb',
|
108
|
+
]
|
109
|
+
spec = IRPack::Specification.new
|
110
|
+
spec.entry_file = files.first
|
111
|
+
spec.files = files
|
112
|
+
spec.base_paths << 'lib'
|
113
|
+
spec.base_paths << 'hoge'
|
114
|
+
pack_files = spec.map_files
|
115
|
+
assert_equal(files.size, pack_files.size)
|
116
|
+
assert_equal(File.expand_path('bin/foo.rb'), pack_files['bin/foo.rb'])
|
117
|
+
assert_equal(File.expand_path('lib/foo/bar.rb'), pack_files['foo/bar.rb'])
|
118
|
+
assert_equal(File.expand_path('lib/foo/bar/baz.rb'), pack_files['foo/bar/baz.rb'])
|
119
|
+
assert_equal(File.expand_path('hoge/fuga/piyo.rb'), pack_files['fuga/piyo.rb'])
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_map_files_with_base_paths
|
123
|
+
files = [
|
124
|
+
'bin/foo.rb',
|
125
|
+
'lib/foo/bar.rb',
|
126
|
+
'lib/foo/bar/baz.rb',
|
127
|
+
'hoge/fuga/piyo.rb',
|
128
|
+
'hoge/main.rb',
|
129
|
+
]
|
130
|
+
spec = IRPack::Specification.new
|
131
|
+
spec.entry_file = 'main.rb'
|
132
|
+
spec.files = files
|
133
|
+
spec.base_paths << 'lib'
|
134
|
+
spec.base_paths << 'hoge'
|
135
|
+
spec.base_paths << 'hoge/fuga'
|
136
|
+
pack_files = spec.map_files
|
137
|
+
assert_equal(files.size, pack_files.size)
|
138
|
+
assert_equal(File.expand_path('bin/foo.rb'), pack_files['bin/foo.rb'])
|
139
|
+
assert_equal(File.expand_path('lib/foo/bar.rb'), pack_files['foo/bar.rb'])
|
140
|
+
assert_equal(File.expand_path('lib/foo/bar/baz.rb'), pack_files['foo/bar/baz.rb'])
|
141
|
+
assert_equal(File.expand_path('hoge/fuga/piyo.rb'), pack_files['piyo.rb'])
|
142
|
+
assert_equal(File.expand_path('hoge/main.rb'), pack_files['main.rb'])
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_map_files_with_base_paths_no_entry
|
146
|
+
files = []
|
147
|
+
spec = IRPack::Specification.new
|
148
|
+
spec.entry_file = 'hoge/main.rb'
|
149
|
+
spec.files = files
|
150
|
+
spec.base_paths << 'lib'
|
151
|
+
spec.base_paths << 'hoge'
|
152
|
+
pack_files = spec.map_files
|
153
|
+
assert_equal(files.size+1, pack_files.size)
|
154
|
+
assert_equal(File.expand_path('hoge/main.rb'), pack_files['main.rb'])
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_map_files_hash
|
158
|
+
files = {
|
159
|
+
'main.rb' => 'bin/main.rb',
|
160
|
+
'bin/foo.rb' => 'bin/foo.rb',
|
161
|
+
'foo/bar.rb' => 'lib/foo/bar.rb',
|
162
|
+
'foo/bar/baz.rb' => 'lib/foo/bar/baz.rb',
|
163
|
+
'fuga/piyo.rb' => 'hoge/fuga/piyo.rb',
|
164
|
+
}
|
165
|
+
spec = IRPack::Specification.new
|
166
|
+
spec.entry_file = 'main.rb'
|
167
|
+
spec.files = files
|
168
|
+
pack_files = spec.map_files
|
169
|
+
assert_equal(files.size, pack_files.size)
|
170
|
+
assert_equal(File.expand_path('bin/main.rb'), pack_files['main.rb'])
|
171
|
+
assert_equal(File.expand_path('bin/foo.rb'), pack_files['bin/foo.rb'])
|
172
|
+
assert_equal(File.expand_path('lib/foo/bar.rb'), pack_files['foo/bar.rb'])
|
173
|
+
assert_equal(File.expand_path('lib/foo/bar/baz.rb'), pack_files['foo/bar/baz.rb'])
|
174
|
+
assert_equal(File.expand_path('hoge/fuga/piyo.rb'), pack_files['fuga/piyo.rb'])
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_map_files_hash_no_entry
|
178
|
+
files = {}
|
179
|
+
spec = IRPack::Specification.new
|
180
|
+
spec.entry_file = 'bin/main.rb'
|
181
|
+
spec.files = files
|
182
|
+
pack_files = spec.map_files
|
183
|
+
assert_equal(files.size+1, pack_files.size)
|
184
|
+
assert_equal(File.expand_path('bin/main.rb'), pack_files['bin/main.rb'])
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
class TC_Specification_RuntimeOptions < Test::Unit::TestCase
|
189
|
+
def test_construct
|
190
|
+
opts = IRPack::Specification::RuntimeOptions.new
|
191
|
+
assert(!opts.debug_mode)
|
192
|
+
assert(!opts.no_adaptive_compilation)
|
193
|
+
assert_equal(-1, opts.compilation_threshold)
|
194
|
+
assert(!opts.exception_detail)
|
195
|
+
assert(!opts.show_clr_exceptions)
|
196
|
+
assert_equal(1, opts.warning_level)
|
197
|
+
assert(!opts.debug_variable)
|
198
|
+
assert(!opts.profile)
|
199
|
+
assert(!opts.trace)
|
200
|
+
assert(opts.required_paths.empty?)
|
201
|
+
assert(opts.search_paths.empty?)
|
202
|
+
assert(!opts.pass_exceptions)
|
203
|
+
assert(!opts.private_binding)
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_to_hash
|
207
|
+
opts = IRPack::Specification::RuntimeOptions.new
|
208
|
+
opts.debug_mode = true
|
209
|
+
opts.no_adaptive_compilation = true
|
210
|
+
opts.compilation_threshold = 42
|
211
|
+
opts.exception_detail = true
|
212
|
+
opts.show_clr_exceptions = true
|
213
|
+
opts.warning_level = 2
|
214
|
+
opts.debug_variable = true
|
215
|
+
opts.profile = true
|
216
|
+
opts.trace = true
|
217
|
+
opts.required_paths << 'stringio'
|
218
|
+
opts.search_paths << 'lib'
|
219
|
+
opts.pass_exceptions = true
|
220
|
+
opts.private_binding = true
|
221
|
+
hash = opts.to_hash
|
222
|
+
assert_equal(opts.debug_mode, hash[:DebugMode])
|
223
|
+
assert_equal(opts.private_binding, hash[:PrivateBinding])
|
224
|
+
assert_equal(opts.no_adaptive_compilation, hash[:NoAdaptiveCompilation])
|
225
|
+
assert_equal(opts.compilation_threshold, hash[:CompilationThreshold])
|
226
|
+
assert_equal(opts.exception_detail, hash[:ExceptionDetail])
|
227
|
+
assert_equal(opts.show_clr_exceptions, hash[:ShowClrExceptions])
|
228
|
+
assert_equal(opts.pass_exceptions, hash[:PassExceptions])
|
229
|
+
assert_equal(opts.profile, hash[:Profile])
|
230
|
+
assert_equal(opts.warning_level, hash[:Verbosity])
|
231
|
+
assert_equal(opts.debug_variable, hash[:DebugVariable])
|
232
|
+
assert_equal(opts.trace, hash[:EnableTracing])
|
233
|
+
assert_equal(opts.required_paths, hash[:RequiredPaths])
|
234
|
+
assert_equal(opts.search_paths, hash[:SearchPaths])
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
data/test/utils.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: irpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- kumaryu
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-12-24 00:00:00 +09:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -33,14 +33,19 @@ files:
|
|
33
33
|
- lib/irpack/entrypoint.rb
|
34
34
|
- lib/irpack/missing.rb
|
35
35
|
- lib/irpack/packager.rb
|
36
|
+
- lib/irpack/rake/generateexetask.rb
|
37
|
+
- lib/irpack/specification.rb
|
36
38
|
- lib/irpack.rb
|
39
|
+
- test/fixtures/foo.rb
|
37
40
|
- test/test_application.rb
|
38
41
|
- test/test_bootloader.rb
|
39
42
|
- test/test_cscompiler.rb
|
40
43
|
- test/test_entrypoint.rb
|
44
|
+
- test/test_generateexetask.rb
|
41
45
|
- test/test_irpack.rb
|
42
46
|
- test/test_missing.rb
|
43
47
|
- test/test_packager.rb
|
48
|
+
- test/test_specification.rb
|
44
49
|
- test/utils.rb
|
45
50
|
- README.rdoc
|
46
51
|
has_rdoc: true
|
@@ -73,11 +78,14 @@ signing_key:
|
|
73
78
|
specification_version: 3
|
74
79
|
summary: Generate a standalone executable file from IronRuby scripts.
|
75
80
|
test_files:
|
81
|
+
- test/fixtures/foo.rb
|
76
82
|
- test/test_application.rb
|
77
83
|
- test/test_bootloader.rb
|
78
84
|
- test/test_cscompiler.rb
|
79
85
|
- test/test_entrypoint.rb
|
86
|
+
- test/test_generateexetask.rb
|
80
87
|
- test/test_irpack.rb
|
81
88
|
- test/test_missing.rb
|
82
89
|
- test/test_packager.rb
|
90
|
+
- test/test_specification.rb
|
83
91
|
- test/utils.rb
|