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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7a023ab9f3e7c4335513ad7f7dd4e735e8749877001f5793f8fa98edf990b63
4
- data.tar.gz: bac97d266bbbf1e438bc94001f59bca09d78900841bc55c42afe1a49ce34d00c
3
+ metadata.gz: 062dd6b24c634d7d006e3334d37fc630b026e6d119f1a4841c7265184ee9ad4d
4
+ data.tar.gz: 13f84c1d50a68251389502e41b1e10b637a6fc3fe6b5761aff21a9154b885233
5
5
  SHA512:
6
- metadata.gz: 63a7c1700c036a2b0ad6ca4b8e4dc90887cd0e80c02745a0130fa2c46632d072e5bef50f6e60d6d8609eef2247ebfa2f043e2082d88c9cbbfeae89d2aca23d29
7
- data.tar.gz: 6d8dc8731abe2fa44282bce323f713e8c60e939002ed2f0431bd86fc2e904c1046c43a2a6b36d312a6b91f0ba741b8b39e69affa5fef0882206cb386dcba86db
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(ARGV, filter)
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
- require_relative '../lib/sus/progress'
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
- filter = Sus::Filter.new
27
- output = Sus::Output.default
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
- prepare(ARGV, filter)
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
@@ -35,6 +35,8 @@ module Sus
35
35
  @styles[:indent] = @indent
36
36
  end
37
37
 
38
+ attr :io
39
+
38
40
  INDENTATION = "\t"
39
41
 
40
42
  def indent
data/lib/sus/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sus
4
- VERSION = "0.6.2"
4
+ VERSION = "0.7.0"
5
5
  end
data/lib/sus.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'sus/version'
4
+ require_relative 'sus/config'
4
5
  require_relative 'sus/registry'
5
6
  require_relative 'sus/assertions'
6
7
 
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.6.2
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-06 00:00:00.000000000 Z
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.1.6
74
+ rubygems_version: 3.3.7
74
75
  signing_key:
75
76
  specification_version: 4
76
77
  summary: A fast and scalable test runner.