rubygems-test 0.3.12 → 0.4.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,11 @@
1
+ === 0.4.0.rc1 / 2011-04-17
2
+
3
+ * Pretty much nailed the reader problem to the wall.
4
+ * Now able to test .gem files directly on the commandline.
5
+ * Use the new hooks to uninstall gems if they fail testing. Bump the rubygems
6
+ requirement to 1.5 to reflect above changes.
7
+ * Specify the exec_name for Gem.bin_path. [Postmodern]
8
+
1
9
  === 0.3.11 / 2011-03-13
2
10
 
3
11
  * Now sending :rubygems_test_version which is the version of rubygems-test used for the upload.
data/Rakefile CHANGED
@@ -32,7 +32,7 @@ spec = Hoe.spec 'rubygems-test' do
32
32
  pluggable!
33
33
 
34
34
  require_ruby_version ">= 1.8.7"
35
- require_rubygems_version ">= 1.3.6"
35
+ require_rubygems_version ">= 1.5.0"
36
36
 
37
37
  extra_deps << ['rake', '>= 0.8.7']
38
38
 
@@ -9,12 +9,13 @@ require 'rbconfig'
9
9
  autoload(:YAML, 'yaml')
10
10
  require 'net/http'
11
11
  require 'uri'
12
+ require 'tempfile'
12
13
 
13
14
  class Gem::Commands::TestCommand < Gem::Command
14
15
  include Gem::VersionOption
15
16
  include Gem::DefaultUserInteraction
16
17
 
17
- VERSION = "0.3.12"
18
+ VERSION = "0.4.0.rc1"
18
19
 
19
20
  # taken straight out of rake
20
21
  DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb']
@@ -82,9 +83,9 @@ class Gem::Commands::TestCommand < Gem::Command
82
83
  #
83
84
  # Locate the rakefile for a gem name and version
84
85
  #
85
- def find_rakefile(spec)
86
+ def find_rakefile(path, spec)
86
87
  rakefile = DEFAULT_RAKEFILES.
87
- map { |x| File.join(spec.full_gem_path, x) }.
88
+ map { |x| File.join(path, x) }.
88
89
  find { |x| File.exist?(x) }
89
90
 
90
91
  unless(File.exist?(rakefile) rescue nil)
@@ -297,39 +298,60 @@ class Gem::Commands::TestCommand < Gem::Command
297
298
  def read_output(stdout, stderr)
298
299
  require 'thread'
299
300
 
300
- STDOUT.sync = true
301
- STDERR.sync = true
302
- stdout.sync = true
303
- stderr.sync = true
301
+ [STDERR, $stderr, stderr, STDOUT, $stdout, stdout].map { |x| x.sync = true }
304
302
 
303
+ reads = Queue.new
305
304
  output = ""
306
- mutex = Mutex.new
307
305
 
308
306
  err_t = Thread.new do
309
307
  while !stderr.eof?
310
- tmp = stderr.readline
311
- mutex.synchronize do
312
- output << tmp
313
- print tmp
314
- end
308
+ ary = [:stderr, nil, stderr.readline]
309
+ ary[1] = Time.now.to_f
310
+ reads << ary
315
311
  end
316
312
  end
317
313
 
318
314
  out_t = Thread.new do
319
315
  while !stdout.eof?
320
- tmp = stdout.read(1)
321
- mutex.synchronize do
322
- output << tmp
323
- print tmp
316
+ ary = [:stdout, nil, stdout.read(1)]
317
+ ary[1] = Time.now.to_f
318
+ reads << ary
319
+ end
320
+ end
321
+
322
+ tty_t = Thread.new do
323
+ next_time = nil
324
+ while true
325
+ while reads.length > 0
326
+ cur_reads = [next_time || reads.shift]
327
+
328
+ time = cur_reads[0][1]
329
+
330
+ while next_time = reads.shift
331
+ break if next_time[1] != time
332
+ cur_reads << next_time
333
+ end
334
+
335
+ stderr_reads, stdout_reads = cur_reads.partition { |x| x[0] == :stderr }
336
+
337
+ # stderr wins
338
+ (stderr_reads + stdout_reads).each do |rec|
339
+ output << rec[2]
340
+ print rec[2]
341
+ end
324
342
  end
325
343
  end
326
344
  end
327
345
 
328
- while !stderr.eof? or !stdout.eof?
346
+ while !stderr.eof? or !stdout.eof? or !reads.empty?
329
347
  Thread.pass
330
348
  end
331
349
 
332
- return output
350
+ sleep 1
351
+ tty_t.kill
352
+ puts
353
+
354
+ return output + "\n"
333
355
  end
334
356
 
335
357
  #
@@ -403,8 +425,8 @@ class Gem::Commands::TestCommand < Gem::Command
403
425
  # Run the tests with the appropriate spec and rake_path, and capture all
404
426
  # output.
405
427
  #
406
- def run_tests(spec, rake_path)
407
- Dir.chdir(spec.full_gem_path) do
428
+ def run_tests(path, spec, rake_path)
429
+ Dir.chdir(path) do
408
430
  rake_args = get_rake_args(rake_path, 'test')
409
431
 
410
432
  @trapped = false
@@ -460,22 +482,42 @@ class Gem::Commands::TestCommand < Gem::Command
460
482
  terminate_interaction 1
461
483
  end
462
484
 
463
- spec = find_gem(name, version)
464
-
465
- unless spec
466
- say "unable to find gem #{name} #{version}"
467
- next
468
- end
469
-
470
- if File.exist?(File.join(spec.full_gem_path, '.gemtest')) or options[:force]
485
+ path, spec = if name =~ /\.gem$/
486
+ unless File.exist?(name)
487
+ say "unable to find gem #{name}"
488
+ next
489
+ end
490
+
491
+ inst = Gem::Installer.new(name)
492
+ tmpdir = Dir.mktmpdir
493
+ @created_tmpdir = true
494
+ inst.unpack(tmpdir)
495
+ unless inst.spec.extensions.empty?
496
+ say "gem #{name} has extensions. Due to limitations in rubygems,"
497
+ say "the gem must be installed before it can be tested."
498
+ next
499
+ end
500
+ [tmpdir, inst.spec]
501
+ else
502
+ spec = find_gem(name, version)
503
+
504
+ unless spec
505
+ say "unable to find gem #{name} #{version}"
506
+ next
507
+ end
508
+
509
+ [spec.full_gem_path, spec]
510
+ end
511
+
512
+ if File.exist?(File.join(path, '.gemtest')) or options[:force]
471
513
  # we find rake and the rakefile first to eliminate needlessly installing
472
514
  # dependencies.
473
- find_rakefile(spec)
515
+ find_rakefile(path, spec)
474
516
  rake_path = find_rake
475
517
 
476
518
  unless $RG_T_INSTALLING_DEPENDENCIES and !config["test_development_dependencies"]
477
519
  install_dependencies(spec)
478
- run_tests(spec, rake_path)
520
+ run_tests(path, spec, rake_path)
479
521
  end
480
522
  else
481
523
  say "Gem '#{name}' (version #{version}) needs to opt-in for testing."
@@ -492,8 +534,12 @@ class Gem::Commands::TestCommand < Gem::Command
492
534
  say "For more information, please see the rubygems-test README:"
493
535
  say "https://github.com/rubygems/rubygems-test/blob/master/README.txt"
494
536
  end
537
+
538
+ if @created_tmpdir
539
+ FileUtils.rm_rf path
540
+ end
495
541
  end
496
- rescue Gem::TestError
542
+ rescue Gem::TestError => e
497
543
  raise if @on_install
498
544
  terminate_interaction 1
499
545
  end
@@ -3,7 +3,7 @@ Gem::Commands.autoload(:TestCommand, 'rubygems/commands/test_command')
3
3
  Gem.autoload(:RakeNotFoundError, 'exceptions')
4
4
  Gem.autoload(:TestError, 'exceptions')
5
5
 
6
- Gem.post_install do |gem|
6
+ Gem.post_build do |gem|
7
7
  options = Gem.configuration["test_options"] || { }
8
8
 
9
9
  if options["auto_test_on_install"] or options["test_on_install"]
@@ -12,14 +12,13 @@ Gem.post_install do |gem|
12
12
 
13
13
  begin
14
14
  Gem::Commands::TestCommand.new(gem.spec, true).execute
15
+ true
15
16
  rescue Gem::RakeNotFoundError, Gem::TestError
16
- if (options.has_key?("force_install") and !options["force_install"]) or
17
- options["force_uninstall_on_failure"] or
18
- gem.ui.ask_yes_no("Testing #{gem.spec.name} (#{gem.spec.version}) failed. Uninstall?", false)
19
-
20
- # FIXME ask drbrain how to do this more better.
21
- at_exit { Gem::Uninstaller.new(gem.spec.name, :version => gem.spec.version).uninstall }
22
- end
17
+ !(
18
+ (options.has_key?("force_install") && !options["force_install"]) ||
19
+ options["force_uninstall_on_failure"] ||
20
+ gem.ui.ask_yes_no("Testing #{gem.spec.name} (#{gem.spec.version}) failed. Uninstall?", false)
21
+ )
23
22
  end
24
23
  end
25
24
  end
@@ -36,12 +36,16 @@ class TestExecute < Test::Unit::TestCase
36
36
  def test_05_find_rakefile
37
37
  install_stub_gem({ :files => ["Rakefile"] })
38
38
 
39
- assert_nothing_raised { @test.find_rakefile(@test.find_gem("test-gem", "0.0.0")) }
39
+ spec = @test.find_gem('test-gem', '0.0.0')
40
+
41
+ assert_nothing_raised { @test.find_rakefile(spec.full_gem_path, spec) }
40
42
 
41
43
  uninstall_stub_gem
42
44
  install_stub_gem({ :files => "" })
43
45
 
44
- assert_raises(Gem::RakeNotFoundError) { @test.find_rakefile(@test.find_gem("test-gem", "0.0.0")) }
46
+ spec = @test.find_gem('test-gem', '0.0.0')
47
+
48
+ assert_raises(Gem::RakeNotFoundError) { @test.find_rakefile(spec.full_gem_path, spec) }
45
49
 
46
50
  uninstall_stub_gem
47
51
  end
@@ -81,5 +85,4 @@ class TestExecute < Test::Unit::TestCase
81
85
  ensure
82
86
  Gem.configuration.verbose = old_verbose
83
87
  end
84
-
85
88
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-test
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.3.12
4
+ prerelease: 6
5
+ version: 0.4.0.rc1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Erik Hollensbe
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-04-08 00:00:00 Z
14
+ date: 2011-04-17 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: 1.3.6
88
+ version: 1.5.0
89
89
  requirements: []
90
90
 
91
91
  rubyforge_project: