dohtest 0.1.54 → 0.1.55

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: f671b0ee5564d932bd5cf2edd188c31292a0fee261a8ad5207e446450b93cb1e
4
- data.tar.gz: 92e6b918b818a6e1b3824cde7e08c7964999a1e8088d024ed3f7b6ee2f365a14
3
+ metadata.gz: bfbc04ce3b53966d24d062b84ba569837f0b31e4d3a2f62a6fd1dd3b034816fa
4
+ data.tar.gz: 693a91b6c27c0b262bd2313850b9cccdb67969cec40aaf2d9797cf159dd606fe
5
5
  SHA512:
6
- metadata.gz: 98d77e960acc16540bd4e52588af6cb0a98c051d3d068b4cdd49632b247bc46ce164c55cffa0927622b0f28a01d33ab66f7ee171623e798da435203adacf75a3
7
- data.tar.gz: 7a64336cbb411d9056253ba1e2c9ab8a0d99ed857ffea18751272a8ede1b38bc8838f04e2133caf53ed0ac4aa64753869a5cbcb49c08d7e354d332e00f07200b
6
+ metadata.gz: 919fdd8ddd3a2e839d83ddda295340bb335842aa610c374da1938c2e73546608432b744dbd7636af5d727f570d3ad6754d0215e1fb9aba533bab7c2c7890b8fe
7
+ data.tar.gz: 30857a2fc0ab018f01e271e59186fb518e1485fed9b72d56236128663720c8df136eea427fc14771653a4b76c6cbeac24aa2cde209b18da80f86b9c4275682bc
data/bin/dohtest_repeat CHANGED
@@ -3,3 +3,4 @@
3
3
  cmd = "dohtest #{ARGV.join(' ')}"
4
4
  while(system(cmd)) do
5
5
  end
6
+ exit($?.exitstatus || 1)
@@ -187,6 +187,10 @@ class GroupRunner
187
187
  def total_problems
188
188
  @error_count + @assertions_failed
189
189
  end
190
+
191
+ def total_assertions
192
+ return @assertions_passed + @assertions_failed
193
+ end
190
194
  end
191
195
 
192
196
  end
@@ -26,19 +26,30 @@ class MasterRunner
26
26
  end
27
27
 
28
28
  total_problems = 0
29
+ total_assertions = 0
30
+ callbacks_succeeded = true
29
31
  # sort them to be the same order no matter what (different machines were returning different results)
30
32
  TestGroup.descendants.sort{|a,b|a.to_s<=>b.to_s}.shuffle.each do |group_class|
31
33
  runner = GroupRunner.new(group_class, @output, @config)
32
34
  brink_hit = runner.run
33
35
  total_problems += runner.total_problems
36
+ total_assertions += runner.total_assertions
34
37
  break if brink_hit
35
38
  end
36
39
  @config[:post_all_callback].each do |proc|
37
40
  if !proc.call(total_problems)
41
+ callbacks_succeeded = false
38
42
  @output.callback_failed(proc.inspect)
39
43
  end
40
44
  end
41
45
  @output.run_end(Time.now - start_time)
46
+
47
+ success = (total_assertions > 0) && (total_problems == 0) && callbacks_succeeded
48
+ if success
49
+ return 0
50
+ else
51
+ return 1
52
+ end
42
53
  end
43
54
  end
44
55
 
@@ -72,9 +72,6 @@ class StreamOutput
72
72
  msg = "#{error_str}; #{group_str}; #{test_str}; #{assertion_str}"
73
73
  msg = colorize(:success, msg) if success
74
74
  @std_ios.puts msg
75
-
76
- # this is to generate an exit code; true translates to 0, false to 1
77
- success
78
75
  end
79
76
 
80
77
  def group_begin(group_name)
@@ -4,7 +4,7 @@ require 'dohtest/backtrace_parser'
4
4
 
5
5
  module DohTest
6
6
 
7
- class TestBacktraceParser < MiniTest::Test
7
+ class TestBacktraceParser < Minitest::Test
8
8
  def create_single_stack
9
9
  retval = []
10
10
  retval << "/Users/somebody/dohtest/lib/doh/test/assertions.rb:10:in `assert'"
@@ -0,0 +1,106 @@
1
+ require 'dohroot'; Doh.find_root_from_file
2
+ require 'minitest/autorun'
3
+ require 'tmpdir'
4
+
5
+ module DohTest
6
+
7
+ # runs bin/dohtest and bin/dohtest_repeat as subprocesses against generated
8
+ # fixture suites, pinning the exit-code contract: 0 only when tests ran and
9
+ # every assertion passed, 1 otherwise
10
+ class TestExitCodes < Minitest::Test
11
+ BIN_DIR = File.join(Doh.root, 'bin')
12
+ LIB_DIR = File.join(Doh.root, 'lib')
13
+
14
+ PASSING_GROUP = <<~EOT
15
+ class TestExitPass < DohTest::TestGroup
16
+ def test_pass
17
+ assert_equal(4, 2 + 2)
18
+ end
19
+ end
20
+ EOT
21
+
22
+ FAILING_GROUP = <<~EOT
23
+ class TestExitFail < DohTest::TestGroup
24
+ def test_pass
25
+ assert_equal(4, 2 + 2)
26
+ end
27
+ def test_fail
28
+ assert_equal(5, 2 + 2)
29
+ end
30
+ end
31
+ EOT
32
+
33
+ ERROR_GROUP = <<~EOT
34
+ class TestExitError < DohTest::TestGroup
35
+ def test_error
36
+ raise 'boom'
37
+ end
38
+ end
39
+ EOT
40
+
41
+ NO_ASSERTION_GROUP = <<~EOT
42
+ class TestExitNoAssertions < DohTest::TestGroup
43
+ def test_nothing
44
+ end
45
+ end
46
+ EOT
47
+
48
+ def run_dohtest(path)
49
+ system('ruby', "-I#{LIB_DIR}", File.join(BIN_DIR, 'dohtest'), '-q', path, :out => File::NULL, :err => File::NULL)
50
+ return $?.exitstatus
51
+ end
52
+
53
+ def run_dohtest_repeat(path)
54
+ env = {'PATH' => "#{BIN_DIR}:#{ENV['PATH']}", 'RUBYLIB' => LIB_DIR}
55
+ system(env, 'ruby', File.join(BIN_DIR, 'dohtest_repeat'), '-q', path, :out => File::NULL, :err => File::NULL)
56
+ return $?.exitstatus
57
+ end
58
+
59
+ def with_fixture(group_source)
60
+ Dir.mktmpdir do |dir|
61
+ File.write(File.join(dir, 'dohroot'), '')
62
+ path = File.join(dir, 'fixture.dt.rb')
63
+ File.write(path, group_source)
64
+ yield path
65
+ end
66
+ end
67
+
68
+ def test_all_assertions_passing_exits_zero
69
+ with_fixture(PASSING_GROUP) do |path|
70
+ assert_equal(0, run_dohtest(path))
71
+ end
72
+ end
73
+
74
+ def test_assertion_failure_exits_one
75
+ with_fixture(FAILING_GROUP) do |path|
76
+ assert_equal(1, run_dohtest(path))
77
+ end
78
+ end
79
+
80
+ def test_error_exits_one
81
+ with_fixture(ERROR_GROUP) do |path|
82
+ assert_equal(1, run_dohtest(path))
83
+ end
84
+ end
85
+
86
+ def test_no_assertions_exits_one
87
+ with_fixture(NO_ASSERTION_GROUP) do |path|
88
+ assert_equal(1, run_dohtest(path))
89
+ end
90
+ end
91
+
92
+ def test_no_test_files_exits_one
93
+ Dir.mktmpdir do |dir|
94
+ File.write(File.join(dir, 'dohroot'), '')
95
+ assert_equal(1, run_dohtest(dir))
96
+ end
97
+ end
98
+
99
+ def test_dohtest_repeat_propagates_failure
100
+ with_fixture(FAILING_GROUP) do |path|
101
+ assert_equal(1, run_dohtest_repeat(path))
102
+ end
103
+ end
104
+ end
105
+
106
+ end
@@ -5,7 +5,7 @@ require 'dohtest/capture_output'
5
5
 
6
6
  module DohTest
7
7
 
8
- class TestGroupRunner < MiniTest::Test
8
+ class TestGroupRunner < Minitest::Test
9
9
  def verify_event(expected_pairs, event)
10
10
  expected_pairs.each_pair do |key, value|
11
11
  assert_equal(value, event[key])
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dohtest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.54
4
+ version: 0.1.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - ATPSoft
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-07-03 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: dohroot
@@ -64,12 +63,12 @@ files:
64
63
  - lib/dohtest/stream_output.rb
65
64
  - lib/dohtest/test_group.rb
66
65
  - test/test_backtrace_parser.rb
66
+ - test/test_exit_codes.rb
67
67
  - test/test_group_runner.rb
68
68
  homepage: https://github.com/atpsoft/dohtest
69
69
  licenses:
70
70
  - MIT
71
71
  metadata: {}
72
- post_install_message:
73
72
  rdoc_options: []
74
73
  require_paths:
75
74
  - lib
@@ -84,10 +83,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
83
  - !ruby/object:Gem::Version
85
84
  version: '0'
86
85
  requirements: []
87
- rubygems_version: 3.2.11
88
- signing_key:
86
+ rubygems_version: 4.0.17
89
87
  specification_version: 4
90
88
  summary: minimalist unit test framework
91
89
  test_files:
92
90
  - test/test_backtrace_parser.rb
91
+ - test/test_exit_codes.rb
93
92
  - test/test_group_runner.rb