brutal 2.0.0 → 2.0.1
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 +4 -4
- data/README.md +6 -1
- data/bin/brutal +2 -1
- data/lib/brutal/runner.rb +7 -2
- data/lib/brutal.rb +1 -1
- metadata +6 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5530092767fe983e7f798a3e49f2067cabffc1e5d9d6e032184ad31732af2898
|
|
4
|
+
data.tar.gz: 992a42551e93945da8438254aac56d1b0e19817d716221d6e84c0687f9f2fbfb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 992439db7aa3193c9db7e844ea4d1b9b2be376b84f52fc50c3210d8e21f999a3565ae39cf7a34a4359b054453397778261e71ea123ce9a3794d29ba38e23c1d0
|
|
7
|
+
data.tar.gz: 4d83bd3b31ef1f0e00e330073481f4e1e7432d9169b7f5b11f3682bd6fbd85d572fdf217a4b36fe0fe2c9e28177329b300063a280aaab3181012948b913cbb11
|
data/README.md
CHANGED
|
@@ -191,11 +191,16 @@ In CI, run `bundle exec brutal --check test` before the tests.
|
|
|
191
191
|
- The test file is plain Ruby, run by `ruby` or any test runner that loads files. It uses one local variable, `actual`, at the top level of the file; under `ruby -w`, a manifest whose actuals do not use `%{subject}` warns that `actual` is unused.
|
|
192
192
|
- A failing check raises, and stops its file. `Rake::TestTask` loads every test file in one process: the first failure stops the run, and what a test file changes (a monkey patch) reaches the files loaded after it. Brutal runs each test file alone.
|
|
193
193
|
- An `exit`, an `exit!` or a signal during the recording, or a top-level `return` that skips a check of the recording, is reported as a failure of the manifest, and nothing is written. During the recording, `at_exit` handlers do not run.
|
|
194
|
-
- There is no timeout: code that never ends keeps brutal waiting, and so does,
|
|
194
|
+
- There is no timeout: code that never ends keeps brutal waiting, and so does a process the code forked and left running, when the recording ends without a result (an `exit!`, a crash). Killed with `SIGKILL`, brutal leaves its child running, and may leave a `.test_NAME.rb.PID.tmp` file next to the test file.
|
|
195
195
|
- A magic comment that must be on the first line (`# encoding:`, `# warn_indent:`) has no effect in the header, which starts on the third line; `# frozen_string_literal:` and `# shareable_constant_value:` do. The test file is read as UTF-8.
|
|
196
196
|
- On macOS, code that uses Objective-C classes may crash in the child process: run brutal with `OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES`.
|
|
197
197
|
- A check is `::Kernel.raise … unless (expected).eql?((actual))`: code that redefines `Kernel.raise`, or `eql?` on core classes (a refinement included), ends the process from an `at_exit` handler or a `TracePoint`, or behaves differently when it finds brutal (`$__brutal__`), changes the checks. Brutal does not guard against code that sets out to defeat it.
|
|
198
198
|
|
|
199
|
+
## Changes in 2.0.1
|
|
200
|
+
|
|
201
|
+
- Interrupted right after the test file ended, brutal no longer sends `KILL` to its pid, which may already belong to another process, nor raises `Errno::ESRCH` in place of the `Interrupt`: the process is checked before any signal, as Aw does.
|
|
202
|
+
- Documentation: every combination of a manifest's contexts runs in one child process; a process the code forked and left running delays brutal only when the recording ends without a result.
|
|
203
|
+
|
|
199
204
|
## Changes in 2.0
|
|
200
205
|
|
|
201
206
|
Compared with 1.6.0.beta4:
|
data/bin/brutal
CHANGED
|
@@ -6,7 +6,8 @@ require_relative File.join("..", "lib", "brutal")
|
|
|
6
6
|
begin
|
|
7
7
|
exit Brutal::CLI.run(ARGV)
|
|
8
8
|
rescue Interrupt
|
|
9
|
-
#
|
|
9
|
+
# The child, forked by Aw for the recording or spawned to run the test
|
|
10
|
+
# file, has been ended and reaped. End by the signal, as an interrupted
|
|
10
11
|
# command does, so that a shell loop stops too, but without a backtrace.
|
|
11
12
|
Signal.trap(:INT, "SYSTEM_DEFAULT")
|
|
12
13
|
Process.kill(:INT, Process.pid)
|
data/lib/brutal/runner.rb
CHANGED
|
@@ -173,12 +173,17 @@ module Brutal
|
|
|
173
173
|
"exit status #{status.exitstatus}"
|
|
174
174
|
end
|
|
175
175
|
|
|
176
|
-
# Kills and reaps a process left running by an interruption.
|
|
176
|
+
# Kills and reaps a process left running by an interruption. The process
|
|
177
|
+
# is checked first: a wait2 interrupted right after it reaped would
|
|
178
|
+
# otherwise lead to a signal to a pid that may already belong to another
|
|
179
|
+
# process.
|
|
177
180
|
def self.reap(pid)
|
|
178
|
-
return if pid.nil?
|
|
181
|
+
return if pid.nil? || ::Process.wait2(pid, ::Process::WNOHANG)
|
|
179
182
|
|
|
180
183
|
::Process.kill(:KILL, pid)
|
|
181
184
|
::Process.wait(pid)
|
|
185
|
+
rescue ::Errno::ECHILD
|
|
186
|
+
nil
|
|
182
187
|
end
|
|
183
188
|
|
|
184
189
|
private_class_method :failure, :fork, :compile, :evaluate, :describe, :plain, :copy, :status, :reap
|
data/lib/brutal.rb
CHANGED
|
@@ -4,7 +4,7 @@ require "aw"
|
|
|
4
4
|
|
|
5
5
|
# Writes plain Ruby test files from YAML manifests. A manifest gives a
|
|
6
6
|
# subject, contexts to combine and actuals to observe; brutal runs every
|
|
7
|
-
# combination in
|
|
7
|
+
# combination in one child process, records what the code returns, and writes
|
|
8
8
|
# a test file that checks these values with `eql?`, without any framework.
|
|
9
9
|
#
|
|
10
10
|
# The test file describes what the code does, not what it should do: read
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: brutal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cyril Kato
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: aw
|
|
@@ -25,8 +24,8 @@ dependencies:
|
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '1.0'
|
|
27
26
|
description: 'Writes framework-free Ruby test files from YAML manifests: runs every
|
|
28
|
-
combination of contexts in
|
|
29
|
-
eql?.'
|
|
27
|
+
combination of a manifest''s contexts in one child process, and checks each observed
|
|
28
|
+
value with eql?.'
|
|
30
29
|
email: contact@cyril.email
|
|
31
30
|
executables:
|
|
32
31
|
- brutal
|
|
@@ -48,11 +47,10 @@ licenses:
|
|
|
48
47
|
- MIT
|
|
49
48
|
metadata:
|
|
50
49
|
bug_tracker_uri: https://github.com/fixrb/brutal/issues
|
|
51
|
-
changelog_uri: https://github.com/fixrb/brutal#changes-in-
|
|
50
|
+
changelog_uri: https://github.com/fixrb/brutal#changes-in-201
|
|
52
51
|
documentation_uri: https://rubydoc.info/gems/brutal
|
|
53
52
|
rubygems_mfa_required: 'true'
|
|
54
53
|
source_code_uri: https://github.com/fixrb/brutal
|
|
55
|
-
post_install_message:
|
|
56
54
|
rdoc_options: []
|
|
57
55
|
require_paths:
|
|
58
56
|
- lib
|
|
@@ -67,8 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
67
65
|
- !ruby/object:Gem::Version
|
|
68
66
|
version: '0'
|
|
69
67
|
requirements: []
|
|
70
|
-
rubygems_version:
|
|
71
|
-
signing_key:
|
|
68
|
+
rubygems_version: 4.0.23
|
|
72
69
|
specification_version: 4
|
|
73
70
|
summary: Plain Ruby tests, written from what the code does
|
|
74
71
|
test_files: []
|