cutest 1.1.0.rc1 → 1.1.0.rc2
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.
- data/bin/cutest +1 -1
- data/cutest.gemspec +1 -1
- data/lib/cutest.rb +51 -10
- data/test/run.rb +8 -3
- metadata +3 -3
data/bin/cutest
CHANGED
data/cutest.gemspec
CHANGED
data/lib/cutest.rb
CHANGED
@@ -1,6 +1,30 @@
|
|
1
1
|
class Cutest
|
2
|
-
VERSION = "1.1.0.
|
2
|
+
VERSION = "1.1.0.rc2"
|
3
3
|
REQUIREMENTS = []
|
4
|
+
FILTER = %r[/#{RUBY_ENGINE}[-/]([0-9\.])+]
|
5
|
+
CACHE = Hash.new { |h, k| h[k] = File.readlines(k) }
|
6
|
+
|
7
|
+
module Color
|
8
|
+
def self.title(str)
|
9
|
+
"\033[01;36m#{str}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.exception(str)
|
13
|
+
"\033[1;33m#{str}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.code(str)
|
17
|
+
"\033[00m#{str}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.location(str)
|
21
|
+
"\033[01;30m#{str}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.reset
|
25
|
+
"\033[00m"
|
26
|
+
end
|
27
|
+
end
|
4
28
|
|
5
29
|
def self.flags
|
6
30
|
"-r #{REQUIREMENTS.join(" ")}" if REQUIREMENTS.any?
|
@@ -9,6 +33,8 @@ class Cutest
|
|
9
33
|
def self.run(files)
|
10
34
|
files.each do |file|
|
11
35
|
%x{cutest #{flags} #{file}}.chomp.display
|
36
|
+
|
37
|
+
break unless $?.success?
|
12
38
|
end
|
13
39
|
|
14
40
|
puts
|
@@ -21,20 +47,35 @@ class Cutest
|
|
21
47
|
load(file)
|
22
48
|
|
23
49
|
rescue LoadError, SyntaxError
|
24
|
-
|
25
|
-
exit
|
50
|
+
display_error
|
51
|
+
exit 1
|
26
52
|
|
27
53
|
rescue Exception
|
28
|
-
|
29
|
-
|
30
|
-
|
54
|
+
display_error
|
55
|
+
|
56
|
+
trace = $!.backtrace
|
57
|
+
pivot = trace.index { |line| line.match(file) }
|
58
|
+
other = trace[0..pivot].select { |line| line !~ FILTER }
|
59
|
+
other.reverse.each { |trace| display_trace(trace) }
|
60
|
+
exit 1
|
31
61
|
end
|
62
|
+
end
|
32
63
|
|
33
|
-
|
64
|
+
def self.code(fn, ln)
|
65
|
+
CACHE[fn][ln.to_i - 1].strip
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.display_error
|
69
|
+
print Color.title("\n\n#{$!.class}: ")
|
70
|
+
print Color.exception("#{$!.message}\n\n")
|
34
71
|
end
|
35
72
|
|
36
|
-
def self.
|
37
|
-
"
|
73
|
+
def self.display_trace(line)
|
74
|
+
fn, ln = line.split(":")
|
75
|
+
|
76
|
+
print Color.code("- #{code(fn, ln)}")
|
77
|
+
print Color.location(" #{fn} +#{ln}\n")
|
78
|
+
print Color.reset
|
38
79
|
end
|
39
80
|
|
40
81
|
class AssertionFailed < StandardError
|
@@ -115,7 +156,7 @@ private
|
|
115
156
|
|
116
157
|
# Assert that value is not nil or false.
|
117
158
|
def assert(value)
|
118
|
-
flunk("
|
159
|
+
flunk("expression returned #{value.inspect}") unless value
|
119
160
|
success
|
120
161
|
end
|
121
162
|
|
data/test/run.rb
CHANGED
@@ -21,7 +21,9 @@ test "output of successful run" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
test "output of failed run" do
|
24
|
-
expected = "\
|
24
|
+
expected = "\e[01;36m\n\nCutest::AssertionFailed: \e[1;33mexpression retur" +
|
25
|
+
"ned false\n\n\e[00m- assert false\e[01;30m test/fixtures/failu" +
|
26
|
+
"re.rb +2\n\e[00m\n"
|
25
27
|
|
26
28
|
stdout, stderr = capture do
|
27
29
|
Cutest.run(Dir["test/fixtures/failure.rb"])
|
@@ -31,7 +33,8 @@ test "output of failed run" do
|
|
31
33
|
end
|
32
34
|
|
33
35
|
test "output of failed run" do
|
34
|
-
expected = "\
|
36
|
+
expected = "\e[01;36m\n\nRuntimeError: \e[1;33mOops\n\n\e[00m- raise \"Oop" +
|
37
|
+
"s\"\e[01;30m test/fixtures/exception.rb +2\n\e[00m\n"
|
35
38
|
|
36
39
|
stdout, stderr = capture do
|
37
40
|
Cutest.run(Dir["test/fixtures/exception.rb"])
|
@@ -41,7 +44,9 @@ test "output of failed run" do
|
|
41
44
|
end
|
42
45
|
|
43
46
|
test "output of custom assertion" do
|
44
|
-
expected = "\
|
47
|
+
expected = "\e[01;36m\n\nCutest::AssertionFailed: \e[1;33mnot empty\n\n\e[" +
|
48
|
+
"00m- assert_empty \"foo\"\e[01;30m test/fixtures/fail_custom_a" +
|
49
|
+
"ssertion.rb +7\n\e[00m\n"
|
45
50
|
|
46
51
|
stdout, stderr = capture do
|
47
52
|
Cutest.run(Dir["test/fixtures/fail_custom_assertion.rb"])
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cutest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 1.1.0.
|
5
|
+
version: 1.1.0.rc2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Damian Janowski
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-
|
14
|
+
date: 2011-05-07 00:00:00 Z
|
15
15
|
dependencies: []
|
16
16
|
|
17
17
|
description: Run tests in separate processes to avoid shared state.
|
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
requirements: []
|
62
62
|
|
63
63
|
rubyforge_project:
|
64
|
-
rubygems_version: 1.
|
64
|
+
rubygems_version: 1.8.1
|
65
65
|
signing_key:
|
66
66
|
specification_version: 3
|
67
67
|
summary: Forking tests.
|