semaphore_test_boosters 2.2.3 → 2.6.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
  SHA1:
3
- metadata.gz: e9b81adbced4c33522f4e33249abdec12d731839
4
- data.tar.gz: 6854ab8456f245a05cc349043d99c54ca8b2ee82
3
+ metadata.gz: 502cd665598a91e82706246e1f4ce9ec49f74d42
4
+ data.tar.gz: d30decefa24819ecaf7b9e81496bb9f67fb5255a
5
5
  SHA512:
6
- metadata.gz: 1702c760ab390cc4483c8d68b9b7f63cb54aac1a5859ae816ec74aa5496812c96c77f6f779a1fdd1389e54f87eb19be685ae18f0910cdb022d3545d4d44c28a1
7
- data.tar.gz: 44ff6f24265265b3a58a57c8219897172245848a4356e54eafd63860efc1c2a6dd1b296a2715949c30dcbfb7fbd0d2414aa0a496b9ecb173457ba5879aeb31b6
6
+ metadata.gz: 8d5625893720c3d00920a712ae5ea306cb179043c52c692fdb2d19dc4d69646fff8243e7a84f2e0acb7ef3648f617a6c72fddd7b3d2e69fb034805cfdb8b4944
7
+ data.tar.gz: 6e57270af8ed571fd2350ea023e7bffd13aa5fa75109014e987080c949865d18afa6889a740c3b833f852516af7d6097962a8ffa1585e1405e0a14ec160afa80
data/README.md CHANGED
@@ -122,16 +122,16 @@ bundle exec rspec --format documentation --format json --out /home/<user>/rspec_
122
122
  ```
123
123
 
124
124
  Optionally, you can pass additional RSpec flags with the `TB_RSPEC_OPTIONS`
125
- environment variable:
125
+ environment variable. You can also set a RSpec formatter with the `TB_RSPEC_FORMATTER` environment variable.
126
+ Default formatter is `documentation`.
126
127
 
127
- ``` bash
128
- TB_RSPEC_OPTIONS='--fail-fast=3' rspec_booster --job 4/32
129
- ```
130
-
131
- The above command will execute:
132
128
 
129
+ Example:
133
130
  ``` bash
134
- bundle exec rspec --fail-fast=3 --format documentation --format json --out /home/<user>/rspec_report.json <file_list>
131
+ TB_RSPEC_OPTIONS='--fail-fast=3' TB_RSPEC_FORMATTER=Fivemat rspec_booster --job 4/32
132
+
133
+ # will execute:
134
+ bundle exec rspec --fail-fast=3 --format Fivemat --format json --out /home/<user>/rspec_report.json <file_list>
135
135
  ```
136
136
 
137
137
  ## Cucumber Booster
@@ -164,12 +164,29 @@ Example of running job 4 out of 32 jobs:
164
164
  minitest_booster --job 4/32
165
165
  ```
166
166
 
167
- Under the hood, the Minitest Booster uses the following command:
167
+ If minitest booster is executed in a scope of a Rails project, the following is
168
+ executed:
169
+
170
+ ``` bash
171
+ bundle exec rails test <file_list>
172
+ ```
173
+
174
+ If minitest booster is running outside of a Rails project, the following is
175
+ executed:
168
176
 
169
177
  ``` bash
170
178
  ruby -e 'ARGV.each { |f| require ".#{f}" }' <file_list>
171
179
  ```
172
180
 
181
+ If you want to run a custom command for minitest, use the
182
+ `MINITEST_BOOSTER_COMMAND` environment variable:
183
+
184
+ ``` bash
185
+ export MINITEST_BOOSTER_COMMAND="bundle exec rake test"
186
+
187
+ minitest_booster --job 1/42
188
+ ```
189
+
173
190
  ## ExUnit Booster
174
191
 
175
192
  The `ex_unit_booster` loads all the files that match the `test/**/*_test.exs`
@@ -18,6 +18,12 @@ module TestBoosters
18
18
 
19
19
  known, leftover = distribution.files_for(job_index)
20
20
 
21
+ if cli_options[:dry_run]
22
+ show_files_for_dry_run("known", known)
23
+ show_files_for_dry_run("leftover", leftover)
24
+ return 0
25
+ end
26
+
21
27
  exit_status = TestBoosters::Job.run(@command, known, leftover)
22
28
 
23
29
  after_job # execute some activities when the job finishes
@@ -25,6 +31,16 @@ module TestBoosters
25
31
  exit_status
26
32
  end
27
33
 
34
+ def show_files_for_dry_run(label, files)
35
+ if files.empty?
36
+ puts "[DRY RUN] No #{label} files."
37
+ return
38
+ end
39
+
40
+ puts "\n[DRY RUN] Running tests for #{label} files:"
41
+ puts files.map { |file| "- #{file}" }.join("\n")
42
+ end
43
+
28
44
  def before_job
29
45
  # Do nothing
30
46
  end
@@ -9,13 +9,33 @@ module TestBoosters
9
9
  end
10
10
 
11
11
  def command
12
- "ruby -e 'ARGV.each { |f| require \"./\#{f}\" }'"
12
+ if command_set_with_env_var?
13
+ command_from_env_var
14
+ elsif rails_app?
15
+ "bundle exec rails test"
16
+ else
17
+ "ruby -e 'ARGV.each { |f| require \"./\#{f}\" }'"
18
+ end
13
19
  end
14
20
 
15
21
  def split_configuration_path
16
22
  ENV["MINITEST_SPLIT_CONFIGURATION_PATH"] || "#{ENV["HOME"]}/minitest_split_configuration.json"
17
23
  end
18
24
 
25
+ def command_set_with_env_var?
26
+ !command_from_env_var.empty?
27
+ end
28
+
29
+ def command_from_env_var
30
+ ENV["MINITEST_BOOSTER_COMMAND"].to_s
31
+ end
32
+
33
+ private
34
+
35
+ def rails_app?
36
+ File.exist?("app") && File.exist?("config") && File.exist?("config/application.rb")
37
+ end
38
+
19
39
  end
20
40
  end
21
41
  end
@@ -1,11 +1,8 @@
1
1
  module TestBoosters
2
2
  module Boosters
3
3
  class Rspec < Base
4
-
5
- FILE_PATTERN = "spec/**/*_spec.rb".freeze
6
-
7
4
  def initialize
8
- super(FILE_PATTERN, split_configuration_path, command)
5
+ super(file_pattern, split_configuration_path, command)
9
6
  end
10
7
 
11
8
  def display_header
@@ -25,8 +22,11 @@ module TestBoosters
25
22
  end
26
23
 
27
24
  def rspec_options
28
- # rubocop:disable LineLength
29
- @rspec_options ||= "#{ENV["TB_RSPEC_OPTIONS"]} --format documentation --require #{formatter_path} --format SemaphoreFormatter --out #{report_path}"
25
+ @rspec_options ||= begin
26
+ output_formatter = ENV.fetch("TB_RSPEC_FORMATTER", "documentation")
27
+ # rubocop:disable LineLength
28
+ "#{ENV["TB_RSPEC_OPTIONS"]} --format #{output_formatter} --require #{formatter_path} --format SemaphoreFormatter --out #{report_path}"
29
+ end
30
30
  end
31
31
 
32
32
  def report_path
@@ -41,6 +41,9 @@ module TestBoosters
41
41
  @formatter_path ||= File.join(::TestBoosters::ROOT_PATH, "rspec_formatters/semaphore_rspec3_json_formatter.rb")
42
42
  end
43
43
 
44
+ def file_pattern
45
+ ENV["TEST_BOOSTERS_RSPEC_TEST_FILE_PATTERN"] || "spec/**/*_spec.rb"
46
+ end
44
47
  end
45
48
  end
46
49
  end
@@ -9,15 +9,28 @@ module TestBoosters
9
9
  options = {}
10
10
 
11
11
  parser = OptionParser.new do |opts|
12
- opts.on("--thread INDEX") do |parameter|
12
+ opts.on(
13
+ "--thread INDEX",
14
+ "[DEPRECATED] Use the '--job' option instead"
15
+ ) do |parameter|
13
16
  puts "[DEPRECATION WARNING] The '--thread' parameter is deprecated. Please use '--job' instead."
14
17
 
15
18
  options.merge!(parse_job_params(parameter))
16
19
  end
17
20
 
18
- opts.on("--job INDEX") do |parameter|
21
+ opts.on(
22
+ "--job INDEX",
23
+ "The job index and number of total jobs. e.g. --job 4/32"
24
+ ) do |parameter|
19
25
  options.merge!(parse_job_params(parameter))
20
26
  end
27
+
28
+ opts.on(
29
+ "--dry-run",
30
+ "Only print the files that will be run for this job index"
31
+ ) do |parameter|
32
+ options.merge!(:dry_run => parameter)
33
+ end
21
34
  end
22
35
 
23
36
  parser.parse!
@@ -25,7 +38,7 @@ module TestBoosters
25
38
  options
26
39
  end
27
40
 
28
- # parses input like '1/32' and ouputs { :job_index => 1, :job_count => 32 }
41
+ # parses input like '1/32' and outputs { :job_index => 1, :job_count => 32 }
29
42
  def parse_job_params(input_parameter)
30
43
  job_index, job_count, _rest = input_parameter.split("/")
31
44
 
@@ -12,9 +12,12 @@ module TestBoosters
12
12
  system(command)
13
13
  end
14
14
 
15
+ signaled = $?.signaled?
16
+ termsig = $?.termsig
15
17
  exited = $?.exited?
16
18
  exit_status = $?.exitstatus
17
19
 
20
+ TestBoosters::Logger.info("Command signaled with: #{termsig}") if signaled
18
21
  TestBoosters::Logger.info("Command exited : #{exited}")
19
22
  TestBoosters::Logger.info("Command finished, exit status : #{exit_status}")
20
23
 
@@ -1,3 +1,3 @@
1
1
  module TestBoosters
2
- VERSION = "2.2.3".freeze
2
+ VERSION = "2.6.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semaphore_test_boosters
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Developers at Rendered Text
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-10 00:00:00.000000000 Z
11
+ date: 2020-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semaphore_cucumber_booster_config