test-queue 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +94 -0
  3. data/.gitignore +6 -0
  4. data/Appraisals +43 -0
  5. data/Gemfile +4 -2
  6. data/README.md +13 -13
  7. data/Rakefile +14 -0
  8. data/{bin → exe}/cucumber-queue +4 -0
  9. data/{bin → exe}/minitest-queue +4 -0
  10. data/{bin → exe}/rspec-queue +4 -0
  11. data/{bin → exe}/testunit-queue +4 -0
  12. data/gemfiles/cucumber1_3.gemfile +9 -0
  13. data/gemfiles/cucumber2_4.gemfile +9 -0
  14. data/gemfiles/minitest4.gemfile +7 -0
  15. data/gemfiles/minitest5.gemfile +7 -0
  16. data/gemfiles/rspec2.gemfile +8 -0
  17. data/gemfiles/rspec3.gemfile +7 -0
  18. data/gemfiles/rspec4.gemfile +11 -0
  19. data/gemfiles/testunit.gemfile +7 -0
  20. data/lib/test-queue.rb +1 -1
  21. data/lib/test_queue/iterator.rb +1 -1
  22. data/lib/test_queue/runner/minitest.rb +2 -2
  23. data/lib/test_queue/runner/minitest4.rb +1 -1
  24. data/lib/test_queue/runner/minitest5.rb +8 -1
  25. data/lib/test_queue/runner/puppet_lint.rb +1 -1
  26. data/lib/test_queue/runner/rspec.rb +8 -3
  27. data/lib/test_queue/runner/sample.rb +2 -2
  28. data/lib/test_queue/runner/testunit.rb +1 -1
  29. data/lib/test_queue/runner.rb +22 -22
  30. data/lib/test_queue.rb +2 -2
  31. data/script/bootstrap +1 -0
  32. data/spec/stats_spec.rb +3 -0
  33. data/test/minitest4.bats +1 -1
  34. data/test/minitest5.bats +5 -5
  35. data/test/{rspec.bats → rspec2.bats} +4 -4
  36. data/test/rspec3.bats +56 -0
  37. data/test/rspec4.bats +56 -0
  38. data/test/samples/sample_shared_examples_for_spec.rb +2 -4
  39. data/test/samples/sample_spec.rb +3 -3
  40. data/test/samples/sample_split_spec.rb +1 -1
  41. data/test/samples/sample_use_shared_example1_spec.rb +1 -2
  42. data/test/samples/sample_use_shared_example2_spec.rb +1 -2
  43. data/test/sleepy_runner.rb +3 -1
  44. data/test-queue.gemspec +4 -3
  45. metadata +23 -32
  46. data/.travis.yml +0 -18
  47. data/Gemfile-cucumber1-3 +0 -4
  48. data/Gemfile-cucumber1-3.lock +0 -33
  49. data/Gemfile-cucumber2-4 +0 -4
  50. data/Gemfile-cucumber2-4.lock +0 -37
  51. data/Gemfile-minitest4 +0 -3
  52. data/Gemfile-minitest4.lock +0 -19
  53. data/Gemfile-minitest5 +0 -3
  54. data/Gemfile-minitest5.lock +0 -19
  55. data/Gemfile-rspec2-1 +0 -3
  56. data/Gemfile-rspec2-1.lock +0 -27
  57. data/Gemfile-rspec3-0 +0 -3
  58. data/Gemfile-rspec3-0.lock +0 -31
  59. data/Gemfile-rspec3-1 +0 -3
  60. data/Gemfile-rspec3-1.lock +0 -31
  61. data/Gemfile-rspec3-2 +0 -3
  62. data/Gemfile-rspec3-2.lock +0 -32
  63. data/Gemfile-testunit +0 -3
  64. data/Gemfile-testunit.lock +0 -21
  65. data/Gemfile.lock +0 -41
  66. data/script/cibuild +0 -19
  67. data/script/spec +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c32b025eec2391d8523ce84f4f180443b09f003f8770b8b27ff741aac464629
4
- data.tar.gz: 6a18a116cba1ec57617f92405a5d4554dab34dc5ab41be6ed10825b9c8b9f503
3
+ metadata.gz: a84d8eb24f2cdebe31f18be510d2ba28c8633e963beb62e498ef32674df3f761
4
+ data.tar.gz: 9869e95d639d312876faa0264b238ee8702ec21f5e5bc0bfe0d149ea1d83df31
5
5
  SHA512:
6
- metadata.gz: c7be91c62fc0e8f47826b441ed36f08ce454caf53bb56af03b11a3f7ed0eb88028ecb7ec96b03baf413ef985401292fee055561e876012c88e7e63fc7007ae00
7
- data.tar.gz: 27e6d8fbaf61bf96beede058ad5a25ae8695a88fb3ce3d14ba96666e8da2b1df066574aa7efa0f9bcd5cbd619d1825a0a8c4f4cbe20f0eb312b2f9692f7a3d49
6
+ metadata.gz: 7a33f1567709b2fda5670cac096733d0ab1e029fe4db18aec6e1a449b00dd919e979167febe5a249b875d28e536224f0680dfb9810f2b585ea6064fcdb500dcf
7
+ data.tar.gz: 2486c1c8a85b4fe9fbe87eb98b7aa76ea97e01951f7e66d6db64e91dae57f8692f8354d036a7d57c342a46ab2833c6aac9fb7263b138fdb802d6993765a2e9b4
@@ -0,0 +1,94 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ main:
11
+ name: >-
12
+ ${{ matrix.ruby }} ${{ matrix.entry.name }}
13
+ runs-on: ${{ matrix.os }}-latest
14
+ env:
15
+ TEST_QUEUE_WORKERS: 2
16
+ TEST_QUEUE_VERBOSE: 1
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ os: [ubuntu]
21
+ # Lowest and Latest version.
22
+ ruby: ['2.7', '3.2']
23
+ entry:
24
+ - { name: cucumber1_3, bats: test/cucumber.bats }
25
+ - { name: cucumber2_4, bats: test/cucumber.bats }
26
+ - { name: minitest4, bats: test/minitest4.bats }
27
+ - { name: minitest5, bats: test/minitest5.bats }
28
+ - { name: rspec3, bats: test/rspec3.bats }
29
+ - { name: rspec4, bats: test/rspec4.bats }
30
+ - { name: testunit, bats: test/testunit.bats }
31
+
32
+ steps:
33
+ - name: checkout
34
+ uses: actions/checkout@v3
35
+ - name: set up Ruby
36
+ uses: ruby/setup-ruby@v1
37
+ with:
38
+ ruby-version: ${{ matrix.ruby }}
39
+
40
+ - name: install dependencies
41
+ run: bundle install --jobs 3 --retry 3
42
+ - name: setup for Bats
43
+ run: bundle exec rake setup
44
+ - name: spec
45
+ run: bundle exec rake spec
46
+ - name: install dependencies for ${{ matrix.entry.name }}
47
+ run: BUNDLE_GEMFILE=gemfiles/${{ matrix.entry.name }}.gemfile bundle install --jobs 3 --retry 3
48
+ - name: test
49
+ run: BUNDLE_GEMFILE=gemfiles/${{ matrix.entry.name }}.gemfile vendor/bats/bin/bats ${{ matrix.entry.bats }}
50
+
51
+ # RSpec 2 doesn't work with Ruby 3.2:
52
+ #
53
+ # /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/rspec-core-2.99.2/lib/rspec/core/ruby_project.rb:27:
54
+ # in `block in find_first_parent_containing': undefined method `exists?' for File:Class (NoMethodError)
55
+ #
56
+ # ascend_until {|path| File.exists?(File.join(path, dir))}
57
+ # ^^^^^^^^
58
+ # Did you mean? exist?
59
+ #
60
+ # Up to Ruby 3.1 is the supported version for RSpec 2.
61
+ rspec2:
62
+ name: >-
63
+ ${{ matrix.ruby }} ${{ matrix.entry.name }}
64
+ runs-on: ${{ matrix.os }}-latest
65
+ env:
66
+ TEST_QUEUE_WORKERS: 2
67
+ TEST_QUEUE_VERBOSE: 1
68
+ strategy:
69
+ fail-fast: false
70
+ matrix:
71
+ os: [ubuntu]
72
+ # Lowest and Latest version.
73
+ ruby: ['2.7', '3.1']
74
+ entry:
75
+ - { name: rspec2, bats: test/rspec2.bats }
76
+
77
+ steps:
78
+ - name: checkout
79
+ uses: actions/checkout@v3
80
+ - name: set up Ruby
81
+ uses: ruby/setup-ruby@v1
82
+ with:
83
+ ruby-version: ${{ matrix.ruby }}
84
+
85
+ - name: install dependencies
86
+ run: bundle install --jobs 3 --retry 3
87
+ - name: setup for Bats
88
+ run: bundle exec rake setup
89
+ - name: spec
90
+ run: bundle exec rake spec
91
+ - name: install dependencies for ${{ matrix.entry.name }}
92
+ run: BUNDLE_GEMFILE=gemfiles/${{ matrix.entry.name }}.gemfile bundle install --jobs 3 --retry 3
93
+ - name: test
94
+ run: BUNDLE_GEMFILE=gemfiles/${{ matrix.entry.name }}.gemfile vendor/bats/bin/bats ${{ matrix.entry.bats }}
data/.gitignore CHANGED
@@ -1 +1,7 @@
1
1
  .test_queue_stats
2
+ .ruby-version
3
+ Gemfile.lock
4
+ gemfiles/.bundle/
5
+ *.gemfile.lock
6
+ pkg
7
+ vendor
data/Appraisals ADDED
@@ -0,0 +1,43 @@
1
+ appraise "cucumber1-3" do
2
+ gem 'cucumber', '~> 1.3.10'
3
+ # Pin Rake version to Prevent `NoMethodError: undefined method `last_comment'`.
4
+ gem 'rake', '< 11.0'
5
+ end
6
+
7
+ appraise "cucumber2-4" do
8
+ gem 'cucumber', '~> 2.4.0'
9
+ # Pin Rake version to Prevent `NoMethodError: undefined method `last_comment'`.
10
+ gem 'rake', '< 11.0'
11
+ end
12
+
13
+ appraise "minitest4" do
14
+ gem 'rake'
15
+ gem 'minitest', '~> 4.7'
16
+ end
17
+
18
+ appraise "minitest5" do
19
+ gem 'rake'
20
+ gem 'minitest', '5.10.0'
21
+ end
22
+
23
+ appraise "rspec2" do
24
+ # Pin Rake version to Prevent `NoMethodError: undefined method `last_comment'`.
25
+ gem 'rake', '< 11.0'
26
+ gem 'rspec', '~> 2.99'
27
+ end
28
+
29
+ appraise "rspec3" do
30
+ gem 'rspec', '~> 3.12'
31
+ end
32
+
33
+ appraise "rspec4" do
34
+ gem 'rspec', github: 'rspec/rspec-metagem', branch: '4-0-dev'
35
+ gem 'rspec-core', github: 'rspec/rspec-core', branch: '4-0-dev'
36
+ gem 'rspec-expectations', github: 'rspec/rspec-expectations', branch: '4-0-dev'
37
+ gem 'rspec-mocks', github: 'rspec/rspec-mocks', branch: '4-0-dev'
38
+ gem 'rspec-support', github: 'rspec/rspec-support', branch: '4-0-dev'
39
+ end
40
+
41
+ appraise "testunit" do
42
+ gem 'test-unit'
43
+ end
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source 'https://rubygems.org'
2
+
2
3
  gemspec
3
- gem 'minitest', '5.3.3'
4
+
5
+ gem 'appraisal'
6
+ gem 'rake'
4
7
  gem 'rspec', '>= 2.13', '< 4.0'
5
- gem 'cucumber', '~> 1.3.10'
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- ## test-queue
1
+ # test-queue
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/test-queue.svg)](https://rubygems.org/gems/test-queue)
4
- [![Build Status](https://travis-ci.org/tmm1/test-queue.svg?branch=master)](https://travis-ci.org/tmm1/test-queue)
4
+ [![CI](https://github.com/tmm1/test-queue/actions/workflows/test.yml/badge.svg)](https://github.com/tmm1/test-queue/actions/workflows/test.yml)
5
5
 
6
6
  Yet another parallel test runner, built using a centralized queue to ensure
7
7
  optimal distribution of tests between workers.
@@ -10,13 +10,13 @@ Specifically optimized for CI environments: build statistics from each run
10
10
  are stored locally and used to sort the queue at the beginning of the
11
11
  next run.
12
12
 
13
- ### design
13
+ ## Design
14
14
 
15
15
  test-queue uses a simple master + pre-fork worker model. The master
16
16
  exposes a unix domain socket server which workers use to grab tests off
17
17
  the queue.
18
18
 
19
- ```
19
+ ```console
20
20
  ─┬─ 21232 minitest-queue master
21
21
  ├─── 21571 minitest-queue worker [3] - AuthenticationTest
22
22
  ├─── 21568 minitest-queue worker [2] - ApiTest
@@ -27,7 +27,7 @@ the queue.
27
27
  test-queue also has a distributed mode, where additional masters can share
28
28
  the workload and relay results back to a central master.
29
29
 
30
- ### environment variables
30
+ ## Environment variables
31
31
 
32
32
  - `TEST_QUEUE_WORKERS`: number of workers to use per master (default: all available cores)
33
33
  - `TEST_QUEUE_VERBOSE`: show results as they are available (default: `0`)
@@ -40,11 +40,11 @@ the workload and relay results back to a central master.
40
40
  - `TEST_QUEUE_REMOTE_MASTER_MESSAGE`: when using distributed builds, set this on a remote master and it will appear in that master's connection message on the central master.
41
41
  - `TEST_QUEUE_SPLIT_GROUPS`: split tests up by example rather than example group. Faster for tests with short setup time such as selenium. RSpec only. Add the :no_split tag to ExampleGroups you don't want split.
42
42
 
43
- ### usage
43
+ ## Usage
44
44
 
45
45
  test-queue bundles `testunit-queue`, `minitest-queue` and `rspec-queue` binaries which can be used directly:
46
46
 
47
- ```
47
+ ```console
48
48
  $ minitest-queue $(find test/ -name \*_test.rb)
49
49
  $ rspec-queue --format progress spec
50
50
  ```
@@ -53,7 +53,7 @@ But the underlying `TestQueue::Runner::TestUnit`, `TestQueue::Runner::MiniTest`
53
53
  built to be subclassed by your application. I recommend checking a new
54
54
  executable into your project using one of these superclasses.
55
55
 
56
- ```
56
+ ```console
57
57
  $ vim script/test-queue
58
58
  $ chmod +x script/test-queue
59
59
  $ git add script/test-queue
@@ -69,7 +69,7 @@ runner to reset any global state.
69
69
  class MyAppTestRunner < TestQueue::Runner::MiniTest
70
70
  def after_fork(num)
71
71
  # use separate mysql database (we assume it exists and has the right schema already)
72
- ActiveRecord::Base.configurations['test']['database'] << num.to_s
72
+ ActiveRecord::Base.configurations.configs_for(env_name: 'test', name: 'primary').database << num.to_s
73
73
  ActiveRecord::Base.establish_connection(:test)
74
74
 
75
75
  # use separate redis database
@@ -97,13 +97,13 @@ end
97
97
  MyAppTestRunner.new.execute
98
98
  ```
99
99
 
100
- ### distributed mode
100
+ ## Distributed mode
101
101
 
102
102
  To use distributed mode, the central master must listen on a tcp port. Additional masters can be booted
103
- in relay mode to connect to the central master. Remote masters must provide a TEST_QUEUE_RELAY_TOKEN
103
+ in relay mode to connect to the central master. Remote masters must provide a `TEST_QUEUE_RELAY_TOKEN`
104
104
  to match the central master's.
105
105
 
106
- ```
106
+ ```console
107
107
  $ TEST_QUEUE_RELAY_TOKEN=123 TEST_QUEUE_SOCKET=0.0.0.0:12345 bundle exec minitest-queue ./test/sample_test.rb
108
108
  $ TEST_QUEUE_RELAY_TOKEN=123 TEST_QUEUE_RELAY=0.0.0.0:12345 bundle exec minitest-queue ./test/sample_test.rb
109
109
  $ TEST_QUEUE_RELAY_TOKEN=123 ./test-multi.sh
@@ -112,7 +112,7 @@ $ TEST_QUEUE_RELAY_TOKEN=123 ./test-multi.sh
112
112
  See the [Parameterized Trigger Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin)
113
113
  for a simple way to do this with jenkins.
114
114
 
115
- ### see also
115
+ ## See also
116
116
 
117
117
  * https://github.com/Shopify/rails_parallel
118
118
  * https://github.com/grosser/parallel_tests
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => [:setup, :spec, :feature]
7
+
8
+ task :setup do
9
+ sh 'script/bootstrap' unless File.exist?("#{Dir.pwd}/vendor/bats/bin/bats")
10
+ end
11
+
12
+ task :feature do
13
+ sh 'TEST_QUEUE_WORKERS=2 TEST_QUEUE_VERBOSE=1 vendor/bats/bin/bats test'
14
+ end
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+
2
5
  require 'test_queue'
3
6
  require 'test_queue/runner/cucumber'
7
+
4
8
  TestQueue::Runner::Cucumber.new.execute
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+
2
5
  require 'test_queue'
3
6
  require 'test_queue/runner/minitest'
7
+
4
8
  TestQueue::Runner::MiniTest.new.execute
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+
2
5
  require 'test_queue'
3
6
  require 'test_queue/runner/rspec'
7
+
4
8
  TestQueue::Runner::RSpec.new.execute
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+
2
5
  require 'test_queue'
3
6
  require 'test_queue/runner/testunit'
7
+
4
8
  TestQueue::Runner::TestUnit.new.execute
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "< 11.0"
6
+ gem "rspec", ">= 2.13", "< 4.0"
7
+ gem "cucumber", "~> 1.3.10"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "< 11.0"
6
+ gem "rspec", ">= 2.13", "< 4.0"
7
+ gem "cucumber", "~> 2.4.0"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "minitest", "~> 4.7"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "minitest", "5.10.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "< 11.0"
6
+ gem "rspec", "~> 2.99"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rspec", "~> 3.12"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem 'rspec', github: 'rspec/rspec-metagem', branch: '4-0-dev'
6
+ gem 'rspec-core', github: 'rspec/rspec-core', branch: '4-0-dev'
7
+ gem 'rspec-expectations', github: 'rspec/rspec-expectations', branch: '4-0-dev'
8
+ gem 'rspec-mocks', github: 'rspec/rspec-mocks', branch: '4-0-dev'
9
+ gem 'rspec-support', github: 'rspec/rspec-support', branch: '4-0-dev'
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "test-unit"
6
+
7
+ gemspec path: "../"
data/lib/test-queue.rb CHANGED
@@ -1 +1 @@
1
- require 'test_queue'
1
+ require_relative 'test_queue'
@@ -8,7 +8,7 @@ module TestQueue
8
8
  @suite_stats = []
9
9
  @sock = sock
10
10
  @filter = filter
11
- if @sock =~ /^(.+):(\d+)$/
11
+ if @sock =~ /\A(.+):(\d+)\z/
12
12
  @tcp_address = $1
13
13
  @tcp_port = $2.to_i
14
14
  end
@@ -1,9 +1,9 @@
1
1
  begin
2
2
  require 'minitest'
3
- require 'test_queue/runner/minitest5'
3
+ require_relative '../runner/minitest5'
4
4
  rescue LoadError => e
5
5
  require 'minitest/unit'
6
- require 'test_queue/runner/minitest4'
6
+ require_relative '../runner/minitest4'
7
7
  end
8
8
 
9
9
  module TestQueue
@@ -1,4 +1,4 @@
1
- require 'test_queue/runner'
1
+ require_relative '../runner'
2
2
  require 'set'
3
3
  require 'stringio'
4
4
 
@@ -1,4 +1,4 @@
1
- require 'test_queue/runner'
1
+ require_relative '../runner'
2
2
 
3
3
  module MiniTest
4
4
  def self.__run reporter, options
@@ -56,6 +56,13 @@ module TestQueue
56
56
  class Runner
57
57
  class MiniTest < Runner
58
58
  def initialize
59
+ options = Minitest.process_args ARGV
60
+
61
+ if Minitest.respond_to?(:seed)
62
+ Minitest.seed = options[:seed]
63
+ srand Minitest.seed
64
+ end
65
+
59
66
  if ::MiniTest::Test.runnables.any? { |r| r.runnable_methods.any? }
60
67
  fail "Do not `require` test files. Pass them via ARGV instead and they will be required as needed."
61
68
  end
@@ -1,4 +1,4 @@
1
- require 'test_queue'
1
+ require_relative '../../test_queue'
2
2
  require 'puppet-lint'
3
3
 
4
4
  module TestQueue
@@ -1,13 +1,13 @@
1
- require 'test_queue/runner'
1
+ require_relative '../runner'
2
2
  require 'rspec/core'
3
3
 
4
4
  case ::RSpec::Core::Version::STRING.to_i
5
5
  when 2
6
6
  require_relative 'rspec2'
7
- when 3
7
+ when 3, 4
8
8
  require_relative 'rspec3'
9
9
  else
10
- fail 'requires rspec version 2 or 3'
10
+ fail 'requires rspec version 2, 3, or 4'
11
11
  end
12
12
 
13
13
  module TestQueue
@@ -36,6 +36,11 @@ module TestQueue
36
36
  options.parse_options if options.respond_to?(:parse_options)
37
37
  options.configure(::RSpec.configuration)
38
38
 
39
+ if ::RSpec.configuration.instance_variable_defined?(:@files_or_directories_to_run) &&
40
+ ::RSpec.configuration.instance_variable_get(:@files_or_directories_to_run).empty?
41
+ ::RSpec.configuration.instance_variable_set(:@files_or_directories_to_run, [::RSpec.configuration.default_path])
42
+ end
43
+
39
44
  ::RSpec.configuration.files_to_run.uniq
40
45
  end
41
46
 
@@ -1,5 +1,5 @@
1
- require 'test_queue'
2
- require 'test_queue/runner'
1
+ require_relative '../../test_queue'
2
+ require_relative '../runner'
3
3
 
4
4
  module TestQueue
5
5
  class Runner
@@ -1,4 +1,4 @@
1
- require 'test_queue/runner'
1
+ require_relative '../runner'
2
2
 
3
3
  gem 'test-unit'
4
4
  require 'test/unit'
@@ -2,8 +2,8 @@ require 'set'
2
2
  require 'socket'
3
3
  require 'fileutils'
4
4
  require 'securerandom'
5
- require 'test_queue/stats'
6
- require 'test_queue/test_framework'
5
+ require_relative 'stats'
6
+ require_relative 'test_framework'
7
7
 
8
8
  module TestQueue
9
9
  class Worker
@@ -31,7 +31,7 @@ module TestQueue
31
31
  attr_accessor :concurrency, :exit_when_done
32
32
  attr_reader :stats
33
33
 
34
- TOKEN_REGEX = /^TOKEN=(\w+)/
34
+ TOKEN_REGEX = /\ATOKEN=(\w+)/
35
35
 
36
36
  def initialize(test_framework, concurrency=nil, socket=nil, relay=nil)
37
37
  @test_framework = test_framework
@@ -48,12 +48,12 @@ module TestQueue
48
48
 
49
49
  @procline = $0
50
50
 
51
- @whitelist = if forced = ENV['TEST_QUEUE_FORCE']
51
+ @allowlist = if forced = ENV['TEST_QUEUE_FORCE']
52
52
  forced.split(/\s*,\s*/)
53
53
  else
54
54
  []
55
55
  end
56
- @whitelist.freeze
56
+ @allowlist.freeze
57
57
 
58
58
  all_files = @test_framework.all_suite_files.to_set
59
59
  @queue = @stats.all_suites
@@ -61,12 +61,12 @@ module TestQueue
61
61
  .sort_by { |suite| -suite.duration }
62
62
  .map { |suite| [suite.name, suite.path] }
63
63
 
64
- if @whitelist.any?
65
- @queue.select! { |suite_name, path| @whitelist.include?(suite_name) }
66
- @queue.sort_by! { |suite_name, path| @whitelist.index(suite_name) }
64
+ if @allowlist.any?
65
+ @queue.select! { |suite_name, path| @allowlist.include?(suite_name) }
66
+ @queue.sort_by! { |suite_name, path| @allowlist.index(suite_name) }
67
67
  end
68
68
 
69
- @awaited_suites = Set.new(@whitelist)
69
+ @awaited_suites = Set.new(@allowlist)
70
70
  @original_queue = Set.new(@queue).freeze
71
71
 
72
72
  @workers = {}
@@ -251,7 +251,7 @@ module TestQueue
251
251
 
252
252
  def start_master
253
253
  if !relay?
254
- if @socket =~ /^(?:(.+):)?(\d+)$/
254
+ if @socket =~ /\A(?:(.+):)?(\d+)\z/
255
255
  address = $1 || '0.0.0.0'
256
256
  port = $2.to_i
257
257
  @socket = "#$1:#$2"
@@ -318,9 +318,9 @@ module TestQueue
318
318
  # distributes them to remote masters.
319
319
  return if relay?
320
320
 
321
- # No need to discover suites if all whitelisted suites are already
321
+ # No need to discover suites if all allowlisted suites are already
322
322
  # queued.
323
- return if @whitelist.any? && @awaited_suites.empty?
323
+ return if @allowlist.any? && @awaited_suites.empty?
324
324
 
325
325
  @discovering_suites_pid = fork do
326
326
  terminate = false
@@ -346,7 +346,7 @@ module TestQueue
346
346
  def awaiting_suites?
347
347
  case
348
348
  when @awaited_suites.any?
349
- # We're waiting to find all the whitelisted suites so we can run them
349
+ # We're waiting to find all the allowlisted suites so we can run them
350
350
  # in the correct order.
351
351
  true
352
352
  when @queue.empty? && !!@discovering_suites_pid
@@ -359,7 +359,7 @@ module TestQueue
359
359
  end
360
360
 
361
361
  def enqueue_discovered_suite(suite_name, path)
362
- if @whitelist.any? && !@whitelist.include?(suite_name)
362
+ if @allowlist.any? && !@allowlist.include?(suite_name)
363
363
  return
364
364
  end
365
365
 
@@ -377,9 +377,9 @@ module TestQueue
377
377
  @queue.unshift [suite_name, path]
378
378
 
379
379
  if @awaited_suites.delete?(suite_name) && @awaited_suites.empty?
380
- # We've found all the whitelisted suites. Sort the queue to match the
381
- # whitelist.
382
- @queue.sort_by! { |suite_name, path| @whitelist.index(suite_name) }
380
+ # We've found all the allowlisted suites. Sort the queue to match the
381
+ # allowlist.
382
+ @queue.sort_by! { |suite_name, path| @allowlist.index(suite_name) }
383
383
 
384
384
  kill_suite_discovery_process("INT")
385
385
  end
@@ -500,7 +500,7 @@ module TestQueue
500
500
  end
501
501
 
502
502
  case cmd
503
- when /^POP (\S+) (\d+)/
503
+ when /\APOP (\S+) (\d+)/
504
504
  hostname = $1
505
505
  pid = Integer($2)
506
506
  if awaiting_suites?
@@ -510,7 +510,7 @@ module TestQueue
510
510
  sock.write(data)
511
511
  @assignments[obj] = [hostname, pid]
512
512
  end
513
- when /^REMOTE MASTER (\d+) ([\w\.-]+)(?: (.+))?/
513
+ when /\AREMOTE MASTER (\d+) ([\w\.-]+)(?: (.+))?/
514
514
  num = $1.to_i
515
515
  remote_master = $2
516
516
  remote_master_message = $3
@@ -521,15 +521,15 @@ module TestQueue
521
521
  message = "*** #{num} workers connected from #{remote_master} after #{Time.now-@start_time}s"
522
522
  message << " " + remote_master_message if remote_master_message
523
523
  STDERR.puts message
524
- when /^WORKER (\d+)/
524
+ when /\AWORKER (\d+)/
525
525
  data = sock.read($1.to_i)
526
526
  worker = Marshal.load(data)
527
527
  worker_completed(worker)
528
528
  remote_workers -= 1
529
- when /^NEW SUITE (.+)/
529
+ when /\ANEW SUITE (.+)/
530
530
  suite_name, path = Marshal.load($1)
531
531
  enqueue_discovered_suite(suite_name, path)
532
- when /^KABOOM/
532
+ when /\AKABOOM/
533
533
  # worker reporting an abnormal number of test failures;
534
534
  # stop everything immediately and report the results.
535
535
  break
data/lib/test_queue.rb CHANGED
@@ -4,5 +4,5 @@ if !IO.respond_to?(:binread)
4
4
  end
5
5
  end
6
6
 
7
- require 'test_queue/iterator'
8
- require 'test_queue/runner'
7
+ require_relative 'test_queue/iterator'
8
+ require_relative 'test_queue/runner'
data/script/bootstrap CHANGED
@@ -10,3 +10,4 @@ mkdir tmp
10
10
  mkdir -p vendor/bats
11
11
  curl --silent --location --show-error https://github.com/sstephenson/bats/archive/v0.4.0.tar.gz | tar -xz -C tmp
12
12
  tmp/bats-0.4.0/install.sh "$ROOT/vendor/bats"
13
+ rm -rf tmp