semaphore_test_boosters 1.2.4 → 1.3.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: 16ee85bdadc0f19aaf4b16c3e5f98a710540a999
4
- data.tar.gz: 9c912cc4b2fa96df2ad02eddd132fec18651eb6e
3
+ metadata.gz: 4520935b29d20711b3eb5820b25f06f4636b9508
4
+ data.tar.gz: 128cc7b8d1003a16958eb8422170067627e24435
5
5
  SHA512:
6
- metadata.gz: 0ae6310f2469127c089493e9adfb979628c0b00a6ce52f99ab17f559325b57324343f2eb0b08d26aab665fc47404eff5326ddc6f6e53865d6b8cbbae481d181b
7
- data.tar.gz: b2ef54cccb3df907ddd682ae57242225aa9bbe32922b64a97873903325e45d35b16e3d59306081f53b6f878e5bb6c63d0845d873fc9c01ab32d3a84e3ec126bf
6
+ metadata.gz: 3e9462ca2bd7c54e737c5af5b7f1385e07430993e79c0a0ce4e4fa3453561bfcee0b720cd99e8cc74367c12a3784217f581259348bb5071104e3dc6cc8772262
7
+ data.tar.gz: de26c3793cb0aad2fe81428c18b7851d7b28d0c11b7f46644f76f5124bf21ee9f1f7592c1a4969d601f1080dd5128a3fc60b5a6f81af8510a5f6934a992e03fc
data/config/cucumber.yml CHANGED
@@ -1,2 +1,3 @@
1
- default: --format pretty --profile semaphoreci
1
+ default: --format pretty --profile semaphoreci --profile semaphoreci
2
+ semaphoreci: --format json --out=../cucumber_report.json
2
3
  semaphoreci: --format json --out=../cucumber_report.json
@@ -4,8 +4,7 @@ module TestBoosters
4
4
 
5
5
  def initialize(thread_index)
6
6
  @thread_index = thread_index
7
- @cucumber_split_configuration_path = ENV["CUCUMBER_SPLIT_CONFIGURATION_PATH"] || "#{ENV["HOME"]}/cucumber_split_configuration.json"
8
- @report_path = "#{ENV["HOME"]}/rspec_report.json"
7
+ @report_path = ENV["REPORT_PATH"] || "#{ENV["HOME"]}/cucumber_report.json"
9
8
  @spec_path = ENV["SPEC_PATH"] || "features"
10
9
  end
11
10
 
@@ -37,16 +36,15 @@ module TestBoosters
37
36
 
38
37
  def select
39
38
  with_fallback do
40
- file_distribution = JSON.parse(File.read(@cucumber_split_configuration_path))
41
- thread_count = file_distribution.count
42
- thread = file_distribution[@thread_index]
39
+ split_configuration = TestBoosters::SplitConfiguration.for_cucumber
40
+ thread_count = split_configuration.threads.count
43
41
 
44
42
  all_features = Dir["#{@spec_path}/**/*.feature"].sort
45
- all_known_features = file_distribution.map { |t| t["files"] }.flatten.sort
43
+ all_known_features = split_configuration.all_files
46
44
 
47
45
  all_leftover_features = all_features - all_known_features
48
46
  thread_leftover_features = TestBoosters::LeftoverFiles.select(all_leftover_features, thread_count, @thread_index)
49
- thread_features = all_features & thread["files"].sort
47
+ thread_features = all_features & split_configuration.files_for_thread(@thread_index)
50
48
  features_to_run = thread_features + thread_leftover_features
51
49
 
52
50
  TestBoosters::Shell.display_files("This thread features:", thread_features)
@@ -4,7 +4,6 @@ module TestBoosters
4
4
 
5
5
  def initialize(thread_index)
6
6
  @thread_index = thread_index
7
- @rspec_split_configuration_path = ENV["RSPEC_SPLIT_CONFIGURATION_PATH"] || "#{ENV["HOME"]}/rspec_split_configuration.json"
8
7
  @report_path = ENV["REPORT_PATH"] || "#{ENV["HOME"]}/rspec_report.json"
9
8
  @spec_path = ENV["SPEC_PATH"] || "spec"
10
9
  end
@@ -39,18 +38,18 @@ module TestBoosters
39
38
 
40
39
  def select
41
40
  with_fallback do
42
- file_distribution = JSON.parse(File.read(@rspec_split_configuration_path))
43
- thread_count = file_distribution.count
44
- thread = file_distribution[@thread_index]
41
+ split_configuration = TestBoosters::SplitConfiguration.for_rspec
42
+ thread_count = split_configuration.threads.count
45
43
 
46
44
  puts "Running RSpec thread #{@thread_index + 1} out of #{thread_count} threads\n"
47
45
 
48
46
  all_specs = Dir["#{@spec_path}/**/*_spec.rb"].sort
49
- all_known_specs = file_distribution.map { |t| t["files"] }.flatten.sort
47
+ all_known_specs = split_configuration.all_files
50
48
 
51
49
  all_leftover_specs = all_specs - all_known_specs
52
50
  thread_leftover_specs = TestBoosters::LeftoverFiles.select(all_leftover_specs, thread_count, @thread_index)
53
- thread_specs = all_specs & thread["files"].sort
51
+
52
+ thread_specs = all_specs & split_configuration.files_for_thread(@thread_index)
54
53
  specs_to_run = thread_specs + thread_leftover_specs
55
54
 
56
55
  TestBoosters::Shell.display_files("This thread specs:", thread_specs)
@@ -0,0 +1,54 @@
1
+ module TestBoosters
2
+ class SplitConfiguration
3
+
4
+ def self.for_rspec
5
+ path_from_env = ENV["RSPEC_SPLIT_CONFIGURATION_PATH"]
6
+ default_path = "#{ENV["HOME"]}/rspec_split_configuration.json"
7
+
8
+ new(path_from_env || default_path)
9
+ end
10
+
11
+ def self.for_cucumber
12
+ path_from_env = ENV["CUCUMBER_SPLIT_CONFIGURATION_PATH"]
13
+ default_path = "#{ENV["HOME"]}/cucumber_split_configuration.json"
14
+
15
+ new(path_from_env || default_path)
16
+ end
17
+
18
+ class Thread < Struct.new(:files, :thread_index)
19
+ end
20
+
21
+ def initialize(path)
22
+ @path = path
23
+ end
24
+
25
+ def present?
26
+ File.exist?(@path)
27
+ end
28
+
29
+ def all_files
30
+ @all_files ||= threads.map(&:files).flatten.sort
31
+ end
32
+
33
+ def files_for_thread(thread_index)
34
+ threads[thread_index].files
35
+ end
36
+
37
+ def threads
38
+ @threads ||= load_data.map.with_index do |raw_thread, index|
39
+ TestBoosters::SplitConfiguration::Thread.new(raw_thread["files"].sort, index)
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def load_data
46
+ if present?
47
+ JSON.parse(File.read(@path))
48
+ else
49
+ []
50
+ end
51
+ end
52
+
53
+ end
54
+ end
@@ -1,3 +1,3 @@
1
1
  module TestBoosters
2
- VERSION = "1.2.4"
2
+ VERSION = "1.3.0"
3
3
  end
data/lib/test_boosters.rb CHANGED
@@ -5,6 +5,7 @@ require "cucumber_booster_config"
5
5
  module TestBoosters
6
6
  require "test_boosters/version"
7
7
 
8
+ require "test_boosters/split_configuration"
8
9
  require "test_boosters/cli_parser"
9
10
  require "test_boosters/logger"
10
11
  require "test_boosters/shell"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semaphore_test_boosters
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MAINTAINER Rendered Text
@@ -107,8 +107,8 @@ files:
107
107
  - lib/test_boosters/leftover_files.rb
108
108
  - lib/test_boosters/logger.rb
109
109
  - lib/test_boosters/rspec_booster.rb
110
- - lib/test_boosters/run_cucumber_config.rb
111
110
  - lib/test_boosters/shell.rb
111
+ - lib/test_boosters/split_configuration.rb
112
112
  - lib/test_boosters/version.rb
113
113
  - test_boosters.gemspec
114
114
  - test_data/a.feature
File without changes