turbo_tests 1.0.0 → 1.1.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
  SHA256:
3
- metadata.gz: 90e474a8156b2c560bca5ee96efb75dd9d124a97e7a088bcc8b92223f0dd7580
4
- data.tar.gz: 73a47005dbc152492b6ef7e7f4d3c80cfdd958d755f998db453bc1f2cf7f48a8
3
+ metadata.gz: 617e19bd975077fab07e06ef1a6e5da35e72f962709464f62d32f381c6f4aacf
4
+ data.tar.gz: 260869dd5a88d6399f4608942632424027b06696a0d81390c68f2bd8446548af
5
5
  SHA512:
6
- metadata.gz: 9956bf53df8328cff65ef313397f358607ea359d23d086a07389c9fdc673169919220273cfcf77df267f72d45774524ded5318720fd23c59962fcb62d7eb0c68
7
- data.tar.gz: dcacad7897a69b0701993256fa2185454639c91c71810938e9cab574d0d1e601dacb74fe46b68930ddeaf8deba7a40fbc1a95b95b1fff055cffc894a191bf9e8
6
+ metadata.gz: c2eaac23e18d8a3d80e1d074a07f0ce7fafbbb0b6f5dcb0609dd408df0bfd5cd34a58d98fe7befe34a60a060b1f856a1e7e848223104e29dabd5795ea10448e6
7
+ data.tar.gz: 977901641b0bbf1b892155dd6197515eba480c0f6fa3d65d2c4e0d7162f1ea7d2935b766a5b0115ac24a23972343ead48c9b0ad31ff92361c028079108ca8509
@@ -1,10 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- turbo_tests (0.1.0)
5
- optparse
6
- parallel_tests
7
- rspec
4
+ turbo_tests (1.1.1)
5
+ parallel_tests (~> 3.3)
6
+ rspec (~> 3.9)
8
7
 
9
8
  GEM
10
9
  remote: https://rubygems.org/
@@ -12,7 +11,6 @@ GEM
12
11
  coderay (1.1.3)
13
12
  diff-lcs (1.4.4)
14
13
  method_source (1.0.0)
15
- optparse (0.1.0)
16
14
  parallel (1.19.2)
17
15
  parallel_tests (3.3.0)
18
16
  parallel
@@ -26,7 +24,7 @@ GEM
26
24
  rspec-mocks (~> 3.9.0)
27
25
  rspec-core (3.9.3)
28
26
  rspec-support (~> 3.9.3)
29
- rspec-expectations (3.9.3)
27
+ rspec-expectations (3.9.4)
30
28
  diff-lcs (>= 1.2.0, < 2.0)
31
29
  rspec-support (~> 3.9.0)
32
30
  rspec-mocks (3.9.1)
@@ -38,7 +36,7 @@ PLATFORMS
38
36
  ruby
39
37
 
40
38
  DEPENDENCIES
41
- pry
39
+ pry (~> 0.13)
42
40
  rake (~> 12.0)
43
41
  turbo_tests!
44
42
 
data/README.md CHANGED
@@ -36,7 +36,7 @@ Finished in 1 minute 35.05 seconds (files took 6.26 seconds to load)
36
36
  `turbo_tests` output looks like regular `rspec`:
37
37
 
38
38
  ```bash
39
- $ bundle exec turbo_spec
39
+ $ bundle exec turbo_tests
40
40
  ...........................................................................................................................................................................................
41
41
  ...........................................................................................................................................................................................
42
42
  ...........................................................................................................................................................................................
@@ -80,17 +80,20 @@ Show help:
80
80
  ```bash
81
81
  $ bundle exec turbo_tests -h
82
82
  Usage: turbo_tests [options]
83
+
84
+ [optional] Only selected files & folders:
85
+ turbo_tests spec/bar spec/baz/xxx_spec.rb
86
+
87
+ Options:
88
+ -n [PROCESSES] How many processes to use, default: available CPUs
83
89
  -r, --require PATH Require a file.
84
- -f, --format FORMATTER Choose a formatter.
90
+ -f, --format FORMATTER Choose a formatter. Available formatters: progress (p), documentation (d). Default: progress
85
91
  -t, --tag TAG Run examples with the specified tag.
86
92
  -o, --out FILE Write output to a file instead of $stdout
87
93
  -v, --verbose More output
88
94
  --fail-fast=[N]
89
95
  ```
90
96
 
91
- ## Roadmap
92
- - [ ] Capture time to load files #1
93
-
94
97
  ## Development
95
98
 
96
99
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -13,15 +13,31 @@ module TurboTests
13
13
  requires = []
14
14
  formatters = []
15
15
  tags = []
16
+ count = nil
16
17
  verbose = false
17
18
  fail_fast = nil
18
19
 
19
20
  OptionParser.new { |opts|
21
+ opts.banner = <<-BANNER.gsub(/^ /, "")
22
+ Run all tests in parallel, giving each process ENV['TEST_ENV_NUMBER'] ('1', '2', '3', ...).
23
+
24
+ Uses parallel_tests under the hood, but reports test results incrementally. Based on Discourse and RubyGems work in this area.
25
+
26
+ Usage: turbo_tests [options]
27
+
28
+ [optional] Only selected files & folders:
29
+ turbo_tests spec/bar spec/baz/xxx_spec.rb
30
+
31
+ Options:
32
+ BANNER
33
+
34
+ opts.on("-n [PROCESSES]", Integer, "How many processes to use, default: available CPUs") { |n| count = n }
35
+
20
36
  opts.on("-r", "--require PATH", "Require a file.") do |filename|
21
37
  requires << filename
22
38
  end
23
39
 
24
- opts.on("-f", "--format FORMATTER", "Choose a formatter.") do |name|
40
+ opts.on("-f", "--format FORMATTER", "Choose a formatter. Available formatters: progress (p), documentation (d). Default: progress") do |name|
25
41
  formatters << {
26
42
  name: name,
27
43
  outputs: []
@@ -76,7 +92,8 @@ module TurboTests
76
92
  tags: tags,
77
93
  files: @argv.empty? ? ["spec"] : @argv,
78
94
  verbose: verbose,
79
- fail_fast: fail_fast
95
+ fail_fast: fail_fast,
96
+ count: count,
80
97
  )
81
98
  end
82
99
  end
@@ -13,6 +13,7 @@ module TurboTests
13
13
  start_time = opts.fetch(:start_time) { Time.now }
14
14
  verbose = opts.fetch(:verbose, false)
15
15
  fail_fast = opts.fetch(:fail_fast, nil)
16
+ count = opts.fetch(:count, nil)
16
17
 
17
18
  reporter = Reporter.from_config(formatters, start_time)
18
19
 
@@ -21,7 +22,8 @@ module TurboTests
21
22
  files: files,
22
23
  tags: tags,
23
24
  verbose: verbose,
24
- fail_fast: fail_fast
25
+ fail_fast: fail_fast,
26
+ count: count
25
27
  ).run
26
28
  end
27
29
 
@@ -31,6 +33,8 @@ module TurboTests
31
33
  @tags = opts[:tags]
32
34
  @verbose = opts[:verbose]
33
35
  @fail_fast = opts[:fail_fast]
36
+ @count = opts[:count]
37
+
34
38
  @failure_count = 0
35
39
  @runtime_log = "tmp/parallel_runtime_rspec.log"
36
40
 
@@ -39,7 +43,10 @@ module TurboTests
39
43
  end
40
44
 
41
45
  def run
42
- @num_processes = ParallelTests.determine_number_of_processes(nil)
46
+ @num_processes = [
47
+ ParallelTests.determine_number_of_processes(@count),
48
+ ParallelTests::RSpec::Runner.tests_with_size(@files, {}).size
49
+ ].min
43
50
 
44
51
  tests_in_groups =
45
52
  ParallelTests::RSpec::Runner.tests_in_groups(
@@ -48,6 +55,8 @@ module TurboTests
48
55
  runtime_log: @runtime_log
49
56
  )
50
57
 
58
+ report_number_of_tests(tests_in_groups)
59
+
51
60
  tests_in_groups.each_with_index do |tests, process_id|
52
61
  start_regular_subprocess(tests, process_id + 1)
53
62
  end
@@ -176,5 +185,17 @@ module TurboTests
176
185
  def fail_fast_met
177
186
  !@fail_fast.nil? && @fail_fast >= @failure_count
178
187
  end
188
+
189
+ private
190
+
191
+ def report_number_of_tests(groups)
192
+ name = ParallelTests::RSpec::Runner.test_file_name
193
+
194
+ num_processes = groups.size
195
+ num_tests = groups.map(&:size).sum
196
+ tests_per_process = (num_processes == 0 ? 0 : num_tests / num_processes)
197
+
198
+ puts "#{num_processes} processes for #{num_tests} #{name}s, ~ #{tests_per_process} #{name}s per process"
199
+ end
179
200
  end
180
201
  end
@@ -1,3 +1,3 @@
1
1
  module TurboTests
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -4,7 +4,7 @@ Gem::Specification.new do |spec|
4
4
  spec.name = "turbo_tests"
5
5
  spec.version = TurboTests::VERSION
6
6
  spec.authors = ["Ilya Zub"]
7
- spec.email = ["ilya@serpapi.com"]
7
+ spec.email = ["zaoooza92@gmail.com"]
8
8
 
9
9
  spec.summary = "Runner for grosser/parallel_tests with incremental summarized output. Based on Discourse and Rubygems work in this area."
10
10
  spec.homepage = "https://github.com/serpapi/turbo_tests"
@@ -15,11 +15,10 @@ Gem::Specification.new do |spec|
15
15
  spec.metadata["source_code_uri"] = "https://github.com/serpapi/turbo_tests"
16
16
  spec.metadata["changelog_uri"] = "https://github.com/serpapi/turbo_tests/releases"
17
17
 
18
- spec.add_dependency "rspec"
19
- spec.add_dependency "parallel_tests"
20
- spec.add_dependency "optparse"
18
+ spec.add_dependency "rspec", "~> 3.9"
19
+ spec.add_dependency "parallel_tests", "~> 3.3"
21
20
 
22
- spec.add_development_dependency "pry"
21
+ spec.add_development_dependency "pry", "~> 0.13"
23
22
 
24
23
  # Specify which files should be added to the gem when it is released.
25
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Zub
@@ -14,61 +14,47 @@ dependencies:
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '3.9'
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: '0'
26
+ version: '3.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: parallel_tests
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '3.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: optparse
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: '3.3'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: pry
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ">="
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '0'
47
+ version: '0.13'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ">="
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '0'
54
+ version: '0.13'
69
55
  description:
70
56
  email:
71
- - ilya@serpapi.com
57
+ - zaoooza92@gmail.com
72
58
  executables:
73
59
  - turbo_tests
74
60
  extensions: []