cutest 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/CHANGELOG.md +7 -0
- data/bin/cutest +3 -2
- data/cutest.gemspec +2 -0
- data/lib/cutest.rb +9 -6
- data/test/assert_raise.rb +9 -0
- data/test/fixtures/only_run_given_scope_name.rb +15 -0
- data/test/fixtures/outside_block.rb +5 -0
- data/test/run.rb +24 -0
- metadata +23 -8
- data/lib/cutest/vendor/clap.rb +0 -46
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
NDU3ZjczMzczOGVjMGYxN2YzMDA0NjVmNWNlMWFlMWQ0OGZkMjM2OGM3N2Mz
|
10
|
-
ZTMzOTc0OWFlZWZkZmEwOTg5YTdhZTMyYjhjZDhmN2NmNDUwOGM0N2Y2MjJi
|
11
|
-
YWY3ZTVlMTQyMDgzYWRkMDBlNjAxMjljMjU5YWExNTRlNWI1ZDI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YTY4NDQxMmJiYTg2Y2QyOTc3MGQ3MGNiMWRkN2JkYzc0NTNmMWIwM2E2ZWY2
|
14
|
-
ZjhiZDhjZTJlYTk4MTRkOWZkNTdkY2E4NmZkOTI1ZGQ4NjE0NTdhNmY3ZmMy
|
15
|
-
ZTA0MzlhYjAyYmQxZDdlYWYwYTZjN2MzYTIwMGZlYzRiM2JhYzQ=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9bc022132fb8435fd081485e6649717148b2907f
|
4
|
+
data.tar.gz: 51720cbf6e686d549bcb0db4b93aa427be3d1acc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 030a88a3567dba1ac8d88e74c4121c921bc64ea1a0f9086764bc479ddd65ed7157dfe9026ca9bac7465546e57392866e3a1e8c9ec81f1d7c05f73425fb3bbc6c
|
7
|
+
data.tar.gz: 355faf07ae61e2bac11b81943ce3953d4ac8a59eb0a043e4695f1afb7475ef0fa2f0c6c5f4708b517ca03a7e222f2aa4cac0ed64e24952d443971d590c265337
|
data/CHANGELOG.md
CHANGED
data/bin/cutest
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
if ARGV.empty?
|
4
|
-
puts "usage: cutest [-r lib] [-
|
4
|
+
puts "usage: cutest [-v] [-r lib] [-o test] [-s scope] file ..."
|
5
5
|
exit
|
6
6
|
end
|
7
7
|
|
8
8
|
require_relative "../lib/cutest"
|
9
|
-
|
9
|
+
require "clap"
|
10
10
|
|
11
11
|
files = Clap.run ARGV,
|
12
12
|
"-r" => lambda { |file| require file },
|
13
13
|
"-o" => lambda { |name| cutest[:only] = name },
|
14
|
+
"-s" => lambda { |name| cutest[:scope] = name },
|
14
15
|
"-v" => lambda { puts Cutest::VERSION }
|
15
16
|
|
16
17
|
if files.any?
|
data/cutest.gemspec
CHANGED
data/lib/cutest.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Cutest
|
2
2
|
unless defined?(VERSION)
|
3
|
-
VERSION = "1.2.
|
3
|
+
VERSION = "1.2.2"
|
4
4
|
FILTER = %r[/(ruby|jruby|rbx)[-/]([0-9\.])+]
|
5
5
|
CACHE = Hash.new { |h, k| h[k] = File.readlines(k) }
|
6
6
|
end
|
@@ -9,9 +9,7 @@ class Cutest
|
|
9
9
|
status = files.all? do |file|
|
10
10
|
run_file(file)
|
11
11
|
|
12
|
-
Process.
|
13
|
-
|
14
|
-
$?.success?
|
12
|
+
Process.wait2.last.success?
|
15
13
|
end
|
16
14
|
|
17
15
|
puts
|
@@ -96,8 +94,10 @@ private
|
|
96
94
|
|
97
95
|
# Create a class where the block will be evaluated. Recommended to improve
|
98
96
|
# isolation between tests.
|
99
|
-
def scope(&block)
|
100
|
-
|
97
|
+
def scope(name = nil, &block)
|
98
|
+
if !cutest[:scope] || cutest[:scope] == name
|
99
|
+
Cutest::Scope.new(&block).call
|
100
|
+
end
|
101
101
|
end
|
102
102
|
|
103
103
|
# Prepare the environment in order to run the tests. This method can be
|
@@ -144,6 +144,8 @@ private
|
|
144
144
|
prepare.each { |blk| blk.call }
|
145
145
|
block.call(setup && setup.call)
|
146
146
|
end
|
147
|
+
|
148
|
+
cutest[:test] = nil
|
147
149
|
end
|
148
150
|
|
149
151
|
# Assert that value is not nil or false.
|
@@ -163,6 +165,7 @@ private
|
|
163
165
|
begin
|
164
166
|
yield
|
165
167
|
rescue => exception
|
168
|
+
exception
|
166
169
|
ensure
|
167
170
|
flunk("got #{exception.inspect} instead") unless exception.kind_of?(expected)
|
168
171
|
success
|
data/test/assert_raise.rb
CHANGED
data/test/run.rb
CHANGED
@@ -64,3 +64,27 @@ test "output of failure in nested file" do
|
|
64
64
|
|
65
65
|
assert_equal(expected, out)
|
66
66
|
end
|
67
|
+
|
68
|
+
test "output of failure outside block" do
|
69
|
+
expected = ".\n" +
|
70
|
+
" test: \n" +
|
71
|
+
" line: assert false\n" +
|
72
|
+
" file: test/fixtures/outside_block.rb +5\n\n" +
|
73
|
+
"Cutest::AssertionFailed: expression returned false\n\n"
|
74
|
+
|
75
|
+
out = %x{./bin/cutest test/fixtures/outside_block.rb}
|
76
|
+
|
77
|
+
assert_equal(expected, out)
|
78
|
+
end
|
79
|
+
|
80
|
+
test "only runs given scope name" do
|
81
|
+
out = %x{./bin/cutest test/fixtures/only_run_given_scope_name.rb -s scope}
|
82
|
+
|
83
|
+
assert out =~ /This is raised/
|
84
|
+
end
|
85
|
+
|
86
|
+
test "runs by given scope and test names" do
|
87
|
+
%x{./bin/cutest test/fixtures/only_run_given_scope_name.rb -s scope -o test}
|
88
|
+
|
89
|
+
assert_equal 0, $?.to_i
|
90
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cutest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damian Janowski
|
@@ -10,8 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
dependencies:
|
13
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: clap
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
15
29
|
description: Run tests in separate processes to avoid shared state.
|
16
30
|
email:
|
17
31
|
- djanowski@dimaion.com
|
@@ -22,7 +36,7 @@ executables:
|
|
22
36
|
extensions: []
|
23
37
|
extra_rdoc_files: []
|
24
38
|
files:
|
25
|
-
- .gitignore
|
39
|
+
- ".gitignore"
|
26
40
|
- CHANGELOG.md
|
27
41
|
- LICENSE
|
28
42
|
- README.markdown
|
@@ -30,7 +44,6 @@ files:
|
|
30
44
|
- bin/cutest
|
31
45
|
- cutest.gemspec
|
32
46
|
- lib/cutest.rb
|
33
|
-
- lib/cutest/vendor/clap.rb
|
34
47
|
- test/assert.rb
|
35
48
|
- test/assert_equal.rb
|
36
49
|
- test/assert_raise.rb
|
@@ -38,6 +51,8 @@ files:
|
|
38
51
|
- test/fixtures/fail_custom_assertion.rb
|
39
52
|
- test/fixtures/failure.rb
|
40
53
|
- test/fixtures/failure_in_loaded_file.rb
|
54
|
+
- test/fixtures/only_run_given_scope_name.rb
|
55
|
+
- test/fixtures/outside_block.rb
|
41
56
|
- test/fixtures/success.rb
|
42
57
|
- test/prepare.rb
|
43
58
|
- test/run.rb
|
@@ -53,17 +68,17 @@ require_paths:
|
|
53
68
|
- lib
|
54
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
70
|
requirements:
|
56
|
-
- -
|
71
|
+
- - ">="
|
57
72
|
- !ruby/object:Gem::Version
|
58
73
|
version: '0'
|
59
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
75
|
requirements:
|
61
|
-
- -
|
76
|
+
- - ">="
|
62
77
|
- !ruby/object:Gem::Version
|
63
78
|
version: '0'
|
64
79
|
requirements: []
|
65
80
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.
|
81
|
+
rubygems_version: 2.2.2
|
67
82
|
signing_key:
|
68
83
|
specification_version: 4
|
69
84
|
summary: Forking tests.
|
data/lib/cutest/vendor/clap.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
class Clap
|
2
|
-
attr :argv
|
3
|
-
attr :opts
|
4
|
-
|
5
|
-
def self.run(args, opts)
|
6
|
-
new(args, opts).run
|
7
|
-
end
|
8
|
-
|
9
|
-
def initialize(argv, opts)
|
10
|
-
@argv = argv.dup
|
11
|
-
@opts = opts
|
12
|
-
end
|
13
|
-
|
14
|
-
def run
|
15
|
-
args = []
|
16
|
-
|
17
|
-
while argv.any?
|
18
|
-
|
19
|
-
item = argv.shift
|
20
|
-
flag = opts[item]
|
21
|
-
|
22
|
-
if flag
|
23
|
-
|
24
|
-
# Work around lambda semantics in 1.8.7.
|
25
|
-
arity = [flag.arity, 0].max
|
26
|
-
|
27
|
-
# Raise if there are not enough parameters
|
28
|
-
# available for the flag.
|
29
|
-
if argv.size < arity
|
30
|
-
raise ArgumentError
|
31
|
-
end
|
32
|
-
|
33
|
-
# Call the lambda with N items from argv,
|
34
|
-
# where N is the lambda's arity.
|
35
|
-
flag.call(*argv.shift(arity))
|
36
|
-
else
|
37
|
-
|
38
|
-
# Collect the items that don't correspond to
|
39
|
-
# flags.
|
40
|
-
args << item
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
args
|
45
|
-
end
|
46
|
-
end
|