test_bench 1.1.0.0 → 1.2.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d18b019b73d853e50b78abd989c8d8969c65eb7c5beedc0f3eeadb415f652aa
4
- data.tar.gz: e8a421026be5f2cf1c5f2af81ddd6a763ab0095669bbda97998fee4ca6fafb83
3
+ metadata.gz: 82b5c7ea30694c73b4fea06fd84b04a91c39ddb2e4c1f3c5d61bf7cbcf19968a
4
+ data.tar.gz: e3e762b1ed21103f6b63cdc1c9b3c974803e2ae82e60a8f110dcf7b3ba6a5aff
5
5
  SHA512:
6
- metadata.gz: bc855a5819e98378bae988487b7d8e55c5143ca157f6f116c1411e2bbf087771a6bf992650049d07cb3b1a8a0666ad56ef4ef05686a88536264884700851de77
7
- data.tar.gz: 15a6baea7cbbf7f8cfcccaa17c3bb128fe396be9ffb227087335f4edc5a569d95cdbe066359f9af80907f3fa298e8299af8be0d402fb6e08c3c125222fe69a23
6
+ metadata.gz: be92980ba27d4c0132a96a2d31df200e3c442e0de320ee0b66e482b8793ca0868992a833a58b25fd0d6db384eadf9a2f21fee4d3e4308890736881ad3b08b1ec
7
+ data.tar.gz: 4687fc714ea34ddb8510359827016a8107b1ca1fd2659ed140237fa9a4abc73a3c2eafa96f5aeeaa4f1f6b4ea6a877d7e17fde63e74ba1db05e83a0e02eec66d
@@ -1,4 +1,6 @@
1
- require 'optionparser'
1
+ unless RUBY_ENGINE == 'mruby'
2
+ require 'optionparser'
3
+ end
2
4
 
3
5
  require 'test_bench/fixture'
4
6
 
@@ -8,7 +8,7 @@ module TestBench
8
8
  read_stdin = $stdin.stat.pipe?
9
9
 
10
10
  if read_stdin && $stdin.eof?
11
- warn "$stdin is a pipe, but no data was written to it; no test files will be run"
11
+ STDERR.puts "$stdin is a pipe, but no data was written to it; no test files will be run"
12
12
  end
13
13
 
14
14
  Run.(exclude: exclude_file_pattern) do |run|
@@ -48,21 +48,21 @@ module TestBench
48
48
  parser.on('-h', '--help', "Print this help message and exit successfully") do
49
49
  output_device.puts(parser.help)
50
50
 
51
- exit(true)
51
+ raise SystemExit.new(0)
52
52
  end
53
53
 
54
54
  parser.on('-V', '--version', "Print version and exit successfully") do
55
- output_device.puts <<~TEXT
56
- test-bench (#{self.class.program_name}) version #{self.class.version}
57
- TEXT
55
+ output_device.puts <<TEXT
56
+ test-bench (#{self.class.program_name}) version #{self.class.version}
57
+ TEXT
58
58
 
59
- exit(true)
59
+ raise SystemExit.new(0)
60
60
  end
61
61
 
62
62
  parser.separator('')
63
63
  parser.separator("Configuration Options")
64
64
 
65
- parser.on('-a', '--[no-]abort-on-error', %{Exit immediately after any test failure or error (Default: #{Session::Defaults.abort_on_error ? 'on' : 'off'})}) do |abort_on_error|
65
+ parser.on('-a', '--[no-]abort-on-error', %{Exit immediately after any test failure or error (Default: #{TestBench::Defaults.abort_on_error ? 'on' : 'off'})}) do |abort_on_error|
66
66
  env['TEST_BENCH_ABORT_ON_ERROR'] = abort_on_error ? 'on' : 'off'
67
67
  end
68
68
 
@@ -116,7 +116,7 @@ module TestBench
116
116
  env['TEST_BENCH_OUTPUT_STYLING'] = styling_text
117
117
  end
118
118
 
119
- parser.on('-p', '--[no-]permit-deactivated-tests', %{Do not fail the test run if there are deactivated tests or contexts, e.g. _test or _context (Default: #{!DeactivationVariants::Defaults.fail_session ? 'on' : 'off'})}) do |permit_deactivated_tests|
119
+ parser.on('-p', '--[no-]permit-deactivated-tests', %{Do not fail the test run if there are deactivated tests or contexts, e.g. _test or _context (Default: #{!TestBench::Defaults.fail_deactivated_tests ? 'on' : 'off'})}) do |permit_deactivated_tests|
120
120
  env['TEST_BENCH_FAIL_DEACTIVATED_TESTS'] = !permit_deactivated_tests ? 'on' : 'off'
121
121
  end
122
122
 
@@ -128,29 +128,29 @@ module TestBench
128
128
  env['TEST_BENCH_VERBOSE'] = verbose ? 'on' : 'off'
129
129
  end
130
130
 
131
- parser.separator(<<~TEXT)
131
+ parser.separator(<<TEXT)
132
132
 
133
- Paths to test files (and directories containing test files) can be given after any command line arguments or via STDIN (or both).
134
- If no paths are given, a default path (#{Defaults.tests_directory}) is scanned for test files.
133
+ Paths to test files (and directories containing test files) can be given after any command line arguments or via STDIN (or both).
134
+ If no paths are given, a default path (#{Defaults.tests_directory}) is scanned for test files.
135
135
 
136
- The following environment variables can also control execution:
136
+ The following environment variables can also control execution:
137
137
 
138
- #{parser.summary_indent}TEST_BENCH_ABORT_ON_ERROR Same as -a or --abort-on-error
139
- #{parser.summary_indent}TEST_BENCH_DETAIL Same as -d or --detail
140
- #{parser.summary_indent}TEST_BENCH_EXCLUDE_FILE_PATTERN Same as -x or --exclude-file-pattern
141
- #{parser.summary_indent}TEST_BENCH_LOG_LEVEL Same as -l or --log-level
142
- #{parser.summary_indent}TEST_BENCH_OMIT_BACKTRACE_PATTERN Same as -o or --omit-backtrace-pattern
143
- #{parser.summary_indent}TEST_BENCH_OUTPUT_STYLING Same as -s or --output-styling
144
- #{parser.summary_indent}TEST_BENCH_FAIL_DEACTIVATED_TESTS Opposite of -p or --permit-deactivated-tests
145
- #{parser.summary_indent}TEST_BENCH_REVERSE_BACKTRACES Same as -r or --reverse-backtraces
146
- #{parser.summary_indent}TEST_BENCH_VERBOSE Same as -v or --reverse-backtraces
138
+ #{parser.summary_indent}TEST_BENCH_ABORT_ON_ERROR Same as -a or --abort-on-error
139
+ #{parser.summary_indent}TEST_BENCH_DETAIL Same as -d or --detail
140
+ #{parser.summary_indent}TEST_BENCH_EXCLUDE_FILE_PATTERN Same as -x or --exclude-file-pattern
141
+ #{parser.summary_indent}TEST_BENCH_LOG_LEVEL Same as -l or --log-level
142
+ #{parser.summary_indent}TEST_BENCH_OMIT_BACKTRACE_PATTERN Same as -o or --omit-backtrace-pattern
143
+ #{parser.summary_indent}TEST_BENCH_OUTPUT_STYLING Same as -s or --output-styling
144
+ #{parser.summary_indent}TEST_BENCH_FAIL_DEACTIVATED_TESTS Opposite of -p or --permit-deactivated-tests
145
+ #{parser.summary_indent}TEST_BENCH_REVERSE_BACKTRACES Same as -r or --reverse-backtraces
146
+ #{parser.summary_indent}TEST_BENCH_VERBOSE Same as -v or --reverse-backtraces
147
147
 
148
- TEXT
148
+ TEXT
149
149
  end
150
150
  end
151
151
 
152
152
  def assure_pattern(pattern_text)
153
- Regexp.new(pattern_text)
153
+ Regexp.new(pattern_text.to_s)
154
154
  rescue RegexpError
155
155
  raise Error, "Invalid regular expression pattern (Pattern: #{pattern_text.inspect})"
156
156
  end
@@ -164,7 +164,7 @@ module TestBench
164
164
  end
165
165
 
166
166
  def self.version
167
- if defined?(Gem)
167
+ if Object.const_defined?(:Gem)
168
168
  spec = Gem.loaded_specs['test_bench']
169
169
  end
170
170
 
@@ -1,4 +1,6 @@
1
- require 'securerandom'
1
+ unless RUBY_ENGINE == 'mruby'
2
+ require 'securerandom'
3
+ end
2
4
 
3
5
  require 'test_bench/fixture/controls'
4
6
 
@@ -11,11 +11,11 @@ module TestBench
11
11
 
12
12
  error = Error.example(message)
13
13
 
14
- <<~TEXT
15
- #{indent}#{error.backtrace[0]}: #{error.message} (#{error.class.name})
16
- \t#{indent}from #{error.backtrace[1]}
17
- \t#{indent}from #{error.backtrace[2]}
18
- TEXT
14
+ <<TEXT
15
+ #{indent}#{error.backtrace[0]}: #{error.message} (#{error.class.name})
16
+ \t#{indent}from #{error.backtrace[1]}
17
+ \t#{indent}from #{error.backtrace[2]}
18
+ TEXT
19
19
  end
20
20
 
21
21
  module Assertion
@@ -24,9 +24,9 @@ module TestBench
24
24
 
25
25
  assertion_failure = TestBench::Fixture::AssertionFailure.build(caller_location)
26
26
 
27
- <<~TEXT
28
- #{assertion_failure.backtrace[0]}: #{assertion_failure.message} (#{assertion_failure.class.name})
29
- TEXT
27
+ <<TEXT
28
+ #{assertion_failure.backtrace[0]}: #{assertion_failure.message} (#{assertion_failure.class.name})
29
+ TEXT
30
30
  end
31
31
  end
32
32
  end
@@ -3,7 +3,12 @@ module TestBench
3
3
  module Output
4
4
  module NewlineCharacter
5
5
  def self.example
6
- StringIO.new.tap(&:puts).string
6
+ str = String.new
7
+
8
+ string_io = StringIO.new(str)
9
+ string_io.puts('')
10
+
11
+ str
7
12
  end
8
13
  end
9
14
  end
@@ -5,12 +5,12 @@ module TestBench
5
5
  module Error
6
6
  module Text
7
7
  def self.example
8
- <<~TEXT
9
- Error Summary:
10
- 1: #{file}
11
- #{error.backtrace[0]}: #{error} (#{error.class})
8
+ <<TEXT
9
+ Error Summary:
10
+ 1: #{file}
11
+ #{error.backtrace[0]}: #{error} (#{error.class})
12
12
 
13
- TEXT
13
+ TEXT
14
14
  end
15
15
 
16
16
  def self.file
@@ -5,12 +5,12 @@ module TestBench
5
5
  module Session
6
6
  module Text
7
7
  def self.example
8
- <<~TEXT
9
- Finished running 0 files
10
- Ran 0 tests in 0.000s (0.0 tests/second)
11
- 0 passed, 0 skipped, 0 failed, 0 total errors
8
+ <<TEXT
9
+ Finished running 0 files
10
+ Ran 0 tests in 0.000s (0.0 tests/second)
11
+ 0 passed, 0 skipped, 0 failed, 0 total errors
12
12
 
13
- TEXT
13
+ TEXT
14
14
  end
15
15
  end
16
16
  end
@@ -12,9 +12,19 @@ module TestBench
12
12
  minutes = self.minutes
13
13
  seconds = self.seconds + seconds_offset
14
14
 
15
- tz_offset = self.tz_offset
15
+ if not RUBY_ENGINE == 'mruby'
16
+ tz_offset = self.tz_offset
16
17
 
17
- ::Time.new(year, month, day, hours, minutes, seconds, tz_offset)
18
+ final_argument = tz_offset
19
+ else
20
+ seconds, subseconds = seconds.divmod(1)
21
+
22
+ microseconds = subseconds * 1_000_000
23
+
24
+ final_argument = microseconds
25
+ end
26
+
27
+ ::Time.new(year, month, day, hours, minutes, seconds, final_argument)
18
28
  end
19
29
 
20
30
  def self.year
@@ -1,21 +1,11 @@
1
1
  module TestBench
2
2
  module DeactivationVariants
3
3
  def _context(title=nil, &block)
4
- test_session.fail! if Defaults.fail_session
5
-
6
4
  context(title)
7
5
  end
8
6
 
9
7
  def _test(title=nil, &block)
10
- test_session.fail! if Defaults.fail_session
11
-
12
8
  test(title)
13
9
  end
14
-
15
- module Defaults
16
- def self.fail_session
17
- Environment::Boolean.fetch('TEST_BENCH_FAIL_DEACTIVATED_TESTS', true)
18
- end
19
- end
20
10
  end
21
11
  end
@@ -1,3 +1,5 @@
1
- require 'ostruct'
1
+ unless RUBY_ENGINE == 'mruby'
2
+ require 'ostruct'
3
+ end
2
4
 
3
5
  require 'test_bench/fixtures/configure_receiver'
@@ -41,7 +41,9 @@ module TestBench
41
41
  end
42
42
 
43
43
  def new_record(signal, data)
44
- record = Record.new(signal, data)
44
+ record = super
45
+
46
+ record.extend(Record)
45
47
 
46
48
  case signal
47
49
  when :enter_context, :start_test, :start_fixture
@@ -87,7 +89,7 @@ module TestBench
87
89
  stack.length
88
90
  end
89
91
 
90
- class Record < Fixture::Output::Capture::Record
92
+ module Record
91
93
  attr_accessor :batch_data
92
94
 
93
95
  def forward(raw_output)
@@ -8,7 +8,7 @@ module TestBench
8
8
 
9
9
  class Timer < Timer
10
10
  def elapsed_time
11
- @elapsed_time ||= 0
11
+ @elapsed_time ||= 0.0
12
12
  end
13
13
  attr_writer :elapsed_time
14
14
 
@@ -106,7 +106,7 @@ module TestBench
106
106
 
107
107
  def newline
108
108
  sync
109
- device.puts
109
+ device.puts('')
110
110
  self.byte_offset += 1
111
111
  self
112
112
  end
@@ -3,7 +3,7 @@ module TestBench
3
3
  Error = Class.new(RuntimeError)
4
4
 
5
5
  def session
6
- @session ||= Session::Substitute.build
6
+ @session ||= Fixture::Session::Substitute.build
7
7
  end
8
8
  attr_writer :session
9
9
 
@@ -25,7 +25,7 @@ module TestBench
25
25
 
26
26
  instance.exclude_pattern = exclude unless exclude.nil?
27
27
 
28
- Session.configure(instance, session: session)
28
+ Fixture::Session.configure(instance, session: session)
29
29
  instance.session.output = output unless output.nil?
30
30
 
31
31
  instance
@@ -79,7 +79,7 @@ module TestBench
79
79
  def directory(path)
80
80
  glob_pattern = File.join(path, '**/*.rb')
81
81
 
82
- Dir[glob_pattern].sort.each do |path|
82
+ Dir.glob(glob_pattern).sort.each do |path|
83
83
  next if exclude_pattern.match?(path)
84
84
 
85
85
  file(path)
@@ -2,7 +2,9 @@ module TestBench
2
2
  def self.session
3
3
  @session ||= build_session.tap do |session|
4
4
  at_exit do
5
- exit 1 if session.failed?
5
+ exit_code = exit_code(session)
6
+
7
+ exit(exit_code) unless exit_code.zero?
6
8
  end
7
9
  end
8
10
  end
@@ -65,7 +67,7 @@ module TestBench
65
67
  end
66
68
 
67
69
  def self.session_error_policy(abort_on_error=nil)
68
- abort_on_error = Session::Defaults.abort_on_error if abort_on_error.nil?
70
+ abort_on_error = Defaults.abort_on_error if abort_on_error.nil?
69
71
 
70
72
  if abort_on_error
71
73
  :abort
@@ -74,11 +76,29 @@ module TestBench
74
76
  end
75
77
  end
76
78
 
79
+ def self.exit_code(session, fail_deactivated_tests: nil)
80
+ if fail_deactivated_tests.nil?
81
+ fail_deactivated_tests = Defaults.fail_deactivated_tests
82
+ end
83
+
84
+ if session.failed?
85
+ 1
86
+ elsif session.skip?
87
+ fail_deactivated_tests ? 2 : 0
88
+ else
89
+ 0
90
+ end
91
+ end
92
+
77
93
  Session = Fixture::Session
78
94
 
79
- module Session::Defaults
95
+ module Defaults
80
96
  def self.abort_on_error
81
97
  Environment::Boolean.fetch('TEST_BENCH_ABORT_ON_ERROR', false)
82
98
  end
99
+
100
+ def self.fail_deactivated_tests
101
+ Environment::Boolean.fetch('TEST_BENCH_FAIL_DEACTIVATED_TESTS', true)
102
+ end
83
103
  end
84
104
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_bench
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.0
4
+ version: 1.2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Ladd
8
8
  autorequire:
9
9
  bindir: script
10
10
  cert_chain: []
11
- date: 2020-07-23 00:00:00.000000000 Z
11
+ date: 2020-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test_bench-fixture
@@ -72,8 +72,6 @@ files:
72
72
  - lib/test_bench/controls/time.rb
73
73
  - lib/test_bench/deactivation_variants.rb
74
74
  - lib/test_bench/environment/boolean.rb
75
- - lib/test_bench/fixture
76
- - lib/test_bench/fixture.rb
77
75
  - lib/test_bench/fixtures.rb
78
76
  - lib/test_bench/fixtures/configure_receiver.rb
79
77
  - lib/test_bench/output.rb
@@ -113,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
111
  - !ruby/object:Gem::Version
114
112
  version: '0'
115
113
  requirements: []
116
- rubygems_version: 3.1.3
114
+ rubygems_version: 3.1.4
117
115
  signing_key:
118
116
  specification_version: 4
119
- summary: Principled Test Framework for Ruby
117
+ summary: Principled Test Framework for Ruby and MRuby
120
118
  test_files: []
@@ -1 +0,0 @@
1
- lib/test_bench/home/ntl/Projects/test-bench-fixture/lib/test_bench/fixture
@@ -1 +0,0 @@
1
- lib/test_bench/home/ntl/Projects/test-bench-fixture/lib/test_bench/fixture.rb