jason-o-matic-deep_test 1.2.2.8 → 1.2.2.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -66,5 +66,15 @@ module DeepTest
66
66
  a.split(File::PATH_SEPARATOR)
67
67
  end
68
68
  end
69
+
70
+ module Symbol
71
+ def self.to_string(s)
72
+ s.to_s
73
+ end
74
+
75
+ def self.from_string(s)
76
+ s.to_sym
77
+ end
78
+ end
69
79
  end
70
80
  end
@@ -13,6 +13,7 @@ module DeepTest
13
13
  Option.new(:worker_listener, Option::String, "DeepTest::NullWorkerListener"),
14
14
  Option.new(:libs, Option::Array, []),
15
15
  Option.new(:requires, Option::Array, []),
16
+ Option.new(:test_collector, Option::Symbol, :objectspace),
16
17
  ]
17
18
  end
18
19
 
@@ -0,0 +1,57 @@
1
+ require 'test/unit/collector/objectspace'
2
+ module DeepTest
3
+ module Test
4
+ module Collector
5
+
6
+ # This allows us to run tests in a similar order to how rails normal runs them
7
+ # (i.e. units, functionals, integration) without having to mintain the test file
8
+ # loading order and passing it down the line somehow.
9
+ class RailsOrderedObjectSpace < ::Test::Unit::Collector::ObjectSpace
10
+
11
+ # this is like ::Test::Unit::AutoRunner::COLLECTORS[:objectspace] in standard Test::Unit
12
+ ::Test::Unit::AutoRunner::COLLECTORS[:rails_ordered_objectspace] = proc do |r|
13
+ c = DeepTest::Test::Collector::RailsOrderedObjectSpace.new
14
+ c.filter = r.filters
15
+ c.collect($0.sub(/\.rb\Z/, ''))
16
+ end
17
+
18
+ def sort(suites)
19
+ done = int = filter_and_sort_suites(suites, ActionController::IntegrationTest)
20
+ done += func = filter_and_sort_suites(suites - done, ActionController::TestCase)
21
+ done += others = filter_and_sort_suites(suites - done, ::Test::Unit::TestCase)
22
+
23
+ ordered = others + func + int
24
+ if ordered.size == suites.size
25
+ ordered
26
+ else
27
+ oddballs = suites - ordered
28
+
29
+ warn <<-STR
30
+
31
+ WARNING:
32
+ Deep Test isn\'t sure it has preserved the standard test running order.
33
+ Tests that aren\'t of the standard rails unit, functional, or integration
34
+ classes will be run after those that are.
35
+
36
+ The #{oddballs.uniq.size} oddballs are of classes: #{oddballs.map(&:name).uniq.inspect}
37
+
38
+ oddballs:
39
+ #{oddballs.inspect}
40
+
41
+ STR
42
+ ordered + oddballs
43
+ end
44
+ end
45
+
46
+ def filter_and_sort_suites(suites, klass)
47
+ suites.select {|s| s.name.constantize < klass}.sort_by {|s| suite_to_filename(s)}
48
+ end
49
+
50
+ def suite_to_filename(s)
51
+ s.name.underscore + ".rb"
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
@@ -13,12 +13,14 @@ module DeepTest
13
13
  end
14
14
 
15
15
  def process_work_units(server)
16
- suite = ::Test::Unit::AutoRunner::COLLECTORS[:objectspace].call NO_FILTERS
16
+ suite = ::Test::Unit::AutoRunner::COLLECTORS[@options.test_collector].call NO_FILTERS
17
17
  supervised_suite = DeepTest::Test::SupervisedTestSuite.new(suite, server)
18
18
  require 'test/unit/ui/console/testrunner'
19
19
  result = ::Test::Unit::UI::Console::TestRunner.run(supervised_suite, ::Test::Unit::UI::NORMAL)
20
20
  result.passed?
21
21
  end
22
+
23
+
22
24
  end
23
25
  end
24
26
  end
data/lib/deep_test.rb CHANGED
@@ -90,3 +90,4 @@ require File.dirname(__FILE__) + "/deep_test/ui/console"
90
90
  require File.dirname(__FILE__) + "/deep_test/ui/null"
91
91
 
92
92
  require File.expand_path(File.dirname(__FILE__) + "/deep_test/drbfire.rb")
93
+ require File.expand_path(File.dirname(__FILE__) + "/deep_test/test/collector/rails_ordered_object_space.rb")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jason-o-matic-deep_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2.8
4
+ version: 1.2.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - anonymous z, Dan Manges, David Vollbracht
@@ -23,6 +23,7 @@ extra_rdoc_files:
23
23
  - README.rdoc
24
24
  - CHANGELOG
25
25
  files:
26
+ - lib/deep_test/test/collector/rails_ordered_object_space.rb
26
27
  - lib/deep_test/drbfire.rb
27
28
  - lib/deep_test/database/mysql_setup_listener.rb
28
29
  - lib/deep_test/database/setup_listener.rb