Skip to content
This repository
Browse code

Merge pull request #134 from turn-project/cleanup-and-remove-cruft

Cleanup and remove cruft
  • Loading branch information...
commit 660c7431a3a412c1c89417d9bd44f9e88c707a78 2 parents e9aeced + 593fe51
Michael Kohl authored
307  .gemspec
... ...
@@ -1,307 +0,0 @@
1  
-# encoding: utf-8
2  
-
3  
-require 'yaml'
4  
-require 'pathname'
5  
-
6  
-module Indexer
7  
-
8  
-  # Convert index data into a gemspec.
9  
-  #
10  
-  # Notes:
11  
-  #   * Assumes all executables are in bin/.
12  
-  #   * Does not yet handle default_executable setting.
13  
-  #   * Does not yet handle platform setting.
14  
-  #   * Does not yet handle required_ruby_version.
15  
-  #   * Support for rdoc entries is weak.
16  
-  #
17  
-  class GemspecExporter
18  
-
19  
-    # File globs to include in package --unless a manifest file exists.
20  
-    FILES = ".index .yardopts alt bin data demo ext features lib man spec test try* [A-Z]*.*" unless defined?(FILES)
21  
-
22  
-    # File globs to omit from FILES.
23  
-    OMIT = "Config.rb" unless defined?(OMIT)
24  
-
25  
-    # Standard file patterns.
26  
-    PATTERNS = {
27  
-      :root => '{.index,Gemfile}',
28  
-      :bin  => 'bin/*',
29  
-      :lib  => 'lib/{**/}*', #.rb',
30  
-      :ext  => 'ext/{**/}extconf.rb',
31  
-      :doc  => '*.{txt,rdoc,md,markdown,tt,textile}',
32  
-      :test => '{test,spec}/{**/}*.rb'
33  
-    } unless defined?(PATTERNS)
34  
-
35  
-    # For which revision of indexer spec is this converter intended?
36  
-    REVISION = 2013 unless defined?(REVISION)
37  
-
38  
-    #
39  
-    def self.gemspec
40  
-      new.to_gemspec
41  
-    end
42  
-
43  
-    #
44  
-    attr :metadata
45  
-
46  
-    #
47  
-    def initialize(metadata=nil)
48  
-      @root_check = false
49  
-
50  
-      if metadata
51  
-        root_dir = metadata.delete(:root)
52  
-        if root_dir
53  
-          @root = root_dir
54  
-          @root_check = true
55  
-        end
56  
-        metadata = nil if metadata.empty?
57  
-      end
58  
-
59  
-      @metadata = metadata || YAML.load_file(root + '.index')
60  
-
61  
-      if @metadata['revision'].to_i != REVISION
62  
-        warn "This gemspec exporter was not designed for this revision of index metadata."
63  
-      end
64  
-    end
65  
-
66  
-    #
67  
-    def has_root?
68  
-      root ? true : false
69  
-    end
70  
-
71  
-    #
72  
-    def root
73  
-      return @root if @root || @root_check
74  
-      @root_check = true
75  
-      @root = find_root
76  
-    end
77  
-
78  
-    #
79  
-    def manifest
80  
-      return nil unless root
81  
-      @manifest ||= Dir.glob(root + 'manifest{,.txt}', File::FNM_CASEFOLD).first
82  
-    end
83  
-
84  
-    #
85  
-    def scm
86  
-      return nil unless root
87  
-      @scm ||= %w{git hg}.find{ |m| (root + ".#{m}").directory? }.to_sym
88  
-    end
89  
-
90  
-    #
91  
-    def files
92  
-      return [] unless root
93  
-      @files ||= \
94  
-        if manifest
95  
-          File.readlines(manifest).
96  
-            map{ |line| line.strip }.
97  
-            reject{ |line| line.empty? || line[0,1] == '#' }
98  
-        else
99  
-          list = []
100  
-          Dir.chdir(root) do
101  
-            FILES.split(/\s+/).each do |pattern|
102  
-              list.concat(glob(pattern))
103  
-            end
104  
-            OMIT.split(/\s+/).each do |pattern|
105  
-              list = list - glob(pattern)
106  
-            end
107  
-          end
108  
-          list
109  
-        end.select{ |path| File.file?(path) }.uniq
110  
-    end
111  
-
112  
-    #
113  
-    def glob_files(pattern)
114  
-      return [] unless root
115  
-      Dir.chdir(root) do
116  
-        Dir.glob(pattern).select do |path|
117  
-          File.file?(path) && files.include?(path)
118  
-        end
119  
-      end
120  
-    end
121  
-
122  
-    def patterns
123  
-      PATTERNS
124  
-    end
125  
-
126  
-    def executables
127  
-      @executables ||= \
128  
-        glob_files(patterns[:bin]).map do |path|
129  
-          File.basename(path)
130  
-        end
131  
-    end
132  
-
133  
-    def extensions
134  
-      @extensions ||= \
135  
-        glob_files(patterns[:ext]).map do |path|
136  
-          File.basename(path)
137  
-        end
138  
-    end
139  
-
140  
-    def name
141  
-      metadata['name'] || metadata['title'].downcase.gsub(/\W+/,'_')
142  
-    end
143  
-
144  
-    def homepage
145  
-      page = (
146  
-        metadata['resources'].find{ |r| r['type'] =~ /^home/i } ||
147  
-        metadata['resources'].find{ |r| r['name'] =~ /^home/i } ||
148  
-        metadata['resources'].find{ |r| r['name'] =~ /^web/i }
149  
-      )
150  
-      page ? page['uri'] : false
151  
-    end
152  
-
153  
-    def licenses
154  
-      metadata['copyrights'].map{ |c| c['license'] }.compact
155  
-    end
156  
-
157  
-    def require_paths
158  
-      paths = metadata['paths'] || {}
159  
-      paths['load'] || ['lib']
160  
-    end
161  
-
162  
-    #
163  
-    # Convert to gemnspec.
164  
-    #
165  
-    def to_gemspec
166  
-      if has_root?
167  
-        Gem::Specification.new do |gemspec|
168  
-          to_gemspec_data(gemspec)
169  
-          to_gemspec_paths(gemspec)
170  
-        end
171  
-      else
172  
-        Gem::Specification.new do |gemspec|
173  
-          to_gemspec_data(gemspec)
174  
-          to_gemspec_paths(gemspec)
175  
-        end
176  
-      end
177  
-    end
178  
-
179  
-    #
180  
-    # Convert pure data settings.
181  
-    #
182  
-    def to_gemspec_data(gemspec)
183  
-      gemspec.name        = name
184  
-      gemspec.version     = metadata['version']
185  
-      gemspec.summary     = metadata['summary']
186  
-      gemspec.description = metadata['description']
187  
-
188  
-      metadata['authors'].each do |author|
189  
-        gemspec.authors << author['name']
190  
-
191  
-        if author.has_key?('email')
192  
-          if gemspec.email
193  
-            gemspec.email << author['email']
194  
-          else
195  
-            gemspec.email = [author['email']]
196  
-          end
197  
-        end
198  
-      end
199  
-
200  
-      gemspec.licenses = licenses
201  
-
202  
-      requirements = metadata['requirements'] || []
203  
-      requirements.each do |req|
204  
-        next if req['optional']
205  
-        next if req['external']
206  
-
207  
-        name    = req['name']
208  
-        groups  = req['groups'] || []
209  
-
210  
-        version = gemify_version(req['version'])
211  
-
212  
-        if groups.empty? or groups.include?('runtime')
213  
-          # populate runtime dependencies  
214  
-          if gemspec.respond_to?(:add_runtime_dependency)
215  
-            gemspec.add_runtime_dependency(name,*version)
216  
-          else
217  
-            gemspec.add_dependency(name,*version)
218  
-          end
219  
-        else
220  
-          # populate development dependencies
221  
-          if gemspec.respond_to?(:add_development_dependency)
222  
-            gemspec.add_development_dependency(name,*version)
223  
-          else
224  
-            gemspec.add_dependency(name,*version)
225  
-          end
226  
-        end
227  
-      end
228  
-
229  
-      # convert external dependencies into gemspec requirements
230  
-      requirements.each do |req|
231  
-        next unless req['external']
232  
-        gemspec.requirements << ("%s-%s" % req.values_at('name', 'version'))
233  
-      end
234  
-
235  
-      gemspec.homepage = homepage
236  
-      gemspec.require_paths = require_paths
237  
-      gemspec.post_install_message = metadata['install_message']
238  
-    end
239  
-
240  
-    #
241  
-    # Set gemspec settings that require a root directory path.
242  
-    #
243  
-    def to_gemspec_paths(gemspec)
244  
-      gemspec.files       = files
245  
-      gemspec.extensions  = extensions
246  
-      gemspec.executables = executables
247  
-
248  
-      if Gem::VERSION < '1.7.'
249  
-        gemspec.default_executable = gemspec.executables.first
250  
-      end
251  
-
252  
-      gemspec.test_files = glob_files(patterns[:test])
253  
-
254  
-      unless gemspec.files.include?('.document')
255  
-        gemspec.extra_rdoc_files = glob_files(patterns[:doc])
256  
-      end
257  
-    end
258  
-
259  
-    #
260  
-    # Return a copy of this file. This is used to generate a local
261  
-    # .gemspec file that can automatically read the index file.
262  
-    #
263  
-    def self.source_code
264  
-      File.read(__FILE__)
265  
-    end
266  
-
267  
-  private
268  
-
269  
-    def find_root
270  
-      root_files = patterns[:root]
271  
-      if Dir.glob(root_files).first
272  
-        Pathname.new(Dir.pwd)
273  
-      elsif Dir.glob("../#{root_files}").first
274  
-        Pathname.new(Dir.pwd).parent
275  
-      else
276  
-        #raise "Can't find root of project containing `#{root_files}'."
277  
-        warn "Can't find root of project containing `#{root_files}'."
278  
-        nil
279  
-      end
280  
-    end
281  
-
282  
-    def glob(pattern)
283  
-      if File.directory?(pattern)
284  
-        Dir.glob(File.join(pattern, '**', '*'))
285  
-      else
286  
-        Dir.glob(pattern)
287  
-      end
288  
-    end
289  
-
290  
-    def gemify_version(version)
291  
-      case version
292  
-      when /^(.*?)\+$/
293  
-        ">= #{$1}"
294  
-      when /^(.*?)\-$/
295  
-        "< #{$1}"
296  
-      when /^(.*?)\~$/
297  
-        "~> #{$1}"
298  
-      else
299  
-        version
300  
-      end
301  
-    end
302  
-
303  
-  end
304  
-
305  
-end
306  
-
307  
-Indexer::GemspecExporter.gemspec
56  .index
... ...
@@ -1,56 +0,0 @@
1  
----
2  
-revision: 2013
3  
-type: ruby
4  
-sources:
5  
-- Index.rb
6  
-authors:
7  
-- name: Thomas Sawyer
8  
-  email: transfire@gmail.com
9  
-- name: Tim Pease
10  
-  email: tim.pease@gmail.com
11  
-organizations: []
12  
-requirements:
13  
-- name: ansi
14  
-- version: 4~
15  
-  name: minitest
16  
-- groups:
17  
-  - build
18  
-  development: true
19  
-  name: rake
20  
-- groups:
21  
-  - build
22  
-  development: true
23  
-  name: indexer
24  
-- groups:
25  
-  - build
26  
-  development: true
27  
-  name: mast
28  
-conflicts: []
29  
-alternatives: []
30  
-resources:
31  
-- type: home
32  
-  uri: http://rubygems.org/gems/turn
33  
-  label: Homepage
34  
-- type: code
35  
-  uri: http://github.com/TwP/turn
36  
-  label: Source Code
37  
-repositories: []
38  
-categories: []
39  
-copyrights:
40  
-- holder: Tim Pease
41  
-  year: '2006'
42  
-  license: MIT
43  
-- holder: Thomas Sawyer
44  
-  year: '2009'
45  
-  license: MIT
46  
-customs: []
47  
-paths:
48  
-  lib:
49  
-  - lib
50  
-version: 0.9.7
51  
-name: turn
52  
-title: Turn
53  
-summary: Test Reporters (New) -- new output formats for Testing
54  
-description: Turn provides a set of alternative runners for MiniTest, both colorful
55  
-  and informative.
56  
-date: '2014-03-14'
40  CONTRIBUTING.md
Source Rendered
... ...
@@ -1,40 +0,0 @@
1  
-# CONTRIBUTING
2  
-
3  
-1. Fork it
4  
-2. Create your feature branch (`git checkout -b my_new_feature`)
5  
-3. Commit your changes (`git commit -am 'Added some feature'`)
6  
-4. Push to the branch (`git push origin my_new_feature`)
7  
-5. Create a new Pull Request
8  
-
9  
-If you are a project member please follow the same process (minus the forking). For significant changes please wait for another developer to review and merge them, whereas small contributions/fixes can be merged without review. The recommended naming scheme for feature branches is 'feature\_name\_$1\_`date +"%Y%m%d"`'.
10  
-
11  
-You may want to look into the [grb](http://github.com/jinzhu/grb) gem for easier handling of remote branches.
12  
-
13  
-
14  
-## Building
15  
-
16  
-NOTE: The process described here will change sooner than later.
17  
-
18  
-Turn uses the Indexer and Mast gems to simplify project building.
19  
-
20  
-The Indexer gem defines a strict structure for project metadata. Use the `index`
21  
-command to build the `.index` file from the editable `Index.rb` source.
22  
-The `.gemspec` file is written to get the information it needs from the `.index`
23  
-file. To build a gem simply use `gem build .gemspec`.
24  
-
25  
-The `mast` command is used to keep an up-to-date `Manifest.txt` file. The gemspec
26  
-uses this file to determine which files to include in the gem. Just use
27  
-`mast -u` to update it. The top line in the Manifest.txt file determines it's
28  
-contents.
29  
-
30  
-
31  
-## Solo and Cross Runners
32  
-
33  
-An important aspect of Turn's design that needs be kept in mind, is the way
34  
-_solo_ and _cross_ testing features are implemented. This is some really
35  
-neat code actually (IMO), but it might be difficult to grasp with out some
36  
-explanation. What turn does when using the `--solo` or `--cross` options,
37  
-is <i>shell out to itself</i> using the YAML reporter. It does this repeatedly
38  
-for each test, or each pair of tests, respectively, and then collates all the
39  
-resulting YAML reports into a single report, which it then feeds back into the
40  
-selected reporter.
2  Gemfile
... ...
@@ -1,2 +1,2 @@
1  
-source "http://rubygems.org"
  1
+source "https://rubygems.org"
2 2
 gemspec
34  Index.rb
... ...
@@ -1,34 +0,0 @@
1  
-#!/usr/bin/env ruby
2  
-
3  
-require File.dirname(__FILE__) + '/lib/turn/version'
4  
-
5  
-version       Turn::VERSION  #File.read('Version.txt').strip
6  
-
7  
-name         'turn'
8  
-title        'Turn'
9  
-summary      'Test Reporters (New) -- new output formats for Testing'
10  
-
11  
-description "Turn provides a set of alternative runners for MiniTest, both colorful and informative."
12  
-
13  
-authors [
14  
-  'Thomas Sawyer <transfire@gmail.com>',
15  
-  'Tim Pease <tim.pease@gmail.com>'
16  
-]
17  
-
18  
-requirements [
19  
-  'ansi',
20  
-  'minitest  4~',
21  
-  'rake     (build)',
22  
-  'indexer  (build)',
23  
-  'mast     (build)'
24  
-]
25  
-
26  
-resources(
27  
-  'home' => 'http://rubygems.org/gems/turn',
28  
-  'code' => 'http://github.com/TwP/turn'
29  
-)
30  
-
31  
-copyrights [
32  
-  '2006 Tim Pease (MIT)',
33  
-  '2009 Thomas Sawyer (MIT)'
34  
-]
51  Manifest.txt
... ...
@@ -1,51 +0,0 @@
1  
-#!mast -x Gemfile.lock bin lib test try [A-Z]*.*
2  
-bin/turn
3  
-lib/turn/autoload.rb
4  
-lib/turn/autorun.rb
5  
-lib/turn/bin.rb
6  
-lib/turn/colorize.rb
7  
-lib/turn/command.rb
8  
-lib/turn/components/case.rb
9  
-lib/turn/components/method.rb
10  
-lib/turn/components/suite.rb
11  
-lib/turn/components.rb
12  
-lib/turn/configuration.rb
13  
-lib/turn/controller.rb
14  
-lib/turn/core_ext.rb
15  
-lib/turn/decorators/topten_decorator.rb
16  
-lib/turn/minitest.rb
17  
-lib/turn/reporter.rb
18  
-lib/turn/reporters/cue_reporter.rb
19  
-lib/turn/reporters/dot_reporter.rb
20  
-lib/turn/reporters/marshal_reporter.rb
21  
-lib/turn/reporters/outline_reporter.rb
22  
-lib/turn/reporters/pretty_reporter.rb
23  
-lib/turn/reporters/progress_reporter.rb
24  
-lib/turn/runners/crossrunner.rb
25  
-lib/turn/runners/isorunner.rb
26  
-lib/turn/runners/loadrunner.rb
27  
-lib/turn/runners/minirunner.rb
28  
-lib/turn/runners/solorunner.rb
29  
-lib/turn/runners/testrunner.rb
30  
-lib/turn/testunit.rb
31  
-lib/turn/version.rb
32  
-lib/turn.rb
33  
-test/helper.rb
34  
-test/reporter_test.rb
35  
-test/runner
36  
-test/test_framework.rb
37  
-test/test_reporters.rb
38  
-test/test_runners.rb
39  
-try/test_autorun_minitest.rb
40  
-try/test_autorun_testunit.rb
41  
-try/test_counts.rb
42  
-try/test_sample.rb
43  
-try/test_sample2.rb
44  
-CONTRIBUTING.md
45  
-Release.txt
46  
-Version.txt
47  
-NOTICE.md
48  
-Index.rb
49  
-History.txt
50  
-README.md
51  
-LICENSE.txt
29  README.md
Source Rendered
@@ -130,22 +130,41 @@ See source code for examples of how to write your own reporters.
130 130
 
131 131
 * ansi 1.1+ (for colorized output and progress bar output mode)
132 132
 
133  
-
134 133
 ## INSTALLATION
135 134
 
136 135
 Follow the ususal procedure:
137 136
 
138 137
     $ gem install turn
139 138
 
140  
-
141 139
 ## TODO
142 140
 
143 141
 * Support MiniTest v5.0
144  
-* Remove indexer and mast gems from build process
145  
-* Remove support for Ruby versions < 1.9
146  
-* Remove support for Test::Unit
147 142
 * General code cleanup
148 143
 
  144
+# CONTRIBUTING
  145
+
  146
+1. Fork it
  147
+2. Create your feature branch (`git checkout -b my_new_feature`)
  148
+3. Commit your changes (`git commit -am 'Added some feature'`)
  149
+4. Push to the branch (`git push origin my_new_feature`)
  150
+5. Create a new Pull Request
  151
+
  152
+If you are a project member please follow the same process (minus the forking). For significant changes please wait for another developer to review and merge them, whereas small contributions/fixes can be merged without review.
  153
+
  154
+## Building
  155
+
  156
+`gem build turn.gemspec`
  157
+
  158
+## Solo and Cross Runners
  159
+
  160
+An important aspect of Turn's design that needs be kept in mind, is the way
  161
+_solo_ and _cross_ testing features are implemented. This is some really
  162
+neat code actually (IMO), but it might be difficult to grasp with out some
  163
+explanation. What turn does when using the `--solo` or `--cross` options,
  164
+is <i>shell out to itself</i> using the YAML reporter. It does this repeatedly
  165
+for each test, or each pair of tests, respectively, and then collates all the
  166
+resulting YAML reports into a single report, which it then feeds back into the
  167
+selected reporter.
149 168
 
150 169
 ## LICENSE
151 170
 
26  Rakefile
... ...
@@ -1,30 +1,8 @@
  1
+require "bundler/gem_tasks"
  2
+
1 3
 task :default => :test
2 4
 
3 5
 desc "Run unit tests"
4 6
 task :test do
5 7
   ruby "-Ilib bin/turn -Ilib -v test/*.rb"
6 8
 end
7  
-
8  
-desc "build gem package"
9  
-task :gem => ['.ruby'] do
10  
-  sh 'gem build .gemspec'
11  
-  sh 'mv *.gem pkg/'
12  
-end
13  
-
14  
-file '.index' => ['Index.rb', 'lib/turn/version.rb'] do
15  
-  sh 'index -f'
16  
-end
17  
-
18  
-# Might be useful one day, so we'll leave it here.
19  
-#
20  
-# Rake::TaskManager.class_eval do
21  
-#   def remove_task(task_name)
22  
-#     @tasks.delete(task_name.to_s)
23  
-#   end
24  
-# end
25  
-#
26  
-# def remove_task(task_name)
27  
-#   Rake.application.remove_task(task_name)
28  
-# end
29  
-
30  
-# EOF
1  Version.txt
... ...
@@ -1 +0,0 @@
1  
-0.9.7
8  lib/turn/command.rb
@@ -61,9 +61,6 @@ def self.main(*argv)
61 61
     # Libraries to require before running tests.
62 62
     attr :requires
63 63
 
64  
-    # Framework to use, :minitest or :testunit.
65  
-    #attr :framework
66  
-
67 64
     # Run mode.
68 65
     attr :runmode
69 66
 
@@ -163,11 +160,6 @@ def option_parser
163 160
           @ansi = bool
164 161
         end
165 162
 
166  
-        # Turn does not support Test::Unit 2.0+
167  
-        #opts.on('-u', '--testunit', "Force use of TestUnit framework") do
168  
-        #  @framework = :testunit
169  
-        #end
170  
-
171 163
         opts.on('--log', "log results to a file") do #|path|
172 164
           @log = true # TODO: support path/file
173 165
         end
5  lib/turn/configuration.rb
@@ -55,10 +55,6 @@ class Configuration
55 55
     # Runtime threshold.
56 56
     attr_accessor :mark
57 57
 
58  
-    # Test framework, either `:minitest` or `:testunit`.
59  
-    # TODO: Is this used any more?
60  
-    attr_accessor :framework
61  
-
62 58
     # Enable full backtrace
63 59
     attr_accessor :trace
64 60
 
@@ -101,7 +97,6 @@ def initialize_defaults
101 97
       @requires  ||= []
102 98
       @live      ||= false
103 99
       @log       ||= true
104  
-      #@runner   ||= RUBY_VERSION >= "1.9" ? MiniRunner : TestRunner
105 100
       @matchcase ||= nil
106 101
       @pattern   ||= /.*/
107 102
       @natural   ||= false
3  lib/turn/minitest.rb
@@ -9,9 +9,6 @@
9 9
 require 'minitest/unit'
10 10
 require 'minitest/spec'
11 11
 
12  
-# compatability with old Test::Unit
13  
-#Test = MiniTest unless defined?(Test)
14  
-
15 12
 # load Turn's minitest runner
16 13
 require 'turn/runners/minirunner'
17 14
 
9  lib/turn/runners/isorunner.rb
@@ -27,7 +27,6 @@ def initialize
27 27
       @loadpath = @config.loadpath
28 28
       @requires = @config.requires
29 29
       @live     = @config.live?
30  
-      @minitest = @config.framework == :minitest
31 30
     end
32 31
 
33 32
   public
@@ -72,7 +71,6 @@ def test_loop_runner(suite)
72 71
         cmd << %[--loadpath="#{@loadpath.join(':')}"] unless @loadpath.empty?
73 72
         cmd << %[--requires="#{@requires.join(':')}"] unless @requires.empty?
74 73
         cmd << "--live" if @live
75  
-        cmd << "--minitest" if @minitest
76 74
         cmd << files.join(' ')
77 75
         cmd = cmd.join(' ')
78 76
 
@@ -130,13 +128,6 @@ def test_loop_runner(suite)
130 128
 
131 129
       reporter.finish_suite(suite)
132 130
 
133  
-      # shutdown auto runner
134  
-      if @minitest
135  
-
136  
-      else
137  
-        ::Test::Unit.run=true rescue nil
138  
-      end
139  
-
140 131
       suite
141 132
     end
142 133
 
168  lib/turn/runners/testrunner.rb
... ...
@@ -1,168 +0,0 @@
1  
-#require 'test/unit'; Test::Unit.run = false
2  
-require 'test/unit/ui/console/testrunner'
3  
-
4  
-#require 'turn/colorize'
5  
-#require 'turn/components/suite.rb'
6  
-#require 'turn/components/case.rb'
7  
-#require 'turn/components/method.rb'
8  
-#require 'turn/reporters/outline_reporter.rb'
9  
-#require 'turn/reporters/progress_reporter.rb'
10  
-
11  
-class Test::Unit::Failure
12  
-  alias_method :backtrace, :location
13  
-end
14  
-
15  
-module Turn
16  
-
17  
-  # Turn's Test::Unit console test runner.
18  
-  #
19  
-  class TestRunner < ::Test::Unit::UI::Console::TestRunner
20  
-
21  
-    #
22  
-    def initialize(suite, output_level, stdout=$stdout)
23  
-      turn_config = Turn.config
24  
-
25  
-      #output_level = 2 # 2-NORMAL 3-VERBOSE
26  
-
27  
-      name = turn_config.suite_name
28  
-
29  
-      # TODO: instead of building up a new suite, filter the suite
30  
-      # passed into initialize.
31  
-      sub_suites = []
32  
-      ObjectSpace.each_object(Class) do |klass|
33  
-        if(Test::Unit::TestCase > klass)
34  
-          sub_suites << klass.suite
35  
-        end
36  
-      end
37  
-      suite = Test::Unit::TestSuite.new(name)
38  
-
39  
-      matchcase = turn_config.matchcase
40  
-      pattern   = turn_config.pattern
41  
-
42  
-      if matchcase
43  
-        sub_suites = sub_suites.select{|s| matchcase =~ s.name}
44  
-      end
45  
-      sub_suites.sort_by{|s|s.name}.each{|s| suite << s}
46  
-
47  
-      suite.tests.each do |c|
48  
-        c.tests.reject!{ |t| pattern !~ t.method_name }
49  
-      end
50  
-
51  
-      @t_reporter = turn_config.reporter
52  
-
53  
-      super(suite, output_level, stdout)
54  
-    end
55  
-
56  
-    # Is this needed?
57  
-    alias :t_attach_to_mediator :attach_to_mediator
58  
-
59  
-    def attach_to_mediator
60  
-      @mediator.add_listener(::Test::Unit::UI::TestRunnerMediator::STARTED, &method(:t_started))
61  
-      @mediator.add_listener(::Test::Unit::UI::TestRunnerMediator::FINISHED, &method(:t_finished))
62  
-      @mediator.add_listener(::Test::Unit::TestSuite::STARTED, &method(:t_case_started))
63  
-      @mediator.add_listener(::Test::Unit::TestSuite::FINISHED, &method(:t_case_finished))
64  
-      @mediator.add_listener(::Test::Unit::TestCase::STARTED, &method(:t_test_started))
65  
-      @mediator.add_listener(::Test::Unit::TestCase::FINISHED, &method(:t_test_finished))
66  
-      @mediator.add_listener(::Test::Unit::TestResult::FAULT, &method(:t_fault))
67  
-
68  
-      @io.sync    = true
69  
-
70  
-      @t_result   = nil
71  
-      @t_fault    = nil
72  
-
73  
-      @not_first_case = nil
74  
-
75  
-      @t_previous_run_count       = 0
76  
-      @t_previous_error_count     = 0
77  
-      @t_previous_failure_count   = 0
78  
-      @t_previous_assertion_count = 0
79  
-    end
80  
-
81  
-    def t_started(result)
82  
-      @t_suite = Turn::TestSuite.new(@suite.name)
83  
-      @t_suite.size = @suite.size
84  
-      @t_result = result
85  
-      @t_reporter.start_suite(@t_suite)
86  
-    end
87  
-
88  
-    def t_case_started(name)
89  
-      # Err.. why is testunit running this on the suite?
90  
-      (@not_first_case = true; return) unless @not_first_case
91  
-      @t_case = @t_suite.new_case(name)
92  
-      @t_reporter.start_case(@t_case)
93  
-    end
94  
-
95  
-    def t_test_started(name)
96  
-      methname, tcase = name.scan(%r/^([^\(]+)\(([^\)]+)\)/o).flatten!
97  
-      @t_test = @t_case.new_test(methname)
98  
-      #@t_test.file = tcase
99  
-      #@t_test.name = method
100  
-      @t_reporter.start_test(@t_test)
101  
-    end
102  
-
103  
-    def t_fault(fault)
104  
-      case fault
105  
-      when ::Test::Unit::Error
106  
-        #msg = ""
107  
-        #msg << fault.to_s.split("\n")[2..-1].join("\n")
108  
-        @t_test.error!(fault.exception)
109  
-        @t_reporter.error(fault.exception)
110  
-      when ::Test::Unit::Failure
111  
-        #msg = ""
112  
-        #msg << fault.location[0] << "\n"
113  
-        #msg << fault.message #.gsub("\n","\n")
114  
-        @t_test.fail!(fault)
115  
-        @t_reporter.fail(fault)
116  
-      end
117  
-    end
118  
-
119  
-    def t_test_finished(name)
120  
-      @t_reporter.pass if @t_test.pass?
121  
-      @t_reporter.finish_test(@t_test)
122  
-    end
123  
-
124  
-    def t_case_finished(name)
125  
-      # Err.. why is testunit running this on the suite?
126  
-      return if name=='' # FIXME skip suite call
127  
-
128  
-      #t = @t_result.run_count       - @t_previous_run_count
129  
-      #f = @t_result.failure_count   - @t_previous_failure_count
130  
-      #e = @t_result.error_count     - @t_previous_error_count
131  
-      a = @t_result.assertion_count - @t_previous_assertion_count
132  
-      #@t_case.counts(t,a,f,e)
133  
-
134  
-      @t_case.count_assertions = a
135  
-
136  
-      #@t_previous_run_count       = @t_result.run_count.to_i
137  
-      #@t_previous_failure_count   = @t_result.failure_count.to_i
138  
-      #@t_previous_error_count     = @t_result.error_count.to_i
139  
-      @t_previous_assertion_count = @t_result.assertion_count.to_i
140  
-
141  
-      @t_reporter.finish_case(@t_case)
142  
-    end
143  
-
144  
-    def t_finished(elapsed_time)
145  
-      #@t_suite.count_tests      = @t_result.run_count
146  
-      #@t_suite.count_failures   = @t_result.failure_count
147  
-      #@t_suite.count_errors     = @t_result.error_count
148  
-      #@t_suite.count_passes     = @t_result.run_count - @t_result.failure_count - @t_result.error_count
149  
-      @t_suite.count_assertions = @t_result.assertion_count
150  
-
151  
-      @t_reporter.finish_suite(@t_suite)
152  
-    end
153  
-
154  
-    # This is copied verbatim from test/unit/ui/console/testrunner.rb.
155  
-    # It is here for one simple reason: to supress testunits output of
156  
-    # "Loaded Suite".
157  
-    def setup_mediator
158  
-      @mediator = create_mediator(@suite)
159  
-      suite_name = @suite.to_s
160  
-      if ( @suite.kind_of?(Module) )
161  
-        suite_name = @suite.name
162  
-      end
163  
-      #output("Loaded suite #{suite_name}")
164  
-    end
165  
-
166  
-  end#class TestRunner
167  
-
168  
-end#module Turn
24  lib/turn/testunit.rb
... ...
@@ -1,24 +0,0 @@
1  
-module Turn
2  
-
3  
-  # For TestUnit 1.x, completely outdated.
4  
-  def self.bootstrap_legacy(autorun=false)
5  
-    require 'fileutils'
6  
-
7  
-    require 'turn/version'
8  
-    require 'turn/autoload'
9  
-    require 'turn/configuration'
10  
-    require 'turn/colorize'
11  
-    require 'turn/components'
12  
-    require 'turn/controller'
13  
-
14  
-    require 'test/unit'
15  
-    require 'turn/runners/testrunner'
16  
-
17  
-    # need to turn this off unless autorun mode
18  
-    Test::Unit.run = autorun
19  
-  end
20  
-
21  
-end
22  
-
23  
-Turn.bootstrap_legacy(true)
24  
-
22  test/helper.rb
@@ -3,13 +3,9 @@
3 3
 #require 'turn/colorize'
4 4
 require 'fileutils'
5 5
 
6  
-if RUBY_VERSION < "1.9"
7  
-  require 'test/unit'
8  
-else
9  
-  gem 'minitest'
10  
-  require 'minitest/unit'
11  
-  require 'test/unit'
12  
-end
  6
+gem 'minitest'
  7
+require 'minitest/unit'
  8
+require 'test/unit'
13 9
 
14 10
 require 'turn'
15 11
 
@@ -18,20 +14,12 @@
18 14
 
19 15
 #
20 16
 def turn(*args)
21  
-  if RUBY_VERSION < '1.9'
22  
-    `ruby1.8 -Ilib bin/turn -Ilib #{args.join(' ')} 2>&1`
23  
-  else
24  
-    `ruby -Ilib bin/turn -Ilib #{args.join(' ')} 2>&1`
25  
-  end
  17
+  `ruby -Ilib bin/turn -Ilib #{args.join(' ')} 2>&1`
26 18
 end
27 19
 
28 20
 #
29 21
 def turn2(*args)
30  
-  if RUBY_VERSION < '1.9'
31  
-    `ruby1.8 -Ilib bin/turn -Ilib #{args.join(' ')}`
32  
-  else
33  
-    `ruby -Ilib bin/turn -Ilib #{args.join(' ')}`
34  
-  end
  22
+  `ruby -Ilib bin/turn -Ilib #{args.join(' ')}`
35 23
 end
36 24
 
37 25
 #
231  test/test_framework.rb
... ...
@@ -1,174 +1,97 @@
1 1
 require File.expand_path(File.dirname(__FILE__)) + '/helper.rb'
2 2
 
3  
-# Test on Ruby 1.9+
4  
-if RUBY_VERSION >= '1.9'
  3
+class TestRuby19Framework < MiniTest::Unit::TestCase
5 4
 
6  
-  class TestRuby19Framework < MiniTest::Unit::TestCase
7  
-
8  
-    def test_ruby19_minitest
9  
-      setup_test('MiniTest')
10  
-      result = turn 'tmp/test.rb'
11  
-      assert result.index('PASS')
12  
-    end
13  
-
14  
-    def test_ruby19_minitest_color
15  
-      unless defined?(ANSI)
16  
-        assert true   # skip ?
17  
-        return
18  
-      end  
19  
-  
20  
-      begin
21  
-        term, stdout = ENV['TERM'], $stdout
22  
-        host_os, ansicon, = ::RbConfig::CONFIG['host_os'], ENV['ANSICON']
23  
-        $stdout = $stdout.dup
24  
-
25  
-        verbose, debug   = $VERBOSE, $DEBUG
26  
-        $VERBOSE, $DEBUG = false, false
27  
-        def $stdout.tty? ; true ;  end
28  
-        $VERBOSE, $DEBUG = verbose, debug
  5
+  def test_ruby19_minitest
  6
+    setup_test('MiniTest')
  7
+    result = turn 'tmp/test.rb'
  8
+    assert result.index('PASS')
  9
+  end
29 10
 
30  
-        ENV['ANSICON'] = nil
31  
-        ENV['TERM'] = 'xterm'
  11
+  def test_ruby19_minitest_color
  12
+    unless defined?(ANSI)
  13
+      assert true   # skip ?
  14
+      return
  15
+    end  
  16
+
  17
+    begin
  18
+      term, stdout = ENV['TERM'], $stdout
  19
+      host_os, ansicon, = ::RbConfig::CONFIG['host_os'], ENV['ANSICON']
  20
+      $stdout = $stdout.dup
  21
+
  22
+      verbose, debug   = $VERBOSE, $DEBUG
  23
+      $VERBOSE, $DEBUG = false, false
  24
+      def $stdout.tty? ; true ;  end
  25
+      $VERBOSE, $DEBUG = verbose, debug
  26
+
  27
+      ENV['ANSICON'] = nil
  28
+      ENV['TERM'] = 'xterm'
  29
+      assert_equal true, Turn::Colorize.color_supported?
  30
+      ENV['TERM'] = 'dumb'
  31
+      assert_equal false, Turn::Colorize.color_supported?
  32
+      ENV['TERM'] = nil
  33
+      assert_equal false, Turn::Colorize.color_supported?
  34
+      ['mingw32', 'mswin32'].each do |os|
  35
+        ::RbConfig::CONFIG['host_os'] = os
  36
+        ENV['ANSICON'] = '120x5000 (120x50)'
32 37
         assert_equal true, Turn::Colorize.color_supported?
33  
-        ENV['TERM'] = 'dumb'
34  
-        assert_equal false, Turn::Colorize.color_supported?
35  
-        ENV['TERM'] = nil
36  
-        assert_equal false, Turn::Colorize.color_supported?
37  
-        ['mingw32', 'mswin32'].each do |os|
38  
-          ::RbConfig::CONFIG['host_os'] = os
39  
-          ENV['ANSICON'] = '120x5000 (120x50)'
40  
-          assert_equal true, Turn::Colorize.color_supported?
41  
-          ENV['ANSICON'] = nil
42  
-          assert_equal false, Turn::Colorize.color_supported?
43  
-        end
44  
-        ENV['TERM'] = 'xterm'
45  
-
46  
-        verbose, debug   = $VERBOSE, $DEBUG
47  
-        $VERBOSE, $DEBUG = false, false
48  
-        def $stdout.tty? ; false ; end
49  
-        $VERBOSE, $DEBUG = verbose, debug
50  
-
  38
+        ENV['ANSICON'] = nil
51 39
         assert_equal false, Turn::Colorize.color_supported?
52  
-      ensure
53  
-        ENV['TERM'], $stdout = term, stdout
54  
-        ::RbConfig::CONFIG['host_os'], ENV['ANSICON'] = host_os, ansicon
55 40
       end
56  
-    end
57  
-
58  
-    #def test_ruby19_minitest_force
59  
-    #  setup_test('MiniTest')
60  
-    #  result = turn '--minitest tmp/test.rb'
61  
-    #  assert result.index('PASS')
62  
-    #end
63  
-
64  
-    def test_ruby19_minitest_required
65  
-      setup_test('MiniTest', 'minitest/unit')
66  
-      result = turn 'tmp/test.rb'
67  
-      assert result.index('PASS')
68  
-    end
69  
-
70  
-    #def test_ruby19_minitest_required_force
71  
-    #  setup_test('MiniTest', 'minitest/unit')
72  
-    #  result = turn '--minitest tmp/test.rb'
73  
-    #  assert result.index('PASS')
74  
-    #end
75  
-
76  
-    def test_ruby19_minitest_mocking
77  
-      setup_testunit
78  
-      result = turn 'tmp/test.rb'
79  
-      assert result.index('PASS'), "RESULT:\n#{result}"
80  
-    end
  41
+      ENV['TERM'] = 'xterm'
81 42
 
82  
-    #def test_ruby19_minitest_mocking_force
83  
-    #  setup_test('Test')
84  
-    #  result = turn '--minitest tmp/test.rb'
85  
-    #  assert result.index('PASS')
86  
-    #end
  43
+      verbose, debug   = $VERBOSE, $DEBUG
  44
+      $VERBOSE, $DEBUG = false, false
  45
+      def $stdout.tty? ; false ; end
  46
+      $VERBOSE, $DEBUG = verbose, debug
87 47
 
88  
-    def test_ruby19_minitest_mocking_required
89  
-      setup_test('Test', 'minitest/unit')
90  
-      result = turn 'tmp/test.rb'
91  
-      assert result.index('PASS')
  48
+      assert_equal false, Turn::Colorize.color_supported?
  49
+    ensure
  50
+      ENV['TERM'], $stdout = term, stdout
  51
+      ::RbConfig::CONFIG['host_os'], ENV['ANSICON'] = host_os, ansicon
92 52
     end
93  
-
94  
-    #def test_ruby19_minitest_mocking_required_force
95  
-    #  setup_test('Test', 'minitest/unit')
96  
-    #  result = turn '--minitest tmp/test.rb'
97  
-    #  assert result.index('PASS')
98  
-    #end
99  
-
100  
-    #
101  
-    def test_ruby19_testunit_required
102  
-      setup_testunit
103  
-      result = turn 'turn tmp/test.rb'
104  
-      assert result.index('PASS')
105  
-    end
106  
-
107  
-    # Turn does not support Test::Unit 2.0+.
108  
-    #def test_ruby19_testunit_force
109  
-    #  setup_test('Test')
110  
-    #  result = turn '--testunit tmp/test.rb'
111  
-    #  assert result.index('PASS')
112  
-    #end
113  
-
114  
-    # Turn does not support Test::Unit 2.0+.
115  
-    #def test_ruby19_testunit_required_force
116  
-    #  setup_test('Test', 'test/unit')
117  
-    #  result = turn '--testunit tmp/test.rb'
118  
-    #  assert result.index('PASS')
119  
-    #end
120  
-
121 53
   end
122 54
 
123  
-else
124  
-
125  
-  class TestRuby18Framework < Test::Unit::TestCase
126  
-
127  
-    def test_ruby18_testunit
128  
-      setup_testunit
129  
-      result = turn 'tmp/test.rb'
130  
-      assert result.index('PASS'), "ACTUAL RESULT:\n#{result}"
131  
-    end
  55
+  #def test_ruby19_minitest_force
  56
+  #  setup_test('MiniTest')
  57
+  #  result = turn '--minitest tmp/test.rb'
  58
+  #  assert result.index('PASS')
  59
+  #end
132 60
 
133  
-    def test_ruby18_testunit_required
134  
-      setup_testunit
135  
-      result = turn 'tmp/test.rb'
136  
-      assert result.index('PASS'), "ACTUAL RESULT:\n#{result}"
137  
-    end
  61
+  def test_ruby19_minitest_required
  62
+    setup_test('MiniTest', 'minitest/unit')
  63
+    result = turn 'tmp/test.rb'
  64
+    assert result.index('PASS')
  65
+  end
138 66
 
139  
-    def test_ruby18_minitest
140  
-      setup_test('MiniTest')
141  
-      result = turn 'tmp/test.rb'
142  
-      assert result.index('PASS'), "ACTUAL RESULT:\n#{result}"
143  
-    end
  67
+  #def test_ruby19_minitest_required_force
  68
+  #  setup_test('MiniTest', 'minitest/unit')
  69
+  #  result = turn '--minitest tmp/test.rb'
  70
+  #  assert result.index('PASS')
  71
+  #end
144 72
 
145  
-    def test_ruby18_minitest_mocking_testunit
146  
-      setup_test('Test')
147  
-      result = turn 'tmp/test.rb'
148  
-      assert result.index('PASS'), "ACTUAL RESULT:\n#{result}"
149  
-    end
  73
+  def test_ruby19_minitest_mocking
  74
+    setup_test('MiniTest', 'minitest/unit')
  75
+    result = turn 'tmp/test.rb'
  76
+    assert result.index('PASS'), "RESULT:\n#{result}"
  77
+  end
150 78
 
151  
-    # You can't use minitest and have ++require 'test/unit'++ in your tests.
152  
-    #def test_ruby18_minitest_mocking_testunit_required
153  
-    #  setup_test('Test', 'test/unit')
154  
-    #  result = turn '--minitest tmp/test.rb'
155  
-    #  assert result.index('PASS')
156  
-    #end
157  
-
158  
-    # If you want to use minitest with Ruby 1.8 you have to use force option.
159  
-    # TODO: add turn configuration to automatically do this.
160  
-    #def test_ruby18_minitest_required
161  
-    #  setup_test('MiniTest', 'minitest/unit')
162  
-    #  result = turn 'tmp/test.rb'
163  
-    #  assert result.index('PASS')
164  
-    #end
165  
-
166  
-    def test_ruby18_minitest_required_force
167  
-      setup_test('MiniTest', 'minitest/unit')
168  
-      result = turn 'tmp/test.rb'
169  
-      assert result.index('PASS'), "ACTUAL RESULT:\n#{result}"
170  
-    end
  79
+  #def test_ruby19_minitest_mocking_force
  80
+  #  setup_test('Test')
  81
+  #  result = turn '--minitest tmp/test.rb'
  82
+  #  assert result.index('PASS')
  83
+  #end
171 84
 
  85
+  def test_ruby19_minitest_mocking_required
  86
+    setup_test('Test', 'minitest/unit')
  87
+    result = turn 'tmp/test.rb'
  88
+    assert result.index('PASS')
172 89
   end
173 90
 
  91
+  #def test_ruby19_minitest_mocking_required_force
  92
+  #  setup_test('Test', 'minitest/unit')
  93
+  #  result = turn '--minitest tmp/test.rb'
  94
+  #  assert result.index('PASS')
  95
+  #end
  96
+
174 97
 end
69  test/test_runners.rb
@@ -29,55 +29,40 @@ def test_minispec_name
29 29
 
30 30
   # autorun
31 31
 
32  
-  #if RUBY_VERSION < '1.9'
33  
-
34  
-    def test_autorun_testunit
35  
-      file = setup_testunit('turn/autorun', 'test_autorun.rb')
36  
-      result = `ruby -Ilib #{file} 2>&1`
37  
-      assert(result.index('1 passed'),  "ACTUAL RESULT:\n #{result}")
38  
-      assert(result.index('0 failures'),  "ACTUAL RESULT:\n #{result}")
39  
-      assert(result.index('0 errors'), "ACTUAL RESULT:\n #{result}")
40  
-    end
41  
-
42  
-    def test_autorun_minispec_name
43  
-      file = setup_minispec
44  
-      result = `ruby -Ilib #{file} -n "/fail/" 2>&1`
45  
-
46  
-      assert result.index('0 passed'), "ACTUAL RESULT:\n #{result}"
47  
-      assert result.index('1 failures'), "ACTUAL RESULT:\n #{result}"
48  
-      assert result.index('1 assertions'),  "ACTUAL RESULT:\n #{result}"
49  
-    end
50  
-
51  
-  #else
  32
+  def test_autorun_minispec_name
  33
+    file = setup_minispec
  34
+    result = `ruby -Ilib #{file} -n "/fail/" 2>&1`
52 35
 
53  
-    def test_autorun
54  
-      file = setup_minitest_autorun
55  
-      result = `ruby -Ilib #{file} 2>&1`
56  
-      assert result.index('0 failures'),  "ACTUAL RESULT:\n #{result}"
57  
-      assert result.index('0 errors'), "ACTUAL RESULT:\n #{result}"