dohtest 0.1.26 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dc0d7a060ca99f77aabbef3a6645158ff6fec34
4
- data.tar.gz: c02538b1f17eacd94dae243d6578f0b1c03da526
3
+ metadata.gz: d1fdf2db3fe1625dbaa12e7c08465abd3494b5d4
4
+ data.tar.gz: 10ea4118de3da5152355c6c7e930dc8db16e7271
5
5
  SHA512:
6
- metadata.gz: 0cb9fede3798ca92734113ef176dc8e6307baf256c271dd0cd6286a5350fdd9ab4999218ee52fd2f20cdac353688334d718b276dd751f2aaa14423ffc94e96ee
7
- data.tar.gz: 11c02cee2a502f5962c2444d0ffb902e3aa5ccd7d9c1dd7f4b02598f19ddb2c5e4904ee12e280fbf49d20ff892f98f184e9c1d1d3cd2c7c492b020fcdcc3800c
6
+ metadata.gz: 48ab77e357128d6635947f09611543d4b7eb22ee48d044e8860d7994293ab52d8207c22d583d14e95ae815e6cdcb0974e04c548d792db014280f65e62f8b6814
7
+ data.tar.gz: bd7949258961d19fab200e89efeed2b44721d7307ec040cd52eead405aa43bec98013cd15bdb2f3e2b34bc60d54e149db6ff5dcaf67519d5215bacd1f4c90594
data/bin/dohtest CHANGED
@@ -14,9 +14,9 @@ opts = Doh::Options.new({
14
14
  #generates ruby warnings -- equivalent to ruby -v
15
15
  $VERBOSE = true unless opts.quiet
16
16
 
17
- paths = (if opts.varargs.empty? then ['.'] else opts.varargs end)
17
+ paths = opts.varargs
18
18
 
19
- DohTest.configure(paths[0])
19
+ DohTest.configure(paths.first)
20
20
  DohTest.config[:grep] = opts.grep if opts.grep
21
21
  DohTest.config[:glob] = opts.glob if opts.glob
22
22
  DohTest.config[:seed] = opts.seed.to_i if opts.seed
@@ -1,38 +1,58 @@
1
- require 'dohroot'
2
-
3
1
  module DohTest
2
+ extend self
4
3
 
5
- def self.config
4
+ def config
6
5
  @config ||= {}
7
6
  end
8
7
 
9
- def self.load_configuration_files(start_path)
10
- start_path = File.expand_path(start_path)
8
+ def find_root(start_directory, max_tries = 20)
9
+ curr_directory = start_directory
10
+ max_tries.times do
11
+ return nil if curr_directory == '/'
12
+ if File.directory?(File.join(curr_directory, 'test'))
13
+ return curr_directory
14
+ end
15
+ curr_directory = File.expand_path(File.join(curr_directory, '..'))
16
+ end
17
+ nil
18
+ end
19
+
20
+ def load_configuration_files(start_path)
21
+ start_path = File.expand_path(start_path || '.')
11
22
  if File.directory?(start_path)
12
23
  start_directory = start_path
13
24
  else
14
25
  start_directory = File.dirname(start_path)
15
26
  end
16
- root_directory = Doh.find_root(start_directory)
27
+ root_directory = find_root(start_directory)
28
+ raise "unable to determine root directory to run tests from" unless root_directory
29
+ DohTest.config[:root] = root_directory
17
30
 
18
- local_filename = Doh.findup(start_directory, 'configure_dohtest.rb')
19
- if local_filename && File.exist?(local_filename)
20
- require(local_filename)
31
+ libdir = File.join(root_directory, 'lib')
32
+ if File.directory?(libdir) && !$LOAD_PATH.include?(libdir)
33
+ $LOAD_PATH << libdir
34
+ end
35
+
36
+ cfgfile = File.join(root_directory, 'dohtest.rb')
37
+ if File.exist?(cfgfile)
38
+ require(cfgfile)
21
39
  return
22
40
  end
23
41
 
24
- if root_directory
25
- root_filename = File.join(root_directory, 'config', 'dohtest.rb')
26
- require(root_filename) if File.exist?(root_filename)
42
+ cfgfile = File.join(root_directory, 'config', 'dohtest.rb')
43
+ if File.exist?(cfgfile)
44
+ require(cfgfile)
45
+ return
27
46
  end
47
+
28
48
  end
29
49
 
30
- def self.add_default_config_values
50
+ def add_default_config_values
31
51
  DohTest.config[:glob] ||= '*.dt.rb'
32
52
  DohTest.config[:seed] ||= (Time.new.to_f * 1000).to_i
33
53
  end
34
54
 
35
- def self.configure(start_path)
55
+ def configure(start_path)
36
56
  load_configuration_files(start_path)
37
57
  add_default_config_values
38
58
  end
@@ -11,7 +11,14 @@ class MasterRunner
11
11
  def run
12
12
  start_time = Time.now
13
13
  @config[:pre_test_callback].call(@output) if @config[:pre_test_callback]
14
- DohTest::require_paths(@config[:glob], @paths)
14
+ if @paths.empty?
15
+ unless DohTest.require_paths(@config[:glob], ['.'])
16
+ DohTest.require_paths(@config[:glob], [@config[:root]])
17
+ end
18
+ else
19
+ DohTest.require_paths(@config[:glob], @paths)
20
+ end
21
+
15
22
  srand(@config[:seed])
16
23
  @output.run_begin(@config)
17
24
  total_problems = 0
@@ -1,13 +1,19 @@
1
1
  module DohTest
2
+ extend self
2
3
 
3
- def self.require_paths(glob, paths)
4
+ def require_paths(glob, paths)
5
+ retval = false
4
6
  paths.collect {|elem| File.expand_path(elem) }.each do |onepath|
5
7
  if File.directory?(onepath)
6
- Dir.glob(File.join(onepath, '**', glob)).each {|filename| require(filename)}
8
+ Dir.glob(File.join(onepath, '**', glob)).each do |filename|
9
+ retval = true
10
+ require(filename)
11
+ end
7
12
  else
8
13
  require(File.expand_path(onepath))
9
14
  end
10
15
  end
16
+ retval
11
17
  end
12
18
 
13
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dohtest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.26
4
+ version: 0.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makani Mason
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-26 00:00:00.000000000 Z
12
+ date: 2013-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dohroot
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 2.0.2
88
+ rubygems_version: 2.1.8
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: minimalist unit test framework