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
@@ -1,9 +0,0 @@
1
- #require 'test/unit/ui/console/testrunner'
2
- require 'turn/autoload'
3
- require 'turn/colorize'
4
- require 'turn/controller'
5
- require 'turn/runners/testrunner'
6
-
7
- Test::Unit::AutoRunner::RUNNERS[:console] = proc do |r|
8
- Turn::TestRunner
9
- end
@@ -1,116 +0,0 @@
1
- require 'test/unit/ui/console/testrunner'
2
- require 'turn/colorize'
3
-
4
- module ::Test::Unit
5
- module UI
6
- module Console
7
- class TestRunner
8
- include Turn::Colorize
9
-
10
- # 1.x of test/unut used @io, where as 2.x uses @output.
11
- def turn_out
12
- @turn_out ||= (@io || @output)
13
- end
14
-
15
- alias :t_attach_to_mediator :attach_to_mediator
16
- def attach_to_mediator
17
- @mediator.add_listener(TestRunnerMediator::STARTED, &method(:t_started))
18
- @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:t_finished))
19
- @mediator.add_listener(TestCase::STARTED, &method(:t_test_started))
20
- @mediator.add_listener(TestCase::FINISHED, &method(:t_test_finished))
21
- @mediator.add_listener(TestResult::FAULT, &method(:t_fault))
22
- turn_out.sync = true
23
- @t_cur_file, @t_fault = nil
24
- end
25
-
26
- def t_started( result )
27
- @t_result = result
28
- end
29
-
30
- def t_finished( elapsed_time )
31
- failure = @t_result.failure_count
32
- error = @t_result.error_count
33
- total = @t_result.run_count
34
- pass = total - failure - error
35
-
36
- bar = '=' * 78
37
- if colorize?
38
- bar = if pass == total then ::ANSI::Code.green{bar}
39
- else ::ANSI::Code.red{bar} end
40
- end
41
-
42
- turn_out.puts bar
43
- turn_out.puts " pass: %d, fail: %d, error: %d" % [pass, failure, error]
44
- turn_out.puts " total: %d tests with %d assertions in #{elapsed_time} seconds" % [total, @t_result.assertion_count]
45
- turn_out.puts bar
46
- end
47
-
48
- def t_test_started( name )
49
- method, file = name.scan(%r/^([^\(]+)\(([^\)]+)\)/o).flatten!
50
- if @t_cur_file != file
51
- @t_cur_file = file
52
- file = colorize? ? ::ANSI::Code.yellow{file} : file
53
- turn_out.puts file
54
- end
55
- turn_out.print " %-69s" % method
56
- end
57
-
58
- def t_test_finished( name )
59
- turn_out.puts " #{PASS}" unless @t_fault
60
- @t_fault = false
61
- end
62
-
63
- def t_fault( fault )
64
- @t_fault = true
65
- msg = "\t"
66
-
67
- case fault
68
- when ::Test::Unit::Error
69
- turn_out.puts ERROR
70
- msg << fault.to_s.split("\n")[2..-1].join("\n\t")
71
- when ::Test::Unit::Failure
72
- test_name = underscore(fault.test_name.match(/\((.*)\)/)[1])
73
- better_location = fault.location.detect{|line|line.include?(test_name)} || fault.location[0]
74
- turn_out.puts " #{FAIL}"
75
- msg << better_location.to_s << "\n\t"
76
- msg << fault.message.gsub("\n","\n\t")
77
- end
78
-
79
- msg = ::ANSI::Code.magenta{msg} if colorize?
80
- turn_out.puts msg
81
- end
82
-
83
- private
84
-
85
- # Taken from ActiveSupport::Inflector
86
- def underscore(camel_cased_word)
87
- word = camel_cased_word.to_s.dup
88
- word.gsub!(/::/, '/')
89
- word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
90
- word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
91
- word.tr!("-", "_")
92
- word.downcase!
93
- word
94
- end
95
-
96
- def setup_mediator
97
- @mediator = create_mediator(@suite)
98
- suite_name = @suite.to_s
99
- if ( @suite.kind_of?(Module) )
100
- suite_name = @suite.name
101
- end
102
- msg = rails? ? "\n" : "Loaded suite #{suite_name}" #always same in rails so scrap it
103
- output(msg)
104
- end
105
-
106
- def rails?
107
- $:.to_s.include? "rails"
108
- end
109
-
110
-
111
- end
112
- end
113
- end
114
- end
115
-
116
- # EOF