forking_test_runner 1.17.0 → 1.18.0

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: 0d794c30f5c802d8bc7ac54e9f904df97920f75731f9df22f141e74a09bcf138
4
- data.tar.gz: 5b80cdb62e641794f436babb17619c0ad680f93ed50878c38066b1e4d5104655
3
+ metadata.gz: a248306cb1a71ac76fe62cff26f468f3aa8ae39f701f6c2d6ab8ed43bc2c0491
4
+ data.tar.gz: a4683438d4fa23251d609568fec91e147c77325548d6d0c616e5034c6bc26efe
5
5
  SHA512:
6
- metadata.gz: ecc5203c6a7c9249c83008b799fa773b7f53c40ceed7a88cb7e4bf49316d08a40b8535ee9e926521e230ef2d8cfa9b8c7317bdd473b6aff70188109f10ada905
7
- data.tar.gz: 7f6832e31114fb564aa6af927dd091f1caf8c7cb09b87410db06d6a9f63779e38630f75fb21a8dd3b54eb5f65137aa347c5948b4c0157ef399effab44a0ee8ed
6
+ metadata.gz: a63845433bc9bef04de653f116dc20377ad1c16d7014e81f2bc16b32e02b68f6bab9b46cb9de0ea6740d86c74021381c5f457deb6fc6c212e3555f6b095948c2
7
+ data.tar.gz: b80c1bcb90d560d74af870dff0b44bffee28bc1a60c0a1ee0607d96361c4b00e8fb210d96734482495aabc003fe1a7ef01464e6f1838730dfed317add6871188
@@ -18,7 +18,7 @@ module ForkingTestRunner
18
18
  String
19
19
  ],
20
20
  [:runtime_log, "--runtime-log FILE", "File to store runtime log in or runtime.log", String],
21
- [:parallel, "--parallel NUM", "Number of parallel groups to run at once", Integer],
21
+ [:parallel, "--parallel [NUM]", "Number of parallel groups to run at once", Integer],
22
22
  [:group, "--group NUM[,NUM]", "What group this is (use with --groups / starts at 1)", String],
23
23
  [:groups, "--groups NUM", "How many groups there are in total (use with --group)", Integer],
24
24
  [:version, "--version", "Show version"],
@@ -28,9 +28,13 @@ module ForkingTestRunner
28
28
  class << self
29
29
  def parse_options(argv)
30
30
  options = OPTIONS.each_with_object({}) do |(setting, flag, _, type), all|
31
- all[setting] = delete_argv(flag.split(' ', 2)[0], argv, type: type)
31
+ optional = flag.include?("[")
32
+ all[setting] = delete_argv(flag.split(' ', 2)[0], argv, type: type, optional: optional)
32
33
  end
33
34
 
35
+ # default parallel to processor count
36
+ options[:parallel] = Parallel.processor_count if options[:parallel] == true
37
+
34
38
  # show version
35
39
  if options.fetch(:version)
36
40
  puts VERSION
@@ -76,12 +80,19 @@ module ForkingTestRunner
76
80
  # so minitest / rspec can read their own options (--seed / -v ...)
77
81
  # - keep our options clear / unambiguous to avoid overriding
78
82
  # - read all serial non-flag arguments as tests and leave only unknown options behind
79
- def delete_argv(name, argv, type: nil)
83
+ def delete_argv(name, argv, type: nil, optional: false)
80
84
  if type # value needed
81
85
  value =
82
86
  if (index = argv.index(name)) # user used `--foo bar` style ?
83
87
  argv.delete_at(index)
84
- argv.delete_at(index) || raise(ArgumentError, "Missing argument for #{name}")
88
+ next_arg = argv[index]
89
+ if next_arg && !next_arg.start_with?("-")
90
+ argv.delete_at(index)
91
+ elsif optional
92
+ return true
93
+ else
94
+ raise(ArgumentError, "Missing argument for #{name}")
95
+ end
85
96
  else # user used `--foo=bar` style ?
86
97
  prefix = "#{name}="
87
98
  return unless (index = argv.index { |arg| arg.start_with?(prefix) })
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ForkingTestRunner
3
- VERSION = "1.17.0"
3
+ VERSION = "1.18.0"
4
4
  end
@@ -66,8 +66,8 @@ module ForkingTestRunner
66
66
  puts "\nResults:"
67
67
  puts(
68
68
  results
69
- .sort_by { |_, _, _, r, _| r ? 0 : 1 } # failures should be last so they are easy to find
70
- .map { |f, _, _, r, _| "#{f}: #{r ? "OK" : "Fail"}" }
69
+ .sort_by { |_, _, _, r, _| r ? 0 : 1 } # failures should be last so they are easy to find
70
+ .map { |f, _, _, r, _| "#{f}: #{r ? "OK" : "Fail"}" }
71
71
  )
72
72
  puts
73
73
  end
@@ -82,7 +82,7 @@ module ForkingTestRunner
82
82
  puts "Time: #{diff.round(2)} diff to expected"
83
83
  end
84
84
 
85
- if mode = @options.fetch(:record_runtime)
85
+ if (mode = @options.fetch(:record_runtime))
86
86
  # store runtime log
87
87
  log = runtime_log || 'runtime.log'
88
88
  record_test_runtime(mode, results, log)
@@ -162,7 +162,7 @@ module ForkingTestRunner
162
162
  when 'simple'
163
163
  File.write(log, data)
164
164
  when 'amend'
165
- if id = ENV["BUILDKITE_JOB_ID"]
165
+ if (id = ENV["BUILDKITE_JOB_ID"])
166
166
  slug = "#{ENV.fetch("BUILDKITE_ORG_SLUG")}-#{ENV.fetch("BUILDKITE_PIPELINE_SLUG")}"
167
167
  else
168
168
  slug = ENV.fetch("TRAVIS_REPO_SLUG").sub("/", "-")
@@ -278,10 +278,11 @@ module ForkingTestRunner
278
278
  wpipe.close
279
279
 
280
280
  buffer = +""
281
+ tee = !@options.fetch(:quiet) && !@options.fetch(:parallel)
281
282
 
282
- while ch = rpipe.read(1)
283
+ while (ch = rpipe.read(tee ? 1 : 4096))
283
284
  buffer << ch
284
- $stdout.write(ch) if !@options.fetch(:quiet) && !@options.fetch(:parallel) # tee
285
+ $stdout.write(ch) if tee
285
286
  end
286
287
 
287
288
  Process.wait(child)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forking_test_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.0
4
+ version: 1.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -200,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
200
  requirements:
201
201
  - - ">="
202
202
  - !ruby/object:Gem::Version
203
- version: 3.2.0
203
+ version: 3.3.0
204
204
  required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - ">="