sus 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sus +6 -28
- data/bin/sus-parallel +13 -36
- data/lib/sus/config.rb +92 -0
- data/lib/sus/output/text.rb +2 -0
- data/lib/sus/version.rb +1 -1
- data/lib/sus.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 062dd6b24c634d7d006e3334d37fc630b026e6d119f1a4841c7265184ee9ad4d
|
4
|
+
data.tar.gz: 13f84c1d50a68251389502e41b1e10b637a6fc3fe6b5761aff21a9154b885233
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c27b28f9e80a52244ca3fba25d48e9f87264bf1033898b0aa20d4cfb59565fe7d847c110159d34f2efc51a6082f30134606d6de2520806c8ff29bccba54250a4
|
7
|
+
data.tar.gz: fa80a6275e3a08853bf0366eb93b6fc3ae733481d14122669840aabc7081544e738e1bb4c86e777ec018851677b6c2b6b1ea5965f592e18232f34c583bf19abc
|
data/bin/sus
CHANGED
@@ -1,40 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require_relative '../lib/sus'
|
4
|
-
|
5
|
-
if File.exist?("config/test.rb")
|
6
|
-
load("config/test.rb")
|
7
|
-
end
|
8
|
-
|
9
|
-
def prepare(paths, registry)
|
10
|
-
if paths&.any?
|
11
|
-
paths.each do |path|
|
12
|
-
registry.load(path)
|
13
|
-
end
|
14
|
-
else
|
15
|
-
Dir.glob("test/**/*.rb").each do |path|
|
16
|
-
registry.load(path)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
3
|
+
require_relative '../lib/sus/config'
|
4
|
+
config = Sus::Config.load
|
20
5
|
|
6
|
+
require_relative '../lib/sus'
|
21
7
|
filter = Sus::Filter.new
|
22
|
-
output = Sus::Output.default
|
23
8
|
assertions = Sus::Assertions.default(output: Sus::Output::Null.new)
|
24
9
|
|
25
|
-
prepare(
|
10
|
+
config.prepare(filter)
|
26
11
|
|
12
|
+
config.before_tests(assertions)
|
27
13
|
filter.call(assertions)
|
28
|
-
|
29
|
-
assertions.print(output)
|
30
|
-
output.puts
|
14
|
+
config.after_tests(assertions)
|
31
15
|
|
32
16
|
if assertions.failed.any?
|
33
|
-
output.puts
|
34
|
-
|
35
|
-
assertions.failed.each do |failure|
|
36
|
-
failure.output.append(output)
|
37
|
-
end
|
38
|
-
|
39
17
|
exit(1)
|
40
18
|
end
|
data/bin/sus-parallel
CHANGED
@@ -1,39 +1,23 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require_relative '../lib/sus'
|
4
|
-
|
5
|
-
|
6
|
-
if File.exist?("config/test.rb")
|
7
|
-
load("config/test.rb")
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'etc'
|
11
|
-
|
12
|
-
def prepare(paths, registry)
|
13
|
-
if paths&.any?
|
14
|
-
paths.each do |path|
|
15
|
-
registry.load(path)
|
16
|
-
end
|
17
|
-
else
|
18
|
-
Dir.glob("test/**/*.rb").each do |path|
|
19
|
-
registry.load(path)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
3
|
+
require_relative '../lib/sus/config'
|
4
|
+
config = Sus::Config.load
|
23
5
|
|
24
6
|
Result = Struct.new(:job, :assertions)
|
25
7
|
|
26
|
-
|
27
|
-
|
28
|
-
|
8
|
+
require_relative '../lib/sus'
|
9
|
+
require_relative '../lib/sus/progress'
|
29
10
|
jobs = Thread::Queue.new
|
30
11
|
results = Thread::Queue.new
|
31
12
|
guard = Thread::Mutex.new
|
32
|
-
progress = Sus::Progress.new(output)
|
13
|
+
progress = Sus::Progress.new(config.output)
|
14
|
+
|
15
|
+
require 'etc'
|
33
16
|
count = Etc.nprocessors
|
34
17
|
|
35
18
|
loader = Thread.new do
|
36
|
-
|
19
|
+
filter = Sus::Filter.new
|
20
|
+
config.prepare(filter)
|
37
21
|
|
38
22
|
filter.each do |child|
|
39
23
|
guard.synchronize{progress.expand}
|
@@ -43,9 +27,10 @@ loader = Thread.new do
|
|
43
27
|
jobs.close
|
44
28
|
end
|
45
29
|
|
30
|
+
top = Sus::Assertions.new(output: Sus::Output::Null.new)
|
31
|
+
config.before_tests(top)
|
32
|
+
|
46
33
|
aggregation = Thread.new do
|
47
|
-
top = Sus::Assertions.new(output: Sus::Output::Null.new)
|
48
|
-
|
49
34
|
while result = results.pop
|
50
35
|
guard.synchronize{progress.increment}
|
51
36
|
|
@@ -79,16 +64,8 @@ workers.each(&:join)
|
|
79
64
|
results.close
|
80
65
|
|
81
66
|
assertions = aggregation.value
|
82
|
-
|
83
|
-
assertions.print(output)
|
84
|
-
output.puts
|
67
|
+
config.after_tests(assertions)
|
85
68
|
|
86
69
|
if assertions.failed.any?
|
87
|
-
output.puts
|
88
|
-
|
89
|
-
assertions.failed.each do |failure|
|
90
|
-
failure.output.append(output)
|
91
|
-
end
|
92
|
-
|
93
70
|
exit(1)
|
94
71
|
end
|
data/lib/sus/config.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2022, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
module Sus
|
24
|
+
class Config
|
25
|
+
PATH = "config/sus.rb"
|
26
|
+
|
27
|
+
def self.path(root)
|
28
|
+
path = ::File.join(root, PATH)
|
29
|
+
|
30
|
+
if ::File.exist?(path)
|
31
|
+
return path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.load(root: Dir.pwd, argv: ARGV)
|
36
|
+
derived = Class.new(self)
|
37
|
+
|
38
|
+
if path = self.path(root)
|
39
|
+
config = Module.new
|
40
|
+
config.module_eval(::File.read(path), path)
|
41
|
+
derived.prepend(config)
|
42
|
+
end
|
43
|
+
|
44
|
+
return derived.new(root, argv)
|
45
|
+
end
|
46
|
+
|
47
|
+
def initialize(root, paths)
|
48
|
+
@root = root
|
49
|
+
@paths = paths
|
50
|
+
end
|
51
|
+
|
52
|
+
def output
|
53
|
+
@output ||= Sus::Output.default
|
54
|
+
end
|
55
|
+
|
56
|
+
DEFAULT_TEST_PATTERN = "test/**/*.rb"
|
57
|
+
|
58
|
+
def test_paths
|
59
|
+
return Dir.glob(DEFAULT_TEST_PATTERN, base: @root)
|
60
|
+
end
|
61
|
+
|
62
|
+
def prepare(registry)
|
63
|
+
if @paths&.any?
|
64
|
+
@paths.each do |path|
|
65
|
+
registry.load(path)
|
66
|
+
end
|
67
|
+
else
|
68
|
+
test_paths.each do |path|
|
69
|
+
registry.load(path)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def before_tests(assertions)
|
75
|
+
end
|
76
|
+
|
77
|
+
def after_tests(assertions)
|
78
|
+
output = self.output
|
79
|
+
|
80
|
+
assertions.print(output)
|
81
|
+
output.puts
|
82
|
+
|
83
|
+
if assertions.failed.any?
|
84
|
+
output.puts
|
85
|
+
|
86
|
+
assertions.failed.each do |failure|
|
87
|
+
failure.output.append(output)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/sus/output/text.rb
CHANGED
data/lib/sus/version.rb
CHANGED
data/lib/sus.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01
|
11
|
+
date: 2022-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -25,6 +25,7 @@ files:
|
|
25
25
|
- lib/sus/base.rb
|
26
26
|
- lib/sus/be.rb
|
27
27
|
- lib/sus/be_within.rb
|
28
|
+
- lib/sus/config.rb
|
28
29
|
- lib/sus/context.rb
|
29
30
|
- lib/sus/describe.rb
|
30
31
|
- lib/sus/expect.rb
|
@@ -70,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
71
|
- !ruby/object:Gem::Version
|
71
72
|
version: '0'
|
72
73
|
requirements: []
|
73
|
-
rubygems_version: 3.
|
74
|
+
rubygems_version: 3.3.7
|
74
75
|
signing_key:
|
75
76
|
specification_version: 4
|
76
77
|
summary: A fast and scalable test runner.
|