ocra 1.2.0 → 1.3.0.rc1

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.
@@ -1,3 +1,3 @@
1
1
  class Ocra
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0.rc1'
3
3
  end
Binary file
Binary file
Binary file
@@ -2,6 +2,7 @@ require "test/unit"
2
2
  require "tmpdir"
3
3
  require "fileutils"
4
4
  require "rbconfig"
5
+ require "pathname"
5
6
 
6
7
  begin
7
8
  require "rubygems"
@@ -94,13 +95,37 @@ class TestOcra < Test::Unit::TestCase
94
95
  end
95
96
  end
96
97
 
98
+ def each_path_combo(*files)
99
+ # In same directory as first file
100
+ basedir = Pathname.new(files[0]).realpath.parent
101
+ args = files.map{|p|Pathname.new(p).realpath.relative_path_from(basedir).to_s}
102
+ cd basedir do
103
+ yield(*args)
104
+ end
105
+
106
+ # In parent directory of first file
107
+ basedir = basedir.parent
108
+ args = files.map{|p|Pathname.new(p).realpath.relative_path_from(basedir).to_s}
109
+ cd basedir do
110
+ yield(*args)
111
+ end
112
+
113
+ # In a completely different directory
114
+ args = files.map{|p|Pathname.new(p).realpath.to_s}
115
+ with_tmpdir do
116
+ yield(*args)
117
+ end
118
+ end
119
+
97
120
  # Hello world test. Test that we can build and run executables.
98
121
  def test_helloworld
99
122
  with_fixture 'helloworld' do
100
- assert system("ruby", ocra, "helloworld.rb", *DefaultArgs)
101
- assert File.exist?("helloworld.exe")
102
- pristine_env "helloworld.exe" do
103
- assert system("helloworld.exe")
123
+ each_path_combo "helloworld.rb" do |script|
124
+ assert system("ruby", ocra, script, *DefaultArgs)
125
+ assert File.exist?("helloworld.exe")
126
+ pristine_env "helloworld.exe" do
127
+ assert system("helloworld.exe")
128
+ end
104
129
  end
105
130
  end
106
131
  end
@@ -121,11 +146,82 @@ class TestOcra < Test::Unit::TestCase
121
146
  def test_writefile
122
147
  with_fixture 'writefile' do
123
148
  assert system("ruby", ocra, "writefile.rb", *DefaultArgs)
149
+ assert File.exist?("output.txt") # Make sure ocra ran the script during build
124
150
  pristine_env "writefile.exe" do
125
151
  assert File.exist?("writefile.exe")
126
152
  assert system("writefile.exe")
127
153
  assert File.exist?("output.txt")
128
- assert "output", File.read("output.txt")
154
+ assert_equal "output", File.read("output.txt")
155
+ end
156
+ end
157
+ end
158
+
159
+ # With --no-dep-run, ocra should not run script during build
160
+ def test_nodeprun
161
+ with_fixture 'writefile' do
162
+ assert system("ruby", ocra, "writefile.rb", *(DefaultArgs + ["--no-dep-run"]))
163
+ assert !File.exist?("output.txt")
164
+ pristine_env "writefile.exe" do
165
+ assert File.exist?("writefile.exe")
166
+ assert system("writefile.exe")
167
+ assert File.exist?("output.txt")
168
+ assert_equal "output", File.read("output.txt")
169
+ end
170
+ end
171
+ end
172
+
173
+ # With dep run disabled but including all core libs, should be able
174
+ # to use ruby standard libraries (i.e. cgi)
175
+ def test_rubycoreincl
176
+ with_fixture 'rubycoreincl' do
177
+ assert system("ruby", ocra, "rubycoreincl.rb", *(DefaultArgs + ["--no-dep-run", "--add-all-core"]))
178
+ pristine_env "rubycoreincl.exe" do
179
+ assert File.exist?("rubycoreincl.exe")
180
+ assert system("rubycoreincl.exe")
181
+ assert File.exist?("output.txt")
182
+ assert_equal "3 &lt; 5", File.read("output.txt")
183
+ end
184
+ end
185
+ end
186
+
187
+ # With dep run disabled but including corelibs and using a Bundler Gemfile, specified gems should
188
+ # be automatically included and usable in packaged app
189
+ def test_gemfile
190
+ with_fixture 'bundlerusage' do
191
+ assert system("ruby", ocra, "bundlerusage.rb", "Gemfile", *(DefaultArgs + ["--no-dep-run", "--add-all-core", "--gemfile", "Gemfile"]))
192
+ pristine_env "bundlerusage.exe" do
193
+ assert system("bundlerusage.exe")
194
+ end
195
+ end
196
+ end
197
+
198
+ # With --debug-extract option, exe should unpack to local directory and leave it in place
199
+ def test_debug_extract
200
+ with_fixture 'helloworld' do
201
+ assert system("ruby", ocra, "helloworld.rb", *(DefaultArgs + ["--debug-extract"]))
202
+ pristine_env "helloworld.exe" do
203
+ assert_equal 0, Dir["ocr*"].size
204
+ assert system("helloworld.exe")
205
+ assert_equal 1, Dir["ocr*"].size
206
+ end
207
+ end
208
+ end
209
+
210
+ # Test that the --output option allows us to specify a different exe name
211
+ def test_output_option
212
+ with_fixture 'helloworld' do
213
+ assert system("ruby", ocra, "helloworld.rb", *(DefaultArgs + ["--output", "goodbyeworld.exe"]))
214
+ assert !File.exists?("helloworld.exe")
215
+ assert File.exists?("goodbyeworld.exe")
216
+ end
217
+ end
218
+
219
+ # Test that we can specify a directory to be recursively included
220
+ def test_directory_on_cmd_line
221
+ with_fixture 'subdir' do
222
+ assert system("ruby", ocra, "subdir.rb", "a", *DefaultArgs)
223
+ pristine_env "subdir.exe" do
224
+ assert system("subdir.exe")
129
225
  end
130
226
  end
131
227
  end
@@ -295,97 +391,122 @@ class TestOcra < Test::Unit::TestCase
295
391
  end
296
392
  end
297
393
 
298
- # Test that we can use custom include paths when invoking Ocra (ruby
299
- # -I somepath). In this case the lib scripts are put in the src/
300
- # directory.
301
- def test_relative_loadpath1_ilib
302
- with_fixture 'relloadpath1' do
303
- assert system('ruby', '-I', 'lib', ocra, 'relloadpath1.rb', *DefaultArgs)
304
- assert File.exist?('relloadpath1.exe')
305
- pristine_env "relloadpath1.exe" do
306
- assert system('relloadpath1.exe')
394
+ # Should find features via relative require paths, after script
395
+ # changes to the right directory (Only valid for Ruby < 1.9.2).
396
+ def test_relative_require_chdir_path
397
+ with_fixture "relloadpath" do
398
+ each_path_combo "bin/chdir1.rb" do |script|
399
+ assert system('ruby', ocra, script, *DefaultArgs)
400
+ assert File.exist?('chdir1.exe')
401
+ pristine_env "chdir1.exe" do
402
+ assert system('chdir1.exe')
403
+ end
307
404
  end
308
405
  end
309
406
  end
310
407
 
311
- # Same as above with './lib'
312
- def test_relative_loadpath_idotlib
313
- with_fixture 'relloadpath1' do
314
- assert system('ruby', '-I', './lib', ocra, 'relloadpath1.rb', *DefaultArgs)
315
- assert File.exist?('relloadpath1.exe')
316
- pristine_env "relloadpath1.exe" do
317
- assert system('relloadpath1.exe')
408
+ # Should find features via relative require paths prefixed with
409
+ # './', after script changes to the right directory.
410
+ def test_relative_require_chdir_dotpath
411
+ with_fixture "relloadpath" do
412
+ each_path_combo "bin/chdir2.rb" do |script|
413
+ assert system('ruby', ocra, script, *DefaultArgs)
414
+ assert File.exist?('chdir2.exe')
415
+ pristine_env "chdir2.exe" do
416
+ assert system('chdir2.exe')
417
+ end
318
418
  end
319
419
  end
320
420
  end
321
421
 
322
- # Test that we can use custom include paths when invoking Ocra (env
323
- # RUBYLIB=lib). In this case the lib scripts are put in the src/
324
- # directory.
325
- def test_relative_loadpath_rubyliblib
326
- with_fixture 'relloadpath1' do
327
- with_env 'RUBYLIB' => 'lib' do
328
- assert system('ruby', ocra, 'relloadpath1.rb', *DefaultArgs)
329
- assert File.exist?('relloadpath1.exe')
330
- pristine_env "relloadpath1.exe" do
331
- assert system('relloadpath1.exe')
422
+ # Should pick up files from relative load paths specified using the
423
+ # -I option when invoking Ocra, and invoking from same directory as
424
+ # script.
425
+ def test_relative_require_i
426
+ with_fixture 'relloadpath' do
427
+ each_path_combo "bin/external.rb", "lib", "bin/sub" do |script, *loadpaths|
428
+ assert system('ruby', '-I', loadpaths[0], '-I', loadpaths[1], ocra, script, *DefaultArgs)
429
+ assert File.exist?('external.exe')
430
+ pristine_env "external.exe" do
431
+ assert system('external.exe')
332
432
  end
333
433
  end
334
434
  end
335
435
  end
336
436
 
337
- # Same as above with './lib'
338
- def test_relative_loadpath_rubylibdotlib
339
- with_fixture 'relloadpath1' do
340
- with_env 'RUBYLIB' => './lib' do
341
- assert system('ruby', ocra, 'relloadpath1.rb', *DefaultArgs)
342
- assert File.exist?('relloadpath1.exe')
343
- pristine_env "relloadpath1.exe" do
344
- assert system('relloadpath1.exe')
437
+ # Should pick up files from relative load path specified using the
438
+ # RUBYLIB environment variable.
439
+ def test_relative_require_rubylib
440
+ with_fixture 'relloadpath' do
441
+ each_path_combo "bin/external.rb", "lib", "bin/sub" do |script, *loadpaths|
442
+ with_env 'RUBYLIB' => loadpaths.join(';') do
443
+ assert system('ruby', ocra, script, *DefaultArgs)
444
+ end
445
+ assert File.exist?('external.exe')
446
+ pristine_env "external.exe" do
447
+ assert system('external.exe')
345
448
  end
346
449
  end
347
450
  end
348
451
  end
349
-
350
- # Relative path with .. prefix (../lib).
351
- def test_relative_loadpath2_idotdotlib
352
- with_fixture 'relloadpath2' do
353
- cd 'src' do
354
- assert system('ruby', '-I', '../lib', ocra, 'relloadpath2.rb', *DefaultArgs)
355
- assert File.exist?('relloadpath2.exe')
356
- pristine_env "relloadpath2.exe" do
357
- assert system('relloadpath2.exe')
452
+
453
+ # Should pick up file when script modifies $LOAD_PATH by adding
454
+ # dirname of script.
455
+ def test_loadpath_mangling_dirname
456
+ with_fixture 'relloadpath' do
457
+ each_path_combo "bin/loadpath0.rb" do |script|
458
+ assert system('ruby', ocra, script, *DefaultArgs)
459
+ assert File.exist?('loadpath0.exe')
460
+ pristine_env "loadpath0.exe" do
461
+ assert system('loadpath0.exe')
358
462
  end
359
463
  end
360
464
  end
361
465
  end
362
466
 
363
- # Test that scripts which modify $LOAD_PATH with a relative path
364
- # (./lib) work correctly.
365
- def test_relloadpath3
366
- with_fixture 'relloadpath3' do
367
- assert system('ruby', ocra, 'relloadpath3.rb', *DefaultArgs)
368
- assert File.exist?('relloadpath3.exe')
369
- pristine_env "relloadpath3.exe" do
370
- assert system('relloadpath3.exe')
467
+ # Should pick up file when script modifies $LOAD_PATH by adding
468
+ # relative paths, and invoking from same directory.
469
+ def test_loadpath_mangling_path
470
+ with_fixture 'relloadpath' do
471
+ each_path_combo "bin/loadpath1.rb" do |script|
472
+ # p [Dir.pwd, script]
473
+ assert system('ruby', ocra, script, *DefaultArgs)
474
+ assert File.exist?('loadpath1.exe')
475
+ pristine_env "loadpath1.exe" do
476
+ assert system('loadpath1.exe')
477
+ end
371
478
  end
372
479
  end
373
480
  end
374
481
 
375
- # Test that scripts which modify $LOAD_PATH with a relative path
376
- # (../lib) work correctly.
377
- def test_relloadpath4
378
- with_fixture 'relloadpath4' do
379
- cd 'src' do
380
- assert system('ruby', ocra, 'relloadpath4.rb', *DefaultArgs)
381
- assert File.exist?('relloadpath4.exe')
382
- pristine_env "relloadpath4.exe" do
383
- assert system('relloadpath4.exe')
482
+ # Should pick up file when script modifies $LOAD_PATH by adding
483
+ # relative paths with './'-prefix
484
+ def test_loadpath_mangling_dotpath
485
+ with_fixture 'relloadpath' do
486
+ each_path_combo "bin/loadpath2.rb" do |script|
487
+ assert system('ruby', ocra, script, *DefaultArgs)
488
+ assert File.exist?('loadpath2.exe')
489
+ pristine_env "loadpath2.exe" do
490
+ assert system('loadpath2.exe')
384
491
  end
385
492
  end
386
493
  end
387
494
  end
388
495
 
496
+ # Should pick up file when script modifies $LOAD_PATH by adding
497
+ # absolute paths.
498
+ def test_loadpath_mangling_abspath
499
+ with_fixture 'relloadpath' do
500
+ each_path_combo "bin/loadpath3.rb" do |script|
501
+ assert system('ruby', ocra, script, *DefaultArgs)
502
+ assert File.exist?('loadpath3.exe')
503
+ pristine_env "loadpath3.exe" do
504
+ assert system('loadpath3.exe')
505
+ end
506
+ end
507
+ end
508
+ end
509
+
389
510
  # Test that ocra.rb accepts --version and outputs the version number.
390
511
  def test_version
391
512
  assert_match(/^Ocra \d+(\.\d)+(.[a-z]+\d+)?$/, `ruby \"#{ocra}\" --version`)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocra
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease: false
4
+ prerelease: true
6
5
  segments:
7
6
  - 1
8
- - 2
7
+ - 3
9
8
  - 0
10
- version: 1.2.0
9
+ - rc1
10
+ version: 1.3.0.rc1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lars Christensen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-02 00:00:00 +02:00
18
+ date: 2010-12-19 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,7 +26,6 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 7
30
29
  segments:
31
30
  - 2
32
31
  - 0
@@ -42,7 +41,6 @@ dependencies:
42
41
  requirements:
43
42
  - - ">="
44
43
  - !ruby/object:Gem::Version
45
- hash: 21
46
44
  segments:
47
45
  - 2
48
46
  - 6
@@ -63,11 +61,11 @@ extensions: []
63
61
  extra_rdoc_files:
64
62
  - History.txt
65
63
  - Manifest.txt
66
- - README.txt
64
+ - README.rdoc
67
65
  files:
68
66
  - History.txt
69
67
  - Manifest.txt
70
- - README.txt
68
+ - README.rdoc
71
69
  - Rakefile
72
70
  - bin/ocra
73
71
  - share/ocra/lzma.exe
@@ -91,19 +89,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
89
  requirements:
92
90
  - - ">="
93
91
  - !ruby/object:Gem::Version
94
- hash: 3
95
92
  segments:
96
93
  - 0
97
94
  version: "0"
98
95
  required_rubygems_version: !ruby/object:Gem::Requirement
99
96
  none: false
100
97
  requirements:
101
- - - ">="
98
+ - - ">"
102
99
  - !ruby/object:Gem::Version
103
- hash: 3
104
100
  segments:
105
- - 0
106
- version: "0"
101
+ - 1
102
+ - 3
103
+ - 1
104
+ version: 1.3.1
107
105
  requirements: []
108
106
 
109
107
  rubyforge_project: ocra