rubytest 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/.index CHANGED
@@ -9,14 +9,26 @@ authors:
9
9
  organizations: []
10
10
  requirements:
11
11
  - name: ansi
12
+ - groups:
13
+ - build
14
+ development: true
15
+ name: fire
12
16
  - groups:
13
17
  - build
14
18
  development: true
15
19
  name: detroit
20
+ - groups:
21
+ - build
22
+ development: true
23
+ name: dotopts
16
24
  - groups:
17
25
  - test
18
26
  development: true
19
27
  name: qed
28
+ - groups:
29
+ - test
30
+ development: true
31
+ name: ae
20
32
  conflicts: []
21
33
  alternatives: []
22
34
  resources:
@@ -32,7 +44,7 @@ resources:
32
44
  repositories:
33
45
  - name: upstream
34
46
  scm: git
35
- uri: git@github.com:rubyworks/ruby-test.git
47
+ uri: git@github.com:rubyworks/rubytest.git
36
48
  categories: []
37
49
  copyrights:
38
50
  - holder: RubyWorks
@@ -45,9 +57,9 @@ paths:
45
57
  created: '2011-07-23'
46
58
  summary: Ruby Universal Test Harness
47
59
  title: Ruby Test
48
- version: 0.5.4
60
+ version: 0.6.0
49
61
  name: rubytest
50
62
  description: ! "Ruby Test is a universal test harness for Ruby. It can handle any
51
63
  compliant \ntest framework, even running tests from multiple frameworks in a single
52
64
  pass."
53
- date: '2013-01-22'
65
+ date: '2013-02-09'
data/HISTORY.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # RELEASE HISTORY
2
2
 
3
+ ## 0.6.0 / 2013-02-10
4
+
5
+ This release of Ruby Test takes a hard step back and reconsiders how
6
+ to handle configuration from the ground up. Current users of Ruby Test
7
+ will probably have to make some adjustments. Our apologies for the extra
8
+ work. But the whole thing simply got more complicated than it needed to
9
+ be and it was decided that conventional simplicity, with the option
10
+ unconventional complexity, was the best approach.
11
+
12
+ To make a long story short... There is no default config file anymore.
13
+ The `-p/--profile` command line option has been removed; replaced by
14
+ a `-c/--config` option which requires a file relative to the working
15
+ directory. In addition the configuration API had been changed from `Test.run`
16
+ or `Test.configure`, to adopt the common convention, and it no longer takes
17
+ a profile name for an argument. `Test.run` still has the same interface as
18
+ `Test.configure` but it will now run tests immediately! So be sure to change
19
+ that if you used it the past. Lastly, Ruby Test now supports DotOpts out of
20
+ the box, so its easier then ever to setup default command line options.
21
+
22
+ Changes:
23
+
24
+ * Rename `Test.run` to `Test.configure` and remove profile argument.
25
+ * Add new `Test.run` to immediately run tests.
26
+ * Add `-c/--config` option for requiring project file.
27
+ * Add `-C` and `-R` options for changing directory.
28
+ * Add built-in support for DotOpts.
29
+ * Deprecate profiles, removing `-p/--profile` cli option.
30
+ * Deprecate Test::Runner configuration class methods.
31
+
32
+
3
33
  ## 0.5.4 / 2013-01-22
4
34
 
5
35
  This release simply updates configuraiton code to work with RC v0.4.0.
data/README.md CHANGED
@@ -5,15 +5,19 @@
5
5
  [Development](http://github.com/rubyworks/rubytest) /
6
6
  [Issues](http://github.com/rubyworks/rubytest/issues)
7
7
 
8
+ [![Build Status](https://secure.travis-ci.org/rubyworks/rubytest.png)](http://travis-ci.org/rubyworks/rubytest)
9
+ [![Gem Version](https://badge.fury.io/rb/rubytest.png)](http://badge.fury.io/rb/rubytest)
10
+
11
+
8
12
  ## Description
9
13
 
10
- Ruby Test is a universal test harness for Ruby that can be used by any Ruby
11
- test framework. Ruby Test defines a simple specification for compliance, which
12
- allows tests from various frameworks to all run
14
+ Ruby Test is a universal test harness for Ruby developers. It can be used
15
+ by any Ruby test framework. You can think of Ruby Test as a *meta test framework*.
16
+ Ruby Test defines a straight-forward specification that any test framework
17
+ can utilize as it back-end. This makes it almost trivial to implement new
18
+ test frameworks. Ruby Test further allows tests from various frameworks
19
+ to all run through a single uniform user interface in a single pass.
13
20
 
14
- Ruby Test defines a straight-forward specification that any test framework can
15
- easily support which allows Ruby Test to run the frameworks tests through a
16
- single uniform user interface in a single pass.
17
21
 
18
22
  ## Specification
19
23
 
@@ -25,10 +29,9 @@ over as a test case with each entry handled in the same manner. All test
25
29
  objects must respond to `#to_s` so their description can be used in test
26
30
  reports.
27
31
 
28
- Any raised exception that responds to `#assertion?` in the affirmative is taken
29
- to be a failed assertion rather than simply an error. Ruby Test extends the
30
- Exception class to support this method for all exceptions.
31
-
32
+ Ruby Test handles assertions with [BRASS](http://rubyworks.github.com/brass)
33
+ compliance. Any raised exception that responds to `#assertion?` in the
34
+ affirmative is taken to be a failed assertion rather than simply an error.
32
35
  A test framework may raise a `NotImplementedError` to have a test recorded
33
36
  as *todo* --a _pending_ exception to remind the developer of tests that still
34
37
  need to be written. The `NotImplementedError` is a standard Ruby exception
@@ -42,42 +45,62 @@ additional features that can makes its usage even more convenient.
42
45
  See the [Wiki](http://github.com/rubyworks/test/wiki) for further details.
43
46
 
44
47
 
45
- ## Usage
48
+ ## Installation
46
49
 
47
- There are a few ways to run tests. First, there is a command line tool:
50
+ Ruby Test is available as a Gem package.
48
51
 
49
- $ rubytest
52
+ $ gem install rubytest
50
53
 
51
- The command line tool takes various options, use `--help` to see them.
52
- Be sure to load in your test framework or framework's Ruby Test adapter.
54
+ Ruby Test is compliant with Setup.rb layout standard, so it can
55
+ also be installed in an FHS compliant fashion if necessary.
53
56
 
54
- Preconfigurations can be defined in a `.test` file, e.g.
55
57
 
56
- Test.run 'default' do |r|
57
- r.format = 'progress'
58
- r.requires << 'lemon'
59
- r.files << 'test/*_case.rb'
60
- end
58
+ ## Running Tests
61
59
 
62
- There is also a 'rubytest/autorun.rb' library script that can be loaded which
63
- creates an `at_exit` runner, for which `test.rb` provides a nice shortcut:
60
+ There are a few ways to run tests. First, there is the command line tool
61
+ e.g.
64
62
 
65
- $ ruby -r test
63
+ $ rubytest test/test_*.rb
66
64
 
67
- There is also a Rake task.
65
+ The command line tool takes various options, use `-h/--help` to see them.
68
66
 
69
- require 'rubytest/rake'
67
+ When running tests, you need to be sure to load in your test framework
68
+ or your framework's Ruby Test adapter. This is usually done via a helper
69
+ script in the test files, but might also be done via command line options,
70
+ e.g.
70
71
 
71
- Test::Rake::TestTask.new
72
+ $ rubytest -r lemon -r ae test/test_*.rb
72
73
 
73
- A Detroit plugin is in the works and should be available soon.
74
+ Ruby Test supports [dotopts](http://rubyworks.github.com/dotopts) out of the
75
+ box, so it easy to setup reusable options. For example, a `.option` file
76
+ entry might be:
74
77
 
78
+ rubytest
79
+ -f progress
80
+ -r spectroscope
81
+ -r rspecial
82
+ spec/spec_*.rb
75
83
 
76
- ## Installation
84
+ If you are using a build tool to run your tests, such as Rake or Fire, it is
85
+ best to shell out to `rubytest`. This keeps your test environent as prestine
86
+ as possible.
77
87
 
78
- Ruby Test is available as Gem package.
88
+ desc "run tests"
89
+ task :test
90
+ sh "rubytest"
91
+ end
79
92
 
80
- $ gem install rubytest
93
+ RubyTest comes with a Rake task plugin, but its use is all but deprecated
94
+ because it's basically just a glorified rendition of the above.
95
+
96
+ require 'rubytest/rake'
97
+
98
+ Test::Rake::TestTask.new :test do |run|
99
+ run.requires << 'lemon'
100
+ run.files = 'test/test_*.rb'
101
+ end
102
+
103
+ See the Wiki for more information on the different ways to run tests.
81
104
 
82
105
 
83
106
  ## Requirements
@@ -85,28 +108,29 @@ Ruby Test is available as Gem package.
85
108
  Ruby Test uses the [ANSI](http://rubyworks.github.com/ansi) gem for color output.
86
109
 
87
110
  Because of the "foundational" nature of this library we will look at removing
88
- this dependencies for future versions, but for early development the
111
+ this dependency for future versions, but for early development the
89
112
  requirements does the job and does it well.
90
113
 
91
114
 
92
115
  ## Development
93
116
 
94
- Ruby Test is still a "nuby" gem. Please feel OBLIGATED to help improve it ;-)
117
+ Ruby Test is still a bit of a "nuby" gem. Please feel OBLIGATED to help improve it ;-)
95
118
 
96
- Ruby Test is a [RubyWorks](http://rubyworks.github.com) project. If you can't
97
- contribue code, you can still help out by contributing to our development fund.
119
+ Ruby Test is a [Rubyworks](http://rubyworks.github.com) project. If you can't
120
+ contribute code, you can still help out by contributing to our development fund.
98
121
 
99
122
 
100
123
  ## Reference Material
101
124
 
102
- [1] [Standard Definition Of Unit Test](http://c2.com/cgi/wiki?StandardDefinitionOfUnitTest)
125
+ * [Standard Definition Of Unit Test](http://c2.com/cgi/wiki?StandardDefinitionOfUnitTest)
126
+ * [BRASS Assertions Standard](http:rubyworks.github.com/brass)
103
127
 
104
128
 
105
129
  ## Copyrights
106
130
 
107
131
  Copyright (c) 2011 Rubyworks
108
132
 
109
- Made available according to the terms of the <b>FreeBSD license</b>.
133
+ Made available according to the terms of the <b>BSD-2-Clause</b> license.
110
134
 
111
- See NOTICE.md for details.
135
+ See LICENSE.txt for details.
112
136
 
data/bin/ruby-test CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubytest'
3
- Test::CLI.run(*ARGV)
2
+ begin
3
+ require 'rubytest'
4
+ Test::CLI.run
5
+ rescue RuntimeError => error
6
+ raise error if $DEBUG
7
+ $stderr.puts error
8
+ end
4
9
 
data/bin/rubytest CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubytest'
3
- Test::CLI.run(*ARGV)
2
+ begin
3
+ require 'rubytest'
4
+ Test::CLI.run
5
+ rescue RuntimeError => error
6
+ raise error if $DEBUG
7
+ $stderr.puts error
8
+ end
4
9
 
data/lib/rubytest.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Ruby Test - a Universal Ruby Test Harness
1
+ # Ruby Test - Universal Ruby Test Harness
2
2
 
3
3
  $TEST_SUITE = [] unless defined?($TEST_SUITE)
4
4
  $RUBY_IGNORE_CALLERS = [] unless defined?($RUBY_IGNORE_CALLERS)
@@ -6,11 +6,27 @@ $RUBY_IGNORE_CALLERS = [] unless defined?($RUBY_IGNORE_CALLERS)
6
6
  #require 'brass' # TODO: Should we require BRASS ?
7
7
  require 'ansi/core'
8
8
 
9
+ module Test
10
+ # Load project index on demand.
11
+ def self.index
12
+ @index ||= (
13
+ require 'yaml'
14
+ __dir__ = File.dirname(__FILE__)
15
+ file = File.expand_path('rubytest.yml', __dir__)
16
+ YAML.load_file(file)
17
+ )
18
+ end
19
+
20
+ # Lookup missing constant in project index.
21
+ def self.const_missing(name)
22
+ index[name.to_s.downcase] || super(name)
23
+ end
24
+ end
25
+
9
26
  if RUBY_VERSION < '1.9'
10
27
  require 'rubytest/core_ext'
11
28
  require 'rubytest/code_snippet'
12
29
  require 'rubytest/config'
13
- require 'rubytest/rc'
14
30
  require 'rubytest/recorder'
15
31
  require 'rubytest/advice'
16
32
  require 'rubytest/runner'
@@ -21,7 +37,6 @@ else
21
37
  require_relative 'rubytest/core_ext'
22
38
  require_relative 'rubytest/code_snippet'
23
39
  require_relative 'rubytest/config'
24
- require_relative 'rubytest/rc'
25
40
  require_relative 'rubytest/recorder'
26
41
  require_relative 'rubytest/advice'
27
42
  require_relative 'rubytest/runner'
data/lib/rubytest.yml ADDED
@@ -0,0 +1,65 @@
1
+ ---
2
+ revision: 2013
3
+ type: ruby
4
+ sources:
5
+ - var
6
+ authors:
7
+ - name: trans
8
+ email: transfire@gmail.com
9
+ organizations: []
10
+ requirements:
11
+ - name: ansi
12
+ - groups:
13
+ - build
14
+ development: true
15
+ name: fire
16
+ - groups:
17
+ - build
18
+ development: true
19
+ name: detroit
20
+ - groups:
21
+ - build
22
+ development: true
23
+ name: dotopts
24
+ - groups:
25
+ - test
26
+ development: true
27
+ name: qed
28
+ - groups:
29
+ - test
30
+ development: true
31
+ name: ae
32
+ conflicts: []
33
+ alternatives: []
34
+ resources:
35
+ - type: home
36
+ uri: http://rubyworks.github.com/rubytest
37
+ label: Homepage
38
+ - type: code
39
+ uri: http://github.com/rubyworks/rubytest
40
+ label: Source Code
41
+ - type: mail
42
+ uri: http://groups.google.com/group/rubyworks-mailinglist
43
+ label: Mailing List
44
+ repositories:
45
+ - name: upstream
46
+ scm: git
47
+ uri: git@github.com:rubyworks/rubytest.git
48
+ categories: []
49
+ copyrights:
50
+ - holder: RubyWorks
51
+ year: '2011'
52
+ license: BSD-2-Clause
53
+ customs: []
54
+ paths:
55
+ lib:
56
+ - lib
57
+ created: '2011-07-23'
58
+ summary: Ruby Universal Test Harness
59
+ title: Ruby Test
60
+ version: 0.6.0
61
+ name: rubytest
62
+ description: ! "Ruby Test is a universal test harness for Ruby. It can handle any
63
+ compliant \ntest framework, even running tests from multiple frameworks in a single
64
+ pass."
65
+ date: '2013-02-09'
@@ -1,19 +1,7 @@
1
- #$TEST_SUITE = [] unless defined?($TEST_SUITE)
2
-
3
- if RUBY_VERSION < '1.9'
4
- require 'rubytest'
5
- else
6
- require_relative '../rubytest'
7
- end
1
+ require 'rubytest'
8
2
 
9
3
  at_exit {
10
- suite = $TEST_SUITE
11
- options = {
12
- :format => ENV['rubytest-format'] # TODO: better name?
13
- }
14
-
15
- runner = Ruth::Test::Runner.new(suite, options)
16
- success = runner.run
4
+ success = Test.run
17
5
  exit -1 unless success
18
6
  }
19
7
 
data/lib/rubytest/cli.rb CHANGED
@@ -2,65 +2,52 @@ module Test
2
2
 
3
3
  # Command line interface to test runner.
4
4
  #
5
+ # TODO: Use `cli` based library instead of option parser?
6
+ #
5
7
  class CLI
6
8
 
7
- #
8
9
  # Convenience method for invoking the CLI.
9
10
  #
11
+ # @return nothing
10
12
  def self.run(*argv)
11
13
  new.run(*argv)
12
14
  end
13
15
 
14
- #
15
16
  # Initialize CLI instance.
16
17
  #
18
+ # @return nothing
17
19
  def initialize
18
20
  require 'optparse'
19
21
 
20
- Test::Config.load
21
-
22
- #@profile = ENV['profile'] || ENV['p'] || 'default'
23
- @config = Test.config
24
- @runner = Runner.new
22
+ @config = Test.configuration(true)
25
23
  end
26
24
 
25
+ # Test run configuration.
27
26
  #
28
- # @return [Runner]
29
- #
30
- attr :runner
31
-
32
- #
33
- # @return [Hash]
34
- #
35
- attr :config
36
-
37
- #
38
- def profile
39
- ENV['profile'] || ENV['p'] || 'default'
27
+ # @return [Config]
28
+ def config
29
+ @config
40
30
  end
41
31
 
42
- #
43
- def profile=(name)
44
- ENV['profile'] = name.to_s
45
- end
46
-
47
- #
48
32
  # Run tests.
49
33
  #
50
- def run(*argv)
51
- options.parse!(argv)
52
-
53
- if Object.const_get(:RC)
54
- RC.configure('rubytest')
34
+ # @return nothing
35
+ def run(argv=nil)
36
+ begin
37
+ require 'dotopts'
38
+ rescue LoadError
55
39
  end
56
40
 
57
- run_profile
41
+ argv = (argv || ARGV.dup)
58
42
 
59
- runner.files.replace(argv) unless argv.empty?
43
+ options.parse!(argv)
60
44
 
61
- # TODO: this should probably be invoked via runner.run instead
62
- Test::Config.load_path_setup if runner.autopath?
45
+ config.files.replace(argv) unless argv.empty?
63
46
 
47
+ config.apply_environment_overrides
48
+
49
+ #Test.run(config)
50
+ runner = Runner.new(config)
64
51
  begin
65
52
  success = runner.run
66
53
  exit -1 unless success
@@ -71,90 +58,87 @@ module Test
71
58
  end
72
59
  end
73
60
 
74
- #
75
- # Run the common profile if defined and then the specific
76
- # profile.
77
- #
78
- def run_profile
79
- raise "no such profile -- #{profile}" unless config[profile] or profile == 'default'
80
-
81
- common = config['common']
82
- common.call(runner) if common
83
-
84
- profig = config[profile]
85
- profig.call(runner) if profig
86
- end
87
-
88
- #
89
61
  # Setup OptionsParser instance.
90
62
  #
63
+ # @return [OptionParser]
91
64
  def options
92
65
  this = self
93
66
 
94
67
  OptionParser.new do |opt|
95
- opt.banner = "Usage: #{$0} [options] [files ...]"
96
-
97
- opt.separator "PRESET OPTIONS:"
98
-
99
- opt.on '-p', '--profile NAME', "use configuration profile" do |name|
100
- this.profile = name.to_s
101
- end
68
+ opt.banner = "Usage: #{File.basename($0)} [options] [files ...]"
102
69
 
103
- config_names = config.keys - ['common', 'default']
70
+ #opt.separator "PRESET OPTIONS:"
71
+ #pnames = profile_names
72
+ #unless pnames.empty?
73
+ # pnames.each do |pname|
74
+ # opt.separator((" " * 40) + "* #{pname}")
75
+ # end
76
+ #end
77
+ #opt.separator "CONFIG OPTIONS:"
104
78
 
105
- unless config_names.empty?
106
- config_names.each do |name|
107
- opt.separator((" " * 40) + "* #{name}")
108
- end
109
- end
110
-
111
- opt.separator "CONFIG OPTIONS:"
112
79
  opt.on '-f', '--format NAME', 'report format' do |name|
113
- runner.format = name
80
+ config.format = name
114
81
  end
115
82
  opt.on '-y', '--tapy', 'shortcut for -f tapy' do
116
- runner.format = 'tapy'
83
+ config.format = 'tapy'
117
84
  end
118
85
  opt.on '-j', '--tapj', 'shortcut for -f tapj' do
119
- runner.format = 'tapj'
86
+ config.format = 'tapj'
120
87
  end
121
88
 
122
89
  opt.on '-t', '--tag TAG', 'select tests by tag' do |tag|
123
- runner.tags << tag
90
+ config.tags.concat makelist(tag)
124
91
  end
125
92
  opt.on '-u', '--unit TAG', 'select tests by software unit' do |unit|
126
- runner.units << unit
93
+ config.units.concat makelist(unit)
127
94
  end
128
95
  opt.on '-m', '--match TEXT', 'select tests by description' do |text|
129
- runner.match << text
96
+ config.match.concat makelist(text)
130
97
  end
131
98
 
132
- opt.on '-a', '--autopath', 'automatically add to $LOAD_PATH' do |paths|
133
- runner.autopath = true
99
+ opt.on '-A', '--autopath', 'automatically add paths to $LOAD_PATH' do |paths|
100
+ config.autopath = true
134
101
  end
135
- opt.on '-I', '--loadpath PATH', 'add to $LOAD_PATH' do |paths|
136
- paths.split(/[:;]/).reverse_each do |path|
137
- $LOAD_PATH.unshift path
138
- end
102
+ opt.on '-I', '--loadpath PATH', 'add given path to $LOAD_PATH' do |paths|
103
+ #makelist(paths).reverse_each do |path|
104
+ # $LOAD_PATH.unshift path
105
+ #end
106
+ config.loadpath.concat makelist(paths)
107
+ end
108
+ opt.on '-C', '--chdir DIR', 'change directory before running tests' do |dir|
109
+ config.chdir = dir
110
+ end
111
+ opt.on '-R', '--chroot', 'change to project root directory before running tests' do
112
+ config.chdir = Config.root
139
113
  end
140
114
  opt.on '-r', '--require FILE', 'require file' do |file|
141
- require file
115
+ #require file
116
+ config.requires.concat makelist(file)
117
+ end
118
+ opt.on '-c', '--config FILE', "require local config file (immediately)" do |file|
119
+ config.load_config(file)
142
120
  end
143
- opt.on '-v' , '--verbose', 'provide extra detailed report' do
144
- runner.verbose = true
121
+ opt.on '-V' , '--verbose', 'provide extra detail in reports' do
122
+ config.verbose = true
145
123
  end
146
- #opt.on('--log DIRECTORY', 'log directory'){ |dir|
147
- # options[:log] = dir
124
+ #opt.on('--log PATH', 'log test output to path'){ |path|
125
+ # config.log = path
148
126
  #}
149
127
  opt.on("--[no-]ansi" , 'turn on/off ANSI colors'){ |v| $ansi = v }
150
128
  opt.on("--debug" , 'turn on debugging mode'){ $DEBUG = true }
151
129
 
152
- opt.separator "COMMAND OPTIONS:"
153
- #opt.on("--about" , 'display information about rubytest'){
154
- # puts "Ruby Test v#{VERSION}"
155
- # puts "#{COPYRIGHT}"
156
- # exit
157
- #}
130
+ #opt.separator "COMMAND OPTIONS:"
131
+ opt.on('--about' , 'display information about rubytest') do
132
+ puts "Ruby Test v%s" % [Test.index['version']]
133
+ Test.index['copyrights'].each do |c|
134
+ puts "(c) %s %s (%s)" % c.values_at('year', 'holder', 'license')
135
+ end
136
+ exit
137
+ end
138
+ opt.on('--version' , 'display rubytest version') do
139
+ puts Test::VERSION
140
+ exit
141
+ end
158
142
  opt.on('-h', '--help', 'display this help message'){
159
143
  puts opt
160
144
  exit
@@ -162,6 +146,21 @@ module Test
162
146
  end
163
147
  end
164
148
 
149
+ # If given a String then split up at `:` and `;` markers.
150
+ # Otherwise ensure the list is an Array and the entries are
151
+ # all strings and not empty.
152
+ #
153
+ # @return [Array<String>]
154
+ def makelist(list)
155
+ case list
156
+ when String
157
+ list = list.split(/[:;]/)
158
+ else
159
+ list = Array(list).map{ |path| path.to_s }
160
+ end
161
+ list.reject{ |path| path.strip.empty? }
162
+ end
163
+
165
164
  end
166
165
 
167
166
  end