semaphore_test_boosters 2.4.0 → 2.7.1

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: 38151e0d34ca4081dea4782b8bd0ee4c522c60e8
4
- data.tar.gz: 14cbff2823879b021ebd16dab027e728a146bc4f
3
+ metadata.gz: 6d0c966918c0c180dcc5d54a2e9e4510d94ba427
4
+ data.tar.gz: 204e1afda777bf4bd5c9c0041fb3a10f654fb3e3
5
5
  SHA512:
6
- metadata.gz: 3d269fa457ead201112c6046ff79eded087d198d2f597e0f9d7fddbc9cb2be15cf5cf12ab6008ada2d37cad7db93dd097039af4cdebcac096ec995c8f2a11561
7
- data.tar.gz: e7f4a3b8a7900042606e7682fefc64d13bcc797ea9b1a9f13514b99a2436376e670e89f69a59ae3be769260bdcb84f6c2418a4d95a0496beaa2eca2acc03e59a
6
+ metadata.gz: 071bead8abd93a9e38e8ed12da57ad08f1c5a033743086165d6e6a54389a1514e1cfe0a0c01e4a6264294bb06a41e3519496cdcba5b57185d7a050ab789867e9
7
+ data.tar.gz: 748c105efbe779da651fb25c5ac04186235e140809a4cc06692edc45ea044a7ad0d117d0ecea36cdd6d783d5a09f327b2b128c93ed43fd167b70005e361d22fd
data/README.md CHANGED
@@ -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`
@@ -2,9 +2,10 @@ module TestBoosters
2
2
  module Boosters
3
3
  class Base
4
4
 
5
- def initialize(file_pattern, split_configuration_path, command)
5
+ def initialize(file_pattern, exclude_pattern, split_configuration_path, command)
6
6
  @command = command
7
7
  @file_pattern = file_pattern
8
+ @exclude_pattern = exclude_pattern
8
9
  @split_configuration_path = split_configuration_path
9
10
  end
10
11
 
@@ -18,6 +19,12 @@ module TestBoosters
18
19
 
19
20
  known, leftover = distribution.files_for(job_index)
20
21
 
22
+ if cli_options[:dry_run]
23
+ show_files_for_dry_run("known", known)
24
+ show_files_for_dry_run("leftover", leftover)
25
+ return 0
26
+ end
27
+
21
28
  exit_status = TestBoosters::Job.run(@command, known, leftover)
22
29
 
23
30
  after_job # execute some activities when the job finishes
@@ -25,6 +32,16 @@ module TestBoosters
25
32
  exit_status
26
33
  end
27
34
 
35
+ def show_files_for_dry_run(label, files)
36
+ if files.empty?
37
+ puts "[DRY RUN] No #{label} files."
38
+ return
39
+ end
40
+
41
+ puts "\n[DRY RUN] Running tests for #{label} files:"
42
+ puts files.map { |file| "- #{file}" }.join("\n")
43
+ end
44
+
28
45
  def before_job
29
46
  # Do nothing
30
47
  end
@@ -43,6 +60,7 @@ module TestBoosters
43
60
  def distribution
44
61
  @distribution ||= TestBoosters::Files::Distributor.new(@split_configuration_path,
45
62
  @file_pattern,
63
+ @exclude_pattern,
46
64
  job_count)
47
65
  end
48
66
 
@@ -5,7 +5,7 @@ module TestBoosters
5
5
  FILE_PATTERN = "features/**/*.feature".freeze
6
6
 
7
7
  def initialize
8
- super(FILE_PATTERN, split_configuration_path, "bundle exec cucumber")
8
+ super(FILE_PATTERN, nil, split_configuration_path, "bundle exec cucumber")
9
9
  end
10
10
 
11
11
  def before_job
@@ -5,7 +5,7 @@ module TestBoosters
5
5
  FILE_PATTERN = "test/**/*_test.exs".freeze
6
6
 
7
7
  def initialize
8
- super(FILE_PATTERN, split_configuration_path, "mix test")
8
+ super(FILE_PATTERN, nil, split_configuration_path, "mix test")
9
9
  end
10
10
 
11
11
  def split_configuration_path
@@ -5,7 +5,7 @@ module TestBoosters
5
5
  FILE_PATTERN = "**/*/*_test.go".freeze
6
6
 
7
7
  def initialize
8
- super(FILE_PATTERN, split_configuration_path, "go test")
8
+ super(FILE_PATTERN, nil, split_configuration_path, "go test")
9
9
  end
10
10
 
11
11
  def split_configuration_path
@@ -5,17 +5,37 @@ module TestBoosters
5
5
  FILE_PATTERN = "test/**/*_test.rb".freeze
6
6
 
7
7
  def initialize
8
- super(FILE_PATTERN, split_configuration_path, command)
8
+ super(FILE_PATTERN, nil, split_configuration_path, command)
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
@@ -2,7 +2,7 @@ module TestBoosters
2
2
  module Boosters
3
3
  class Rspec < Base
4
4
  def initialize
5
- super(file_pattern, split_configuration_path, command)
5
+ super(file_pattern, exclude_pattern, split_configuration_path, command)
6
6
  end
7
7
 
8
8
  def display_header
@@ -44,6 +44,10 @@ module TestBoosters
44
44
  def file_pattern
45
45
  ENV["TEST_BOOSTERS_RSPEC_TEST_FILE_PATTERN"] || "spec/**/*_spec.rb"
46
46
  end
47
+
48
+ def exclude_pattern
49
+ ENV["TEST_BOOSTERS_RSPEC_TEST_EXCLUDE_PATTERN"]
50
+ end
47
51
  end
48
52
  end
49
53
  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
 
@@ -6,9 +6,10 @@ module TestBoosters
6
6
  #
7
7
  class Distributor
8
8
 
9
- def initialize(split_configuration_path, file_pattern, job_count)
9
+ def initialize(split_configuration_path, file_pattern, exclude_pattern, job_count)
10
10
  @split_configuration_path = split_configuration_path
11
11
  @file_pattern = file_pattern
12
+ @exclude_pattern = exclude_pattern
12
13
  @job_count = job_count
13
14
  end
14
15
 
@@ -26,7 +27,11 @@ module TestBoosters
26
27
  end
27
28
 
28
29
  def all_files
29
- @all_files ||= Dir[@file_pattern].sort
30
+ @all_files ||= begin
31
+ files = Dir[@file_pattern].sort
32
+ files -= Dir[@exclude_pattern] if @exclude_pattern
33
+ files
34
+ end
30
35
  end
31
36
 
32
37
  private
@@ -1,3 +1,3 @@
1
1
  module TestBoosters
2
- VERSION = "2.4.0".freeze
2
+ VERSION = "2.7.1".freeze
3
3
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "semaphore_cucumber_booster_config", "~> 1.4.1"
22
+ spec.add_dependency "semaphore_cucumber_booster_config", "~> 1.4.2"
23
23
 
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.5"
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.4.0
4
+ version: 2.7.1
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: 2019-11-14 00:00:00.000000000 Z
11
+ date: 2021-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semaphore_cucumber_booster_config
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.4.1
19
+ version: 1.4.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.4.1
26
+ version: 1.4.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement