autotest 4.4.3 → 4.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -8,6 +8,7 @@ Improvements over ZenTest
8
8
  - `-r` use given config file
9
9
  - `-p` use parallel_tests to run tests (Test::Unit only)
10
10
  - `-s` use any style you want -> `alias autospec2="autotest --style rspec2"`
11
+ - `-b` use bundle exec to run tests
11
12
  - simplified test setup
12
13
  - simplified packaging
13
14
  - less globals
@@ -38,6 +39,7 @@ Usage
38
39
  -q, --quiet Be quiet.
39
40
  -r, --rc CONFIG Path to config file. (Defaults to ~/.autotest or current_dir/.autotest)
40
41
  -s, --style STYLE Which style to use, e.g. rspec, rspec2
42
+ -b, --bundle-exec Use bundle exec to run tests
41
43
  -h, --help Show this.
42
44
 
43
45
  Windows needs [diff.exe](http://gnuwin32.sourceforge.net/packages.html)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.4.3
1
+ 4.4.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{autotest}
8
- s.version = "4.4.3"
8
+ s.version = "4.4.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Davis"]
12
- s.date = %q{2010-11-15}
12
+ s.date = %q{2010-11-16}
13
13
  s.executables = ["autotest", "unit_diff"]
14
14
  s.files = [
15
15
  ".autotest",
@@ -26,6 +26,9 @@ BANNER
26
26
  opts.on("-s", "--style STYLE", "Which style to use, e.g. rspec, rspec2") do |style|
27
27
  options[:style] = style
28
28
  end
29
+ opts.on("-b", "--bundle-exec", "Use bundle exec to run tests") do
30
+ options[:bundle_exec] = true
31
+ end
29
32
  opts.on("-h", "--help","Show this.") { puts opts;exit }
30
33
  end.parse!
31
34
 
@@ -61,4 +64,4 @@ unless style.empty?
61
64
  puts "style: #{style.map {|s| s.capitalize}.join}"
62
65
  target = Autotest.const_get(style.map {|s| s.capitalize}.join)
63
66
  end
64
- target.run
67
+ target.run
@@ -183,7 +183,13 @@ class Autotest
183
183
  self.find_directories = ['.']
184
184
  self.unit_diff = "#{File.expand_path("#{File.dirname(__FILE__)}/../bin/unit_diff")} -u"
185
185
 
186
- #add Test::Unit mappings
186
+ add_test_unit_mappings
187
+
188
+ #execute custom extensions
189
+ load_custom_extensions(options[:rc])
190
+ end
191
+
192
+ def add_test_unit_mappings
187
193
  #file in /lib -> run test in /test
188
194
  self.add_mapping(/^lib\/.*\.rb$/) do |filename, _|
189
195
  possible = File.basename(filename).gsub '_', '_?'
@@ -194,9 +200,6 @@ class Autotest
194
200
  self.add_mapping(/^test.*\/test_.*rb$/) do |filename, _|
195
201
  filename
196
202
  end
197
-
198
- #execute custom extensions
199
- load_custom_extensions(options[:rc])
200
203
  end
201
204
 
202
205
  def load_custom_extensions(config_file)
@@ -446,12 +449,12 @@ class Autotest
446
449
  def make_test_cmd files_to_test
447
450
  cmds = []
448
451
  full, partial = reorder(files_to_test).partition { |k,v| v.empty? }
449
- base_cmd = "#{ruby} -I#{libs} -rubygems"
452
+ base_cmd = "#{bundle_exec}#{ruby} -I#{libs} -rubygems"
450
453
 
451
454
  unless full.empty? then
452
455
  classes = full.map {|k,v| k}.flatten.uniq
453
456
  if options[:parallel] and classes.size > 1
454
- cmds << "parallel_test #{escape_filenames(classes).join(' ')}"
457
+ cmds << "#{bundle_exec}parallel_test #{escape_filenames(classes).join(' ')}"
455
458
  else
456
459
  classes.unshift testlib
457
460
  cmds << "#{base_cmd} -e \"[#{escape_filenames(classes).join(', ')}].each { |f| require f }\" | #{unit_diff}"
@@ -466,6 +469,10 @@ class Autotest
466
469
  cmds.join("#{SEP} ")
467
470
  end
468
471
 
472
+ def bundle_exec
473
+ options[:bundle_exec] ? 'bundle exec ' : ''
474
+ end
475
+
469
476
  def escape_filenames(classes)
470
477
  classes.map{|klass| "'#{klass}'"}
471
478
  end
@@ -46,6 +46,8 @@ class TestAutotest < Test::Unit::TestCase
46
46
  @a = klassname.split(/::/).inject(Object) { |k,n| k.const_get(n) }.new
47
47
  @a.output = StringIO.new
48
48
  @a.last_mtime = Time.at(2)
49
+ @a.options[:bundle_exec] = nil
50
+ @a.options[:parallel] = nil
49
51
 
50
52
  @files = {}
51
53
  @files[@impl] = Time.at(1)
@@ -359,7 +361,7 @@ test_error2(#{@test_class}):
359
361
  assert @a.hook(:blah)
360
362
  end
361
363
 
362
- def test_make_test_cmd
364
+ def test_make_test_cmd_basics
363
365
  f = {
364
366
  @test => [],
365
367
  'test/test_fooby.rb' => [ 'test_something1', 'test_something2' ]
@@ -379,6 +381,45 @@ test_error2(#{@test_class}):
379
381
  assert_equal expected, result
380
382
  end
381
383
 
384
+ def test_make_test_cmd_uses_bundle_exec_when_given
385
+ @a.options[:bundle_exec] = true
386
+ f = {
387
+ @test => []
388
+ }
389
+ result = @a.make_test_cmd f
390
+ assert_match /^bundle exec \//,result
391
+ end
392
+
393
+ def test_make_test_cmd_uses_bundle_exec_with_parallel_test
394
+ @a.options[:bundle_exec] = true
395
+ @a.options[:parallel] = true
396
+ f = {
397
+ 'test/a.rb' => [],
398
+ 'test/b.rb' => []
399
+ }
400
+ result = @a.make_test_cmd f
401
+ assert_match /^bundle exec parallel_test/, result
402
+ end
403
+
404
+ def test_make_test_cmd_uses_parallel_with_multiple_files
405
+ @a.options[:parallel] = true
406
+ f = {
407
+ 'test/a.rb' => [],
408
+ 'test/b.rb' => []
409
+ }
410
+ result = @a.make_test_cmd f
411
+ assert_match /^parallel_test/, result
412
+ end
413
+
414
+ def test_make_test_cmd_does_not_use_parallel_for_single_file
415
+ @a.options[:parallel] = true
416
+ f = {
417
+ 'test/a.rb' => []
418
+ }
419
+ result = @a.make_test_cmd f
420
+ assert_equal nil, (/^parallel_test/ =~ result)
421
+ end
422
+
382
423
  def test_path_to_classname
383
424
  # non-rails
384
425
  util_path_to_classname 'TestBlah', 'test/test_blah.rb'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autotest
3
3
  version: !ruby/object:Gem::Version
4
- hash: 41
4
+ hash: 39
5
5
  prerelease: false
6
6
  segments:
7
7
  - 4
8
8
  - 4
9
- - 3
10
- version: 4.4.3
9
+ - 4
10
+ version: 4.4.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Davis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-15 00:00:00 +01:00
18
+ date: 2010-11-16 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21