minitest-silence 0.1.0 → 0.2.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: f6db18145fa32f96ca4c2f3ca5fe7099949b0603ee5fdff92981564f1b18e606
4
- data.tar.gz: 456dcf9fe20ddc6302d1c1a611958c65752d3177f31184ab467a9ff53d9946ff
3
+ metadata.gz: cbcaf249c787322e61fb0b08a3836b5aa3c2650fc7ae3df47a029bbfe55c500e
4
+ data.tar.gz: dc346dfae4ea921cd818daa92f1cec2589ddf85f6fea1a6c0c58997e19b012cd
5
5
  SHA512:
6
- metadata.gz: fa01057df17eb458c34fa559e5b108583cc614b669d85657eb22d254e5ad6b171257f0a39291eb87bb93a93723a8624fbdc8804571fd4c2bd38ab14824be050f
7
- data.tar.gz: 6f318bca2ebe5dab21ab5f07ad32ace16b9d02838d25d96d72c8ce843096b1166b03ca79a1f5aa2ccc71944c6f42d7cda6af1a33e3dcacdf6c81433230fa4c55
6
+ metadata.gz: 2c194b97d1130cf0261cf519b563acdcc4f8a91233a40f41817f4dab73260408d31ebe1e0fe076eac2754523862522877d51600f0a55e2bf484fb2c050a612ab
7
+ data.tar.gz: b65df74f1913124c1f71d19855c09ebadf5398a3e20f4910b4eea7b638eff9f895012d669627def451f5391aaf4c1458683b604e9295f42ae603ce694440cdfa
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .byebug_history
10
+ Gemfile.lock
data/Gemfile CHANGED
@@ -7,3 +7,4 @@ gemspec
7
7
  gem "rake", "~> 12.0"
8
8
  gem "minitest", "~> 5.0"
9
9
  gem "rubocop-shopify"
10
+ gem "byebug"
@@ -1,31 +1,35 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minitest-silence (0.1.0)
4
+ minitest-silence (0.2.0)
5
5
  minitest (~> 5.12)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.0)
11
- jaro_winkler (1.5.4)
10
+ ast (2.4.1)
11
+ byebug (11.1.3)
12
12
  minitest (5.14.1)
13
13
  parallel (1.19.1)
14
14
  parser (2.7.1.3)
15
15
  ast (~> 2.4.0)
16
16
  rainbow (3.0.0)
17
17
  rake (12.3.3)
18
+ regexp_parser (1.7.1)
18
19
  rexml (3.2.4)
19
- rubocop (0.82.0)
20
- jaro_winkler (~> 1.5.1)
20
+ rubocop (0.85.1)
21
21
  parallel (~> 1.10)
22
22
  parser (>= 2.7.0.1)
23
23
  rainbow (>= 2.2.2, < 4.0)
24
+ regexp_parser (>= 1.7)
24
25
  rexml
26
+ rubocop-ast (>= 0.0.3)
25
27
  ruby-progressbar (~> 1.7)
26
28
  unicode-display_width (>= 1.4.0, < 2.0)
27
- rubocop-shopify (1.0.2)
28
- rubocop (~> 0.82.0)
29
+ rubocop-ast (0.0.3)
30
+ parser (>= 2.7.0.1)
31
+ rubocop-shopify (1.0.3)
32
+ rubocop (~> 0.85.0)
29
33
  ruby-progressbar (1.10.1)
30
34
  unicode-display_width (1.7.0)
31
35
 
@@ -33,6 +37,7 @@ PLATFORMS
33
37
  ruby
34
38
 
35
39
  DEPENDENCIES
40
+ byebug
36
41
  minitest (~> 5.0)
37
42
  minitest-silence!
38
43
  rake (~> 12.0)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Minitest
3
3
  module Silence
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
@@ -15,20 +15,29 @@ module Minitest
15
15
  end
16
16
 
17
17
  module RunOneMethodPatch
18
+ attr_reader :original_stdin, :original_stdout, :original_stderr
19
+
20
+ def __run(*)
21
+ @original_stdin = $stdin.dup
22
+ @original_stdout = $stdout.dup
23
+ @original_stderr = $stderr.dup
24
+ super
25
+ end
26
+
18
27
  def run_one_method(klass, method_name)
19
28
  output_reader, output_writer = IO.pipe
20
29
  output_thread = Thread.new { output_reader.read }
21
30
 
22
- old_stdout = $stdout.dup
23
- old_stderr = $stderr.dup
24
-
25
31
  result = begin
26
32
  $stdout.reopen(output_writer)
27
33
  $stderr.reopen(output_writer)
34
+ $stdin.reopen(File::NULL)
35
+
28
36
  super
29
37
  ensure
30
- $stdout.reopen(old_stdout)
31
- $stderr.reopen(old_stderr)
38
+ $stdout.reopen(original_stdout)
39
+ $stderr.reopen(original_stderr)
40
+ $stdin.reopen(original_stdin)
32
41
  output_writer.close
33
42
  end
34
43
 
@@ -48,21 +57,26 @@ module Minitest
48
57
 
49
58
  class << self
50
59
  def plugin_silence_options(opts, options)
60
+ opts.on('--disable-silence', "Do not rebind standard IO") do
61
+ options[:disable_silence] = true
62
+ end
51
63
  opts.on('--fail-on-output', "Fail a test when it writes to STDOUT or STDERR") do
52
64
  options[:fail_on_output] = true
53
65
  end
54
66
  end
55
67
 
56
68
  def plugin_silence_init(options)
57
- Minitest::Result.prepend(Minitest::Silence::ResultOutputPatch)
58
- Minitest.singleton_class.prepend(Minitest::Silence::RunOneMethodPatch)
69
+ unless options[:disable_silence]
70
+ Minitest::Result.prepend(Minitest::Silence::ResultOutputPatch)
71
+ Minitest.singleton_class.prepend(Minitest::Silence::RunOneMethodPatch)
59
72
 
60
- if options[:fail_on_output]
61
- # We have to make sure this reporter runs as the first reporter, so it can still adjust
62
- # the result and other reporters will take the change into account.
63
- reporter.reporters.unshift(Minitest::Silence::FailOnOutputReporter.new(options[:io], options))
64
- elsif options[:verbose]
65
- reporter << Minitest::Silence::BoxedOutputReporter.new(options[:io], options)
73
+ if options[:fail_on_output]
74
+ # We have to make sure this reporter runs as the first reporter, so it can still adjust
75
+ # the result and other reporters will take the change into account.
76
+ reporter.reporters.unshift(Minitest::Silence::FailOnOutputReporter.new(options[:io], options))
77
+ elsif options[:verbose]
78
+ reporter << Minitest::Silence::BoxedOutputReporter.new(options[:io], options)
79
+ end
66
80
  end
67
81
  end
68
82
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-silence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-03 00:00:00.000000000 Z
11
+ date: 2020-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest