Skip to content

Commit d5bea5b

Browse files
committed
Spin-off parts as plugins.
* Add support for config profiles. * Remove rubytest command, along with rake task. * Bump version to 0.7.0.
1 parent 63edc9a commit d5bea5b

7 files changed

Lines changed: 71 additions & 85 deletions

File tree

.index

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ paths:
5353
created: '2011-07-23'
5454
summary: Ruby Universal Test Harness
5555
title: Ruby Test
56-
version: 0.6.1
56+
version: 0.7.0
5757
name: rubytest
5858
description: ! "Ruby Test is a universal test harness for Ruby. It can handle any
5959
compliant \ntest framework, even running tests from multiple frameworks in a single
6060
pass."
61-
date: '2013-02-14'
61+
date: '2013-02-17'

HISTORY.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
11
# RELEASE HISTORY
22

3-
## 0.6.1 / 2013-02-15
3+
## 0.7.0 / 2013-02-18
4+
5+
Version 0.7 is a significant release. The library has been simplified
6+
by spinning-off the both the command-line tool and the Rake task as
7+
`rubytest-cli` and `rubytest-rake` respectively. This was done for a
8+
couple of good reasons: a) It focuses the the library on it's core
9+
functionality and b) and it makes the library suitable for becoming
10+
a Ruby standard library, should that ever become a possibility.
11+
12+
Changes:
13+
14+
* Spun off command-line tool as `rubytest-cli`.
15+
* Spun off Rake task as `rubytest-rake`.
16+
17+
18+
## 0.6.1 / 2013-02-16
419

520
Configurations can now supply a before and after procedure to be
621
run right before or right after tests are run. This can be useful
722
for setting up coverage tools Simplecov, which has to be setup
823
before the applicable code is required but after all supporting
924
test infrustructure is required. This release also fixes
1025
the `-c/--config` option, to prevent name clashes between gems and
11-
local config files, and it is simplifed to always load locally.
26+
local config files.
1227

1328
Changes:
1429

1530
* Add before and after config procs.
1631
* Fix -c/--config loading.
1732
* Remove use of DotOpts, it is not good enough yet.
33+
* Move Rake plugin to separate plugin project.
1834

1935

2036
## 0.6.0 / 2013-02-11

bin/ruby-test

Lines changed: 0 additions & 9 deletions
This file was deleted.

bin/rubytest

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/rubytest/config.rb

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
module Test
22

3+
# Stores test configurations.
4+
def self.config
5+
@config ||= {}
6+
end
7+
38
# Configure test run via a block then will be passed a `Config` instance.
49
#
510
# @return [Config]
6-
def self.configure(&block)
11+
def self.configure(profile=nil, &block)
712
if reconfigure?
8-
configuration.apply(&block)
13+
configuration(profile).apply(profile, &block)
914
else
10-
@config = Config.new(&block)
15+
@config[profile.to_s] = Config.new(&block)
1116
end
1217
end
1318

@@ -23,9 +28,9 @@ def self.reconfigure?
2328
# Get the current configuration.
2429
#
2530
# @return [Config]
26-
def self.configuration(reconfigurable=false)
31+
def self.configuration(profile=nil, reconfigurable=false)
2732
@reconfigure = true if reconfigurable
28-
@config ||= Config.new
33+
@config[profile.to_s] ||= Config.new
2934
end
3035

3136
##
@@ -39,12 +44,6 @@ class Config
3944
# Glob used to find project root directory.
4045
GLOB_ROOT = '{.index,.gemspec,.git,.hg,_darcs,lib/}'
4146

42-
# RubyTest configuration file can be in '.test.rb`, `etc/test.rb`
43-
# or `config/test.rb`, `.test`, in that order of precedence.
44-
#
45-
# @deprecated Use manual -c/--config option instead.
46-
GLOB_CONFIG = '{.test.rb,etc/test.rb,config/test.rb,.test}'
47-
4847
#
4948
def self.assertionless
5049
@assertionless
@@ -55,28 +54,6 @@ def self.assertionless=(boolean)
5554
@assertionaless = !!boolean
5655
end
5756

58-
# Load configuration file. An example file might look like:
59-
#
60-
# Test.configure do |run|
61-
# run.files << 'test/case_*.rb'
62-
# end
63-
#
64-
# @deprecated Planned for deprecation in April 2013.
65-
def self.load_config
66-
if config_file
67-
file = config_file.sub(Dir.pwd+'/','')
68-
$stderr.puts "Automatic #{file} loading has been deprecated.\nUse -c option for future version."
69-
load config_file
70-
end
71-
end
72-
73-
# Find traditional configuration file.
74-
#
75-
# @deprecated
76-
def self.config_file
77-
@config_file ||= Dir.glob(File.join(root, GLOB_CONFIG)).first
78-
end
79-
8057
# Find and cache project root directory.
8158
#
8259
# @return [String] Project's root path.

lib/rubytest/runner.rb

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,53 @@
11
module Test
22

3-
# TODO: Support config profile's again?
4-
53
# Alias for `Test.configure`.
64
# Use #run! to run tests immediately.
75
#
8-
def self.run(config=nil, &config_proc)
9-
$stderr.puts "configuration profiles no longer supported." if config
10-
configure(&config_proc)
6+
def self.run(profile=nil, &config_proc)
7+
configure(profile, &config_proc)
118
end
129

1310
# Configure and run immediately.
1411
#
12+
# @todo Should this method return the success instead of exiting?
13+
# @todo Wrap run in at_exit ?
14+
#
15+
# @return [void]
1516
def run!(config=nil, &config_proc)
16-
Runner.run(config, &config_proc)
17+
begin
18+
success = Runner.run(config, &config_proc)
19+
exit -1 unless success
20+
rescue => error
21+
raise error if $DEBUG
22+
$stderr.puts('ERROR: ' + error.to_s)
23+
exit -1
24+
end
1725
end
1826

1927
# The Test::Runner class handles the execution of tests.
2028
#
2129
class Runner
2230

23-
# TODO: Wrap run in at_exit ?
24-
def self.run(config=nil, &config_proc)
25-
runner = Runner.new(config, &config_proc)
26-
begin
27-
success = runner.run
28-
exit -1 unless success
29-
rescue => error
30-
raise error if $DEBUG
31-
$stderr.puts('ERROR: ' + error.to_s)
32-
exit -1
31+
# Run tests.
32+
#
33+
# @param [Config,Hash,String,Symbol] config
34+
# Either a Config instance, a hash to construct a Config
35+
# instance with, or a name of a configuration profile.
36+
#
37+
# @return [Boolean] Success of test run.
38+
def self.run(config=nil) #:yield:
39+
case config
40+
when Config
41+
when Hash
42+
config = Config.new(config)
43+
else
44+
config = Test.configuration(config)
3345
end
46+
47+
yeild config if block_given?
48+
49+
runner = Runner.new(config)
50+
runner.run
3451
end
3552

3653
# Exceptions that are not caught by test runner.
@@ -90,15 +107,7 @@ def upon(type, &block)
90107
# @param [Config] config
91108
# Config instance.
92109
#
93-
def initialize(config=nil, &block)
94-
if config
95-
@config = Hash === config ? Config.new(config) : config
96-
else
97-
@config = Test.configuration
98-
end
99-
100-
block.call(@config) if block
101-
110+
def initialize(config)
102111
@advice = Advice.new
103112
end
104113

@@ -123,15 +132,17 @@ def run
123132

124133
ignore_callers
125134

126-
config.loadpath.each{ |path| $LOAD_PATH.unshift(path) }
127-
config.requires.each{ |file| require file }
135+
config.loadpath.flatten.each{ |path| $LOAD_PATH.unshift(path) }
136+
config.requires.flatten.each{ |file| require file }
137+
138+
# Config before advice occurs after loadpath and require are
139+
# applied and before test files are required.
140+
config.before.call if config.before
128141

129142
test_files.each do |test_file|
130143
require test_file
131144
end
132145

133-
config.before.call if config.before
134-
135146
@reporter = reporter_load(format)
136147
@recorder = Recorder.new
137148

var/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.6.1
1+
0.7.0

0 commit comments

Comments
 (0)