turn 0.8.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +1 -8
  3. data/History.txt +16 -0
  4. data/{license/GPLv2.txt → LICENSE-GPL2.txt} +0 -0
  5. data/{license/MIT-LICENSE.txt → LICENSE-MIT.txt} +0 -0
  6. data/{license/RUBY-LICENSE.txt → LICENSE-RUBY.txt} +0 -0
  7. data/{NOTICE.txt → LICENSE.txt} +1 -1
  8. data/README.md +26 -0
  9. data/Rakefile +1 -0
  10. data/Version.txt +1 -1
  11. data/bin/turn +7 -1
  12. data/lib/turn.rb +20 -11
  13. data/lib/turn/autoload.rb +1 -1
  14. data/lib/turn/autorun.rb +8 -0
  15. data/lib/turn/bin.rb +7 -1
  16. data/lib/turn/colorize.rb +26 -10
  17. data/lib/turn/command.rb +32 -13
  18. data/lib/turn/components.rb +4 -0
  19. data/lib/turn/components/case.rb +1 -1
  20. data/lib/turn/components/suite.rb +9 -3
  21. data/lib/turn/configuration.rb +197 -0
  22. data/lib/turn/controller.rb +15 -206
  23. data/lib/turn/{autorun/minitest.rb → minitest.rb} +7 -3
  24. data/lib/turn/reporter.rb +65 -10
  25. data/lib/turn/reporters/cue_reporter.rb +13 -2
  26. data/lib/turn/reporters/dot_reporter.rb +12 -11
  27. data/lib/turn/reporters/outline_reporter.rb +57 -36
  28. data/lib/turn/reporters/pretty_reporter.rb +37 -24
  29. data/lib/turn/reporters/progress_reporter.rb +64 -26
  30. data/lib/turn/runners/minirunner.rb +7 -32
  31. data/lib/turn/testunit.rb +5 -0
  32. data/test/helper.rb +11 -2
  33. data/test/test_framework.rb +39 -30
  34. data/test/test_runners.rb +9 -7
  35. data/{demo → try}/test_autorun_minitest.rb +0 -0
  36. data/{demo → try}/test_autorun_testunit.rb +0 -0
  37. data/{demo → try}/test_counts.rb +0 -0
  38. data/{demo → try}/test_sample.rb +0 -0
  39. data/{demo → try}/test_sample2.rb +0 -0
  40. data/turn.gemspec +2 -2
  41. metadata +42 -29
  42. data/lib/turn/autorun/minitest0.rb +0 -163
  43. data/lib/turn/autorun/testunit.rb +0 -9
  44. data/lib/turn/autorun/testunit0.rb +0 -116
@@ -0,0 +1,5 @@
1
+ require 'turn/runners/testrunner'
2
+
3
+ # need to turn this off unless autorun mode
4
+ Test::Unit.run = false
5
+
@@ -1,3 +1,6 @@
1
+ $:.unshift './lib'
2
+
3
+ #require 'turn/colorize'
1
4
  require 'fileutils'
2
5
 
3
6
  if RUBY_VERSION < "1.9"
@@ -7,6 +10,10 @@ else
7
10
  require 'test/unit'
8
11
  end
9
12
 
13
+ require 'turn'
14
+
15
+ #
16
+ #Turn.config.format = :pretty
10
17
 
11
18
  #
12
19
  def turn(*args)
@@ -39,7 +46,7 @@ end
39
46
  #
40
47
  def save_test(text, name=nil)
41
48
  file = File.join('tmp', name || 'test.rb')
42
- FileUtils.mkdir_p('tmp')
49
+ FileUtils.mkdir_p('tmp') unless File.directory?('tmp')
43
50
  File.open(file, 'w'){ |f| f << text }
44
51
  return file
45
52
  end
@@ -91,6 +98,7 @@ end
91
98
  def setup_minitest_autorun
92
99
  text = <<-HERE
93
100
  require 'turn'
101
+ MiniTest::Unit.runner = Turn::MiniRunner.new
94
102
  MiniTest::Unit.autorun
95
103
  #require 'minitest/unit'
96
104
  class TestTest < MiniTest::Unit::TestCase
@@ -108,9 +116,10 @@ def setup_minitest_autorun_with_trace
108
116
  #require 'minitest/unit'
109
117
  #require 'rubygems'
110
118
  require 'turn'
119
+ MiniTest::Unit.runner = Turn::MiniRunner.new
111
120
  MiniTest::Unit.autorun
112
121
  Turn.config do |c|
113
- c.trace = true
122
+ c.trace = 1
114
123
  end
115
124
  class TestTest < MiniTest::Unit::TestCase
116
125
  def test_sample_pass
@@ -13,30 +13,40 @@ if RUBY_VERSION >= '1.9'
13
13
 
14
14
  def test_ruby19_minitest_color
15
15
  term, stdout = ENV['TERM'], $stdout
16
+ host_os, ansicon, = ::RbConfig::CONFIG['host_os'], ENV['ANSICON']
16
17
  $stdout = $stdout.dup
17
18
  def $stdout.tty?
18
19
  true
19
20
  end
21
+ ENV['ANSICON'] = nil
20
22
  ENV['TERM'] = 'xterm'
21
- assert_equal true, Turn::Colorize.colorize?
23
+ assert_equal true, Turn::Colorize.color_supported?
22
24
  ENV['TERM'] = 'dumb'
23
- assert_equal false, Turn::Colorize.colorize?
25
+ assert_equal false, Turn::Colorize.color_supported?
24
26
  ENV['TERM'] = nil
25
- assert_equal false, Turn::Colorize.colorize?
27
+ assert_equal false, Turn::Colorize.color_supported?
28
+ ['mingw32', 'mswin32'].each do |os|
29
+ ::RbConfig::CONFIG['host_os'] = os
30
+ ENV['ANSICON'] = '120x5000 (120x50)'
31
+ assert_equal true, Turn::Colorize.color_supported?
32
+ ENV['ANSICON'] = nil
33
+ assert_equal false, Turn::Colorize.color_supported?
34
+ end
26
35
  ENV['TERM'] = 'xterm'
27
36
  def $stdout.tty?
28
37
  false
29
38
  end
30
- assert_equal false, Turn::Colorize.colorize?
39
+ assert_equal false, Turn::Colorize.color_supported?
31
40
  ensure
32
41
  ENV['TERM'], $stdout = term, stdout
42
+ ::RbConfig::CONFIG['host_os'], ENV['ANSICON'] = host_os, ansicon
33
43
  end
34
44
 
35
- def test_ruby19_minitest_force
36
- setup_test('MiniTest')
37
- result = turn '--minitest tmp/test.rb'
38
- assert result.index('PASS')
39
- end
45
+ #def test_ruby19_minitest_force
46
+ # setup_test('MiniTest')
47
+ # result = turn '--minitest tmp/test.rb'
48
+ # assert result.index('PASS')
49
+ #end
40
50
 
41
51
  def test_ruby19_minitest_required
42
52
  setup_test('MiniTest', 'minitest/unit')
@@ -44,11 +54,11 @@ if RUBY_VERSION >= '1.9'
44
54
  assert result.index('PASS')
45
55
  end
46
56
 
47
- def test_ruby19_minitest_required_force
48
- setup_test('MiniTest', 'minitest/unit')
49
- result = turn '--minitest tmp/test.rb'
50
- assert result.index('PASS')
51
- end
57
+ #def test_ruby19_minitest_required_force
58
+ # setup_test('MiniTest', 'minitest/unit')
59
+ # result = turn '--minitest tmp/test.rb'
60
+ # assert result.index('PASS')
61
+ #end
52
62
 
53
63
  def test_ruby19_minitest_mocking
54
64
  setup_test('Test')
@@ -56,11 +66,11 @@ if RUBY_VERSION >= '1.9'
56
66
  assert result.index('PASS')
57
67
  end
58
68
 
59
- def test_ruby19_minitest_mocking_force
60
- setup_test('Test')
61
- result = turn '--minitest tmp/test.rb'
62
- assert result.index('PASS')
63
- end
69
+ #def test_ruby19_minitest_mocking_force
70
+ # setup_test('Test')
71
+ # result = turn '--minitest tmp/test.rb'
72
+ # assert result.index('PASS')
73
+ #end
64
74
 
65
75
  def test_ruby19_minitest_mocking_required
66
76
  setup_test('Test', 'minitest/unit')
@@ -68,19 +78,19 @@ if RUBY_VERSION >= '1.9'
68
78
  assert result.index('PASS')
69
79
  end
70
80
 
71
- def test_ruby19_minitest_mocking_required_force
72
- setup_test('Test', 'minitest/unit')
73
- result = turn '--minitest tmp/test.rb'
74
- assert result.index('PASS')
75
- end
76
-
77
- # Ruby 1.9 users must remove ++require 'test/unit'++ from their tests.
78
- #def test_ruby19_testunit_required
79
- # setup_test('Test', 'test/unit')
80
- # result = turn 'turn tmp/test.rb'
81
+ #def test_ruby19_minitest_mocking_required_force
82
+ # setup_test('Test', 'minitest/unit')
83
+ # result = turn '--minitest tmp/test.rb'
81
84
  # assert result.index('PASS')
82
85
  #end
83
86
 
87
+ #
88
+ def test_ruby19_testunit_required
89
+ setup_test('Test', 'test/unit')
90
+ result = turn 'turn tmp/test.rb'
91
+ assert result.index('PASS')
92
+ end
93
+
84
94
  # Turn does not support Test::Unit 2.0+.
85
95
  #def test_ruby19_testunit_force
86
96
  # setup_test('Test')
@@ -149,4 +159,3 @@ else
149
159
  end
150
160
 
151
161
  end
152
-
@@ -20,23 +20,23 @@ class TestRunners < Test::Unit::TestCase
20
20
 
21
21
  # autorun
22
22
 
23
- if RUBY_VERSION < '1.9'
23
+ #if RUBY_VERSION < '1.9'
24
24
 
25
- def test_autorun
26
- file = setup_test('Test', 'turn', 'test_autorun.rb')
25
+ def test_autorun_testunit
26
+ file = setup_test('Test', 'turn/autorun', 'test_autorun.rb')
27
27
  result = `ruby -Ilib #{file} 2>&1`
28
28
  assert(result.index('pass: 1'))
29
29
  assert(result.index('fail: 0'))
30
30
  assert(result.index('error: 0'))
31
31
  end
32
32
 
33
- else
33
+ #else
34
34
 
35
35
  def test_autorun
36
36
  file = setup_minitest_autorun
37
37
  result = `ruby -Ilib #{file} 2>&1`
38
- assert result.index('fail: 0')
39
- assert result.index('error: 0')
38
+ assert result.index('fail: 0'), "ACTUAL RESULT --->\n #{result}"
39
+ assert result.index('error: 0'), "ACTUAL RESULT --->\n #{result}"
40
40
  end
41
41
 
42
42
  def test_autorun_with_trace
@@ -49,6 +49,8 @@ class TestRunners < Test::Unit::TestCase
49
49
  # TODO: the backtrace is empty, why?
50
50
  #assert result.scan(/\.rb:\d+:in/).length > 1
51
51
  end
52
- end
52
+
53
+ #end
54
+
53
55
  end
54
56
 
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{turn}
5
- s.version = "0.8.3"
5
+ s.version = "0.8.3.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{Tim Pease}]
9
- s.date = %q{2011-10-10}
9
+ s.date = %q{2011-10-26}
10
10
  s.description = %q{}
11
11
  s.email = %q{tim.pease@gmail.com}
12
12
  s.executables = [%q{turn}]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-10 00:00:00.000000000Z
12
+ date: 2012-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ansi
16
- requirement: &2153736940 !ruby/object:Gem::Requirement
16
+ requirement: &23349740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,29 +21,40 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153736940
24
+ version_requirements: *23349740
25
+ - !ruby/object:Gem::Dependency
26
+ name: minitest
27
+ requirement: &23349320 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *23349320
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: bones-git
27
- requirement: &2153735960 !ruby/object:Gem::Requirement
38
+ requirement: &23348880 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ! '>='
31
42
  - !ruby/object:Gem::Version
32
- version: 1.2.4
43
+ version: '0'
33
44
  type: :development
34
45
  prerelease: false
35
- version_requirements: *2153735960
46
+ version_requirements: *23348880
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: bones
38
- requirement: &2153735420 !ruby/object:Gem::Requirement
49
+ requirement: &23348420 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
42
53
  - !ruby/object:Gem::Version
43
- version: 3.7.1
54
+ version: 3.7.3
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *2153735420
57
+ version_requirements: *23348420
47
58
  description: ''
48
59
  email: tim.pease@gmail.com
49
60
  executables:
@@ -51,42 +62,41 @@ executables:
51
62
  extensions: []
52
63
  extra_rdoc_files:
53
64
  - History.txt
54
- - NOTICE.txt
65
+ - LICENSE-GPL2.txt
66
+ - LICENSE-MIT.txt
67
+ - LICENSE-RUBY.txt
68
+ - LICENSE.txt
55
69
  - Release.txt
56
70
  - Version.txt
57
71
  - bin/turn
58
- - license/GPLv2.txt
59
- - license/MIT-LICENSE.txt
60
- - license/RUBY-LICENSE.txt
61
72
  files:
73
+ - .gitignore
62
74
  - .travis.yml
63
75
  - Gemfile
64
76
  - History.txt
65
- - NOTICE.txt
77
+ - LICENSE-GPL2.txt
78
+ - LICENSE-MIT.txt
79
+ - LICENSE-RUBY.txt
80
+ - LICENSE.txt
66
81
  - README.md
67
82
  - Rakefile
68
83
  - Release.txt
69
84
  - Version.txt
70
85
  - bin/turn
71
- - demo/test_autorun_minitest.rb
72
- - demo/test_autorun_testunit.rb
73
- - demo/test_counts.rb
74
- - demo/test_sample.rb
75
- - demo/test_sample2.rb
76
86
  - lib/turn.rb
77
87
  - lib/turn/autoload.rb
78
- - lib/turn/autorun/minitest.rb
79
- - lib/turn/autorun/minitest0.rb
80
- - lib/turn/autorun/testunit.rb
81
- - lib/turn/autorun/testunit0.rb
88
+ - lib/turn/autorun.rb
82
89
  - lib/turn/bin.rb
83
90
  - lib/turn/colorize.rb
84
91
  - lib/turn/command.rb
92
+ - lib/turn/components.rb
85
93
  - lib/turn/components/case.rb
86
94
  - lib/turn/components/method.rb
87
95
  - lib/turn/components/suite.rb
96
+ - lib/turn/configuration.rb
88
97
  - lib/turn/controller.rb
89
98
  - lib/turn/core_ext.rb
99
+ - lib/turn/minitest.rb
90
100
  - lib/turn/reporter.rb
91
101
  - lib/turn/reporters/cue_reporter.rb
92
102
  - lib/turn/reporters/dot_reporter.rb
@@ -100,15 +110,18 @@ files:
100
110
  - lib/turn/runners/minirunner.rb
101
111
  - lib/turn/runners/solorunner.rb
102
112
  - lib/turn/runners/testrunner.rb
113
+ - lib/turn/testunit.rb
103
114
  - lib/turn/version.rb
104
- - license/GPLv2.txt
105
- - license/MIT-LICENSE.txt
106
- - license/RUBY-LICENSE.txt
107
115
  - test/helper.rb
108
116
  - test/runner
109
117
  - test/test_framework.rb
110
118
  - test/test_reporters.rb
111
119
  - test/test_runners.rb
120
+ - try/test_autorun_minitest.rb
121
+ - try/test_autorun_testunit.rb
122
+ - try/test_counts.rb
123
+ - try/test_sample.rb
124
+ - try/test_sample2.rb
112
125
  - turn.gemspec
113
126
  homepage: http://gemcutter.org/gems/turn
114
127
  licenses: []
@@ -132,11 +145,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
145
  version: '0'
133
146
  requirements: []
134
147
  rubyforge_project: turn
135
- rubygems_version: 1.8.6
148
+ rubygems_version: 1.8.11
136
149
  signing_key:
137
150
  specification_version: 3
138
151
  summary: Test::Unit Reporter (New) -- new output format for Test::Unit
139
152
  test_files:
140
- - test/test_framework.rb
141
153
  - test/test_reporters.rb
154
+ - test/test_framework.rb
142
155
  - test/test_runners.rb
@@ -1,163 +0,0 @@
1
- require 'minitest/unit'
2
- require 'minitest/spec'
3
- #require 'rubygems'
4
- require 'turn/colorize'
5
-
6
- class MiniTest::Unit
7
- PADDING_SIZE = 4
8
-
9
- @@use_natural_language_case_names = false
10
- def self.use_natural_language_case_names=(boolean)
11
- @use_natural_language_case_names = boolean
12
- end
13
-
14
- def self.use_natural_language_case_names?
15
- @use_natural_language_case_names
16
- end
17
-
18
-
19
- def run(args = [])
20
- @verbose = true
21
- options = args.getopts("n:t", "name:", "trace")
22
- filter = if name = options["n"] || options["name"]
23
- if name =~ /\/(.*)\//
24
- Regexp.new($1)
25
- elsif MiniTest::Unit.use_natural_language_case_names?
26
- # Turn 'sample error1' into 'test_sample_error1'
27
- name[0..4] == "test_" ? name.gsub(" ", "_") : "test_" + name.gsub(" ", "_")
28
- else
29
- name
30
- end
31
- else
32
- /./ # anything - ^test_ already filtered by #tests
33
- end
34
-
35
- @trace = options['t'] || options['trace']
36
-
37
- @@out.puts "Loaded suite #{$0.sub(/\.rb$/, '')}\nStarted"
38
-
39
- start = Time.now
40
- run_test_suites filter
41
-
42
- @@out.puts
43
- @@out.puts "Finished in #{'%.6f' % (Time.now - start)} seconds."
44
-
45
- @@out.puts
46
-
47
- @@out.print "%d tests, " % test_count
48
- @@out.print "%d assertions, " % assertion_count
49
- @@out.print Turn::Colorize.fail("%d failures, " % failures)
50
- @@out.print Turn::Colorize.error("%d errors, " % errors)
51
- @@out.puts Turn::Colorize.skip("%d skips" % skips)
52
-
53
- return failures + errors if @test_count > 0 # or return nil...
54
- end
55
-
56
- # Overwrite #run_test_suites so that it prints out reports
57
- # as errors are generated.
58
- def run_test_suites(filter = /./)
59
- @test_count, @assertion_count = 0, 0
60
- old_sync, @@out.sync = @@out.sync, true if @@out.respond_to? :sync=
61
- TestCase.test_suites.each do |suite|
62
- test_cases = suite.test_methods.grep(filter)
63
- if test_cases.size > 0
64
- @@out.print "\n#{suite}:\n"
65
- end
66
-
67
- test_cases.each do |test|
68
- inst = suite.new test
69
- inst._assertions = 0
70
-
71
- t = Time.now
72
-
73
- @broken = nil
74
-
75
- @@out.print(case run_testcase(inst, self)
76
- when :pass
77
- @broken = false
78
- Turn::Colorize.pass(pad_with_size "PASS")
79
- when :error
80
- @broken = true
81
- Turn::Colorize.error(pad_with_size "ERROR")
82
- when :fail
83
- @broken = true
84
- Turn::Colorize.fail(pad_with_size "FAIL")
85
- when :skip
86
- @broken = false
87
- Turn::Colorize.skip(pad_with_size "SKIP")
88
- end)
89
-
90
-
91
- @@out.print MiniTest::Unit.use_natural_language_case_names? ?
92
- " #{test.gsub("test_", "").gsub(/_/, " ")}" : " #{test}"
93
- @@out.print " (%.2fs) " % (Time.now - t)
94
-
95
- if @broken
96
- @@out.puts
97
-
98
- report = @report.last
99
- @@out.puts pad(report[:message], 10)
100
-
101
- trace = MiniTest::filter_backtrace(report[:exception].backtrace)
102
- if @trace
103
- @@out.print trace.map{|t| pad(t, 10) }.join("\n")
104
- else
105
- @@out.print pad(trace.first, 10)
106
- end
107
-
108
- @@out.puts
109
- end
110
-
111
- @@out.puts
112
- @test_count += 1
113
- @assertion_count += inst._assertions
114
- end
115
- end
116
- @@out.sync = old_sync if @@out.respond_to? :sync=
117
- [@test_count, @assertion_count]
118
- end
119
-
120
- def pad(str, size=PADDING_SIZE)
121
- " " * size + str
122
- end
123
-
124
- def pad_with_size(str)
125
- pad("%5s" % str)
126
- end
127
-
128
- # Overwrite #puke method so that is stores a hash
129
- # with :message and :exception keys.
130
- def puke(klass, meth, e)
131
- result = nil
132
- msg = case e
133
- when MiniTest::Skip
134
- @skips += 1
135
- result = :skip
136
- e.message
137
- when MiniTest::Assertion
138
- @failures += 1
139
- result = :fail
140
- e.message
141
- else
142
- @errors += 1
143
- result = :error
144
- "#{e.class}: #{e.message}\n"
145
- end
146
-
147
- @report << {:message => msg, :exception => e}
148
- result
149
- end
150
-
151
- private
152
- # A wrapper over MiniTest::Unit::TestCase.run() that returns
153
- # :pass whenever the test succeeds (i.e. run() returns "" or ".")
154
- def run_testcase(testcase, runner)
155
- original_result = testcase.run(runner)
156
- if original_result == "" || original_result == "."
157
- :pass
158
- else
159
- original_result
160
- end
161
- end
162
- end
163
-