Skip to content

Commit c2dc459

Browse files
committed
Support some old config code temporarily.
1 parent c3418a8 commit c2dc459

5 files changed

Lines changed: 82 additions & 61 deletions

File tree

.test

Whitespace-only changes.

lib/rubytest/cli.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ def run(argv=nil)
4040

4141
config.files.replace(argv) unless argv.empty?
4242

43-
Test.run(config)
44-
45-
#runner = Runner.new(config)
46-
#begin
47-
# success = runner.run
48-
# exit -1 unless success
49-
#rescue => error
50-
# raise error if $DEBUG
51-
# $stderr.puts('ERROR: ' + error.to_s)
52-
# exit -1
53-
#end
43+
#Test.run(config)
44+
45+
runner = Runner.new(config)
46+
begin
47+
success = runner.run
48+
exit -1 unless success
49+
rescue => error
50+
raise error if $DEBUG
51+
$stderr.puts('ERROR: ' + error.to_s)
52+
exit -1
53+
end
5454
end
5555

5656
# These options are parsed prior to any other options.

lib/rubytest/config.rb

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,54 @@ def self.configuration
1515
@config ||= Config.new
1616
end
1717

18-
# Handle test run configruation.
19-
#
20-
# @todo Why not use the instace level for `Test.config` ?
18+
##
19+
# Encapsulates test run configruation.
2120
#
2221
class Config
2322

2423
# Default report is in the old "dot-progress" format.
2524
DEFAULT_FORMAT = 'dotprogress'
2625

27-
## RubyTest configuration file can be in `etc/test.rb` or `config/test.rb`,
28-
## or the hidden file `.test.rb`.
29-
#GLOB_CONFIG = '{.,task/,etc/,config/}test{.rb,}'
30-
3126
# Glob used to find project root directory.
3227
GLOB_ROOT = '{.index,.gemspec,.git,.hg,_darcs,lib/}'
3328

34-
##
35-
## Load configuration file. This will first look for a root level `Testfile.rb`
36-
## or `.test.rb` file. Failing that it will look for `task/*.test.rb` files.
37-
## An example entry into any of these look like:
38-
##
39-
## Test.run :name do |run|
40-
## run.files << 'test/case_*.rb'
41-
## end
42-
##
43-
## Use `default` for name for non-specific profile and `common` for code that
44-
## should apply to all configurations.
45-
##
46-
#def self.load_config
47-
# require config_file if config_file
48-
#end
29+
# RubyTest configuration file can be in `.test`, '.test.rb`, `etc/test.rb`
30+
# or `config/test.rb`.
31+
#
32+
# @deprecated Use manual -c/--config option instead.
33+
GLOB_CONFIG = '{.test,.test.rb,etc/test.rb,config/test.rb}'
4934

50-
## Find traditional configuration file.
51-
#def self.config_file
52-
# @config_file ||= Dir.glob(File.join(root, GLOB_CONFIG)).first
53-
#end
35+
#
36+
def self.assertionless
37+
@assertionless
38+
end
39+
40+
#
41+
def self.assertionless=(boolean)
42+
@assertionaless = !!boolean
43+
end
44+
45+
# Load configuration file. An example file might look like:
46+
#
47+
# Test.configure do |run|
48+
# run.files << 'test/case_*.rb'
49+
# end
50+
#
51+
# @deprecated Planned for deprecation in April 2013.
52+
def self.load_config
53+
if config_file
54+
file = config_file.sub(Dir.pwd+'/','')
55+
$stderr.puts "Automatic #{file} loading has been deprecated. Use -c option for future version."
56+
load config_file
57+
end
58+
end
59+
60+
# Find traditional configuration file.
61+
#
62+
# @deprecated
63+
def self.config_file
64+
@config_file ||= Dir.glob(File.join(root, GLOB_CONFIG)).first
65+
end
5466

5567
# Find and cache project root directory.
5668
#
@@ -83,10 +95,14 @@ def self.dotindex
8395
)
8496
end
8597

98+
# Require a configuration file.
8699
#
87100
# TODO: Should config files be require relative to project root
88101
# or relatvie to current working directory?
89102
#
103+
# TODO: Use load instead of require?
104+
#
105+
# @return nothing.
90106
def self.require_config(file)
91107
#if File.exist?(file)
92108
# require file
@@ -114,12 +130,13 @@ def self.load_path_setup
114130
end
115131
end
116132

117-
#
133+
# Initialize new Config instance.
118134
def initialize(&block)
135+
self.class.load_config
119136
apply(&block)
120137
end
121138

122-
#
139+
# Evaluate configuration block.
123140
def apply(&block)
124141
block.call(self) if block
125142
end
@@ -142,17 +159,17 @@ def format
142159
@format || ENV['RUBYTEST_FORMAT'] || DEFAULT_FORMAT
143160
end
144161

145-
#
162+
# Set test report format.
146163
def format=(format)
147164
@format = format
148165
end
149166

150-
#
167+
# Provide extra details in reports?
151168
def verbose
152169
@verbose
153170
end
154171

155-
#
172+
# Set verbose mode.
156173
def verbose=(boolean)
157174
@verbose = !!boolean
158175
end
@@ -174,7 +191,7 @@ def units
174191

175192
# Hard is a synonym for assertionless.
176193
def hard
177-
@hard || Runner.assertionless
194+
@hard || self.class.assertionless
178195
end
179196

180197
# Hard is a synonym for assertionless.

lib/rubytest/rake.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'rake/tasklib'
22

3-
module Ruth
3+
module Test
44

55
#
66
module Rake
@@ -91,9 +91,8 @@ def run
9191
end
9292

9393
# Resolve test globs.
94-
#--
95-
# TODO: simplify?
96-
#++
94+
#
95+
# TODO: Can this code be simplifed?
9796
def test_files
9897
files = tests
9998
files = files.map{ |f| Dir[f] }.flatten

lib/rubytest/runner.rb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
module Test
22

3-
# TODO: Wrap run in at_exit ?
3+
# Currently this is an alias for configure, however it is likely
4+
# to become an alias for `Runner.run` in the future.
5+
#
6+
# @deprecated Will probably change behavior in future.
47
def self.run(config=nil, &config_proc)
5-
runner = Runner.new(config, &config_proc)
6-
begin
7-
success = runner.run
8-
exit -1 unless success
9-
rescue => error
10-
raise error if $DEBUG
11-
$stderr.puts('ERROR: ' + error.to_s)
12-
exit -1
13-
end
8+
$stderr.puts "configuration profiles no longer supported." if config
9+
configure(&config_proc)
1410
end
1511

1612
# The Test::Runner class handles the execution of tests.
1713
#
1814
class Runner
1915

16+
# TODO: Wrap run in at_exit ?
17+
def self.run(config=nil, &config_proc)
18+
runner = Runner.new(config, &config_proc)
19+
begin
20+
success = runner.run
21+
exit -1 unless success
22+
rescue => error
23+
raise error if $DEBUG
24+
$stderr.puts('ERROR: ' + error.to_s)
25+
exit -1
26+
end
27+
end
28+
2029
# Default report is in the old "dot-progress" format.
2130
DEFAULT_FORMAT = 'dotprogress'
2231

2332
# Exceptions that are not caught by test runner.
2433
OPEN_ERRORS = [NoMemoryError, SignalException, Interrupt, SystemExit]
2534

26-
class << self
27-
attr_accessor :assertionless
28-
end
29-
3035
# / / / A T T R I B U T E S / / /
3136

3237
# Test suite to run. This is a list of compliant test units and test cases.

0 commit comments

Comments
 (0)