cutest 1.0.1 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/bin/cutest +6 -2
  2. data/cutest.gemspec +1 -1
  3. data/lib/cutest.rb +21 -30
  4. data/test/run.rb +1 -1
  5. metadata +6 -8
data/bin/cutest CHANGED
@@ -63,7 +63,11 @@ class Cutest
63
63
  end
64
64
 
65
65
  files = Cutest::Clap.run ARGV,
66
- "-r" => lambda { |file| require file },
66
+ "-r" => lambda { |file| Cutest::REQUIREMENTS.push(file) },
67
67
  "-v" => lambda { puts Cutest::VERSION }
68
68
 
69
- Cutest.run(Dir[*files]) if files.any?
69
+ case files.size
70
+ when 0 then exit
71
+ when 1 then Cutest.run_file(files.first)
72
+ else Cutest.run(Dir[*files])
73
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cutest"
3
- s.version = "1.0.1"
3
+ s.version = "1.1.0.rc1"
4
4
  s.summary = "Forking tests."
5
5
  s.description = "Run tests in separate processes to avoid shared state."
6
6
  s.authors = ["Damian Janowski", "Michel Martens"]
@@ -1,42 +1,33 @@
1
1
  class Cutest
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0.rc1"
3
+ REQUIREMENTS = []
4
+
5
+ def self.flags
6
+ "-r #{REQUIREMENTS.join(" ")}" if REQUIREMENTS.any?
7
+ end
3
8
 
4
9
  def self.run(files)
5
10
  files.each do |file|
6
- stdin, stdout = IO.pipe
7
-
8
- fork do
9
- stdin.close
10
-
11
- begin
12
- load(file)
13
-
14
- rescue LoadError, SyntaxError
15
- puts ["\n", error([file, $!.message])]
16
- exit
17
-
18
- rescue Exception
19
- fn, ln = $!.backtrace.first.split(":")
20
- message = File.readlines(fn)[ln.to_i - 1]
21
- stdout.write("#{fn}\n#{ln}\n#{error(message.strip)} # #{$!.message}")
22
- end
23
-
24
- stdout.close
25
- end
26
-
27
- stdout.close
11
+ %x{cutest #{flags} #{file}}.chomp.display
12
+ end
28
13
 
29
- Process.wait
14
+ puts
15
+ end
30
16
 
31
- output = stdin.read
17
+ def self.run_file(file)
18
+ begin
19
+ REQUIREMENTS.each { |r| require r }
32
20
 
33
- stdin.close
21
+ load(file)
34
22
 
35
- unless output.empty?
36
- fn, ln, error = output.split("\n")
23
+ rescue LoadError, SyntaxError
24
+ puts ["\n", error([file, $!.message])]
25
+ exit
37
26
 
38
- puts "\n#{error}\n#{fn} +#{ln}"
39
- end
27
+ rescue Exception
28
+ fn, ln = $!.backtrace.first.split(":")
29
+ message = File.readlines(fn)[ln.to_i - 1]
30
+ puts "\n#{error(message.strip)} # #{$!.message}\n#{fn} +#{ln}"
40
31
  end
41
32
 
42
33
  puts
@@ -11,7 +11,7 @@ ensure
11
11
  end
12
12
 
13
13
  test "output of successful run" do
14
- expected = "\n"
14
+ expected = ".\n"
15
15
 
16
16
  stdout, stderr = capture do
17
17
  Cutest.run(Dir["test/fixtures/success.rb"])
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cutest
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.0.1
4
+ prerelease: 6
5
+ version: 1.1.0.rc1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Damian Janowski
@@ -11,8 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-02-14 00:00:00 -03:00
15
- default_executable:
14
+ date: 2011-04-22 00:00:00 Z
16
15
  dependencies: []
17
16
 
18
17
  description: Run tests in separate processes to avoid shared state.
@@ -39,7 +38,6 @@ files:
39
38
  - test/scopes.rb
40
39
  - test/setup.rb
41
40
  - bin/cutest
42
- has_rdoc: true
43
41
  homepage: http://github.com/djanowski/cutest
44
42
  licenses: []
45
43
 
@@ -57,13 +55,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
55
  required_rubygems_version: !ruby/object:Gem::Requirement
58
56
  none: false
59
57
  requirements:
60
- - - ">="
58
+ - - ">"
61
59
  - !ruby/object:Gem::Version
62
- version: "0"
60
+ version: 1.3.1
63
61
  requirements: []
64
62
 
65
63
  rubyforge_project:
66
- rubygems_version: 1.5.2
64
+ rubygems_version: 1.7.2
67
65
  signing_key:
68
66
  specification_version: 3
69
67
  summary: Forking tests.