knapsack_pro 2.18.1 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -1
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +33 -0
  5. data/README.md +8 -3
  6. data/knapsack_pro.gemspec +1 -1
  7. data/lib/knapsack_pro/adapters/base_adapter.rb +4 -4
  8. data/lib/knapsack_pro/adapters/rspec_adapter.rb +5 -10
  9. data/lib/knapsack_pro/config/env.rb +8 -1
  10. data/lib/knapsack_pro/config/temp_files.rb +38 -0
  11. data/lib/knapsack_pro/report.rb +7 -8
  12. data/lib/knapsack_pro/runners/cucumber_runner.rb +3 -0
  13. data/lib/knapsack_pro/runners/minitest_runner.rb +3 -0
  14. data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +3 -1
  15. data/lib/knapsack_pro/runners/queue/minitest_runner.rb +3 -1
  16. data/lib/knapsack_pro/runners/queue/rspec_runner.rb +3 -2
  17. data/lib/knapsack_pro/runners/rspec_runner.rb +3 -0
  18. data/lib/knapsack_pro/runners/spinach_runner.rb +3 -0
  19. data/lib/knapsack_pro/runners/test_unit_runner.rb +3 -0
  20. data/lib/knapsack_pro/slow_test_file_determiner.rb +8 -4
  21. data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +9 -6
  22. data/lib/knapsack_pro/tracker.rb +56 -1
  23. data/lib/knapsack_pro/version.rb +1 -1
  24. data/lib/knapsack_pro.rb +1 -0
  25. data/spec/knapsack_pro/adapters/base_adapter_spec.rb +9 -7
  26. data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +20 -24
  27. data/spec/knapsack_pro/config/env_spec.rb +25 -0
  28. data/spec/knapsack_pro/config/temp_files_spec.rb +25 -0
  29. data/spec/knapsack_pro/report_spec.rb +11 -10
  30. data/spec/knapsack_pro/runners/cucumber_runner_spec.rb +9 -1
  31. data/spec/knapsack_pro/runners/minitest_runner_spec.rb +6 -1
  32. data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +2 -0
  33. data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +2 -0
  34. data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +2 -0
  35. data/spec/knapsack_pro/runners/rspec_runner_spec.rb +9 -1
  36. data/spec/knapsack_pro/runners/spinach_runner_spec.rb +9 -1
  37. data/spec/knapsack_pro/runners/test_unit_runner_spec.rb +6 -1
  38. data/spec/knapsack_pro/slow_test_file_determiner_spec.rb +2 -2
  39. data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +8 -6
  40. data/spec/knapsack_pro/tracker_spec.rb +67 -2
  41. data/spec/spec_helper.rb +5 -2
  42. metadata +6 -9
@@ -1,8 +1,6 @@
1
1
  module KnapsackPro
2
2
  module TestCaseDetectors
3
3
  class RSpecTestExampleDetector
4
- REPORT_DIR = "#{KnapsackPro::Config::Env::TMP_DIR}/test_case_detectors/rspec"
5
-
6
4
  def generate_json_report
7
5
  require 'rspec/core'
8
6
 
@@ -47,7 +45,7 @@ module KnapsackPro
47
45
  end
48
46
 
49
47
  def test_file_example_paths
50
- raise "No report found at #{report_path}" unless File.exists?(report_path)
48
+ raise "No report found at #{report_path}" unless File.exist?(report_path)
51
49
 
52
50
  json_report = File.read(report_path)
53
51
  hash_report = JSON.parse(json_report)
@@ -69,8 +67,12 @@ module KnapsackPro
69
67
 
70
68
  private
71
69
 
70
+ def report_dir
71
+ "#{KnapsackPro::Config::TempFiles::TEMP_DIRECTORY_PATH}/test_case_detectors/rspec"
72
+ end
73
+
72
74
  def report_path
73
- "#{REPORT_DIR}/rspec_dry_run_json_report_node_#{KnapsackPro::Config::Env.ci_node_index}.json"
75
+ "#{report_dir}/rspec_dry_run_json_report_node_#{KnapsackPro::Config::Env.ci_node_index}.json"
74
76
  end
75
77
 
76
78
  def adapter_class
@@ -86,11 +88,12 @@ module KnapsackPro
86
88
  end
87
89
 
88
90
  def ensure_report_dir_exists
89
- FileUtils.mkdir_p(REPORT_DIR)
91
+ KnapsackPro::Config::TempFiles.ensure_temp_directory_exists!
92
+ FileUtils.mkdir_p(report_dir)
90
93
  end
91
94
 
92
95
  def remove_old_json_report
93
- File.delete(report_path) if File.exists?(report_path)
96
+ File.delete(report_path) if File.exist?(report_path)
94
97
  end
95
98
 
96
99
  def test_file_hash_for(test_file_path)
@@ -6,16 +6,23 @@ module KnapsackPro
6
6
  # to better allocate it in Queue Mode for future CI build runs
7
7
  DEFAULT_TEST_FILE_TIME = 0.0 # seconds
8
8
 
9
- attr_reader :global_time_since_beginning, :global_time, :test_files_with_time
9
+ attr_reader :global_time_since_beginning, :global_time, :test_files_with_time, :prerun_tests_loaded
10
10
  attr_writer :current_test_path
11
11
 
12
12
  def initialize
13
13
  @global_time_since_beginning = 0
14
+ KnapsackPro::Config::TempFiles.ensure_temp_directory_exists!
15
+ FileUtils.mkdir_p(tracker_dir_path)
14
16
  set_defaults
15
17
  end
16
18
 
17
19
  def reset!
18
20
  set_defaults
21
+
22
+ # Remove report only when the reset! method is called explicitly.
23
+ # The report should be persisted on the disk so that multiple tracker instances can share the report state.
24
+ # Tracker instance can be created by knapsack_pro process and a separate tracker is created by rake task (e.g., RSpec) in Regular Mode.
25
+ File.delete(prerun_tests_report_path) if File.exist?(prerun_tests_report_path)
19
26
  end
20
27
 
21
28
  def start_timer
@@ -54,9 +61,18 @@ module KnapsackPro
54
61
  measured_time: false,
55
62
  }
56
63
  end
64
+
65
+ save_prerun_tests_report(@test_files_with_time)
66
+
67
+ @prerun_tests_loaded = true
57
68
  end
58
69
 
59
70
  def to_a
71
+ # When the test files are not loaded in the memory then load them from the disk.
72
+ # Useful for the Regular Mode when the memory is not shared between tracker instances.
73
+ # Tracker instance can be created by knapsack_pro process and a separate tracker is created by rake task (e.g., RSpec)
74
+ load_prerun_tests unless prerun_tests_loaded
75
+
60
76
  test_files = []
61
77
  @test_files_with_time.each do |path, hash|
62
78
  test_files << {
@@ -73,6 +89,45 @@ module KnapsackPro
73
89
  @global_time = 0
74
90
  @test_files_with_time = {}
75
91
  @current_test_path = nil
92
+ @prerun_tests_loaded = false
93
+ end
94
+
95
+ def tracker_dir_path
96
+ "#{KnapsackPro::Config::TempFiles::TEMP_DIRECTORY_PATH}/tracker"
97
+ end
98
+
99
+ def prerun_tests_report_path
100
+ raise 'Test runner adapter not set. Report a bug to the Knapsack Pro support.' unless KnapsackPro::Config::Env.test_runner_adapter
101
+ report_name = "prerun_tests_#{KnapsackPro::Config::Env.test_runner_adapter}_node_#{KnapsackPro::Config::Env.ci_node_index}.json"
102
+ File.join(tracker_dir_path, report_name)
103
+ end
104
+
105
+ def save_prerun_tests_report(hash)
106
+ report_json = JSON.pretty_generate(hash)
107
+
108
+ File.open(prerun_tests_report_path, 'w+') do |f|
109
+ f.write(report_json)
110
+ end
111
+ end
112
+
113
+ def read_prerun_tests_report
114
+ raise "Report #{prerun_tests_report_path} doest not exist on the disk. Most likely, it was removed accidentally. Please report the bug to the Knapsack Pro support team at https://knapsackpro.com/contact" unless File.exist?(prerun_tests_report_path)
115
+ JSON.parse(File.read(prerun_tests_report_path))
116
+ end
117
+
118
+ def load_prerun_tests
119
+ read_prerun_tests_report.each do |test_file_path, hash|
120
+ # Load only test files that were not measured. For example,
121
+ # track test files assigned to CI node but never executed by test runner (e.g., pending RSpec spec files).
122
+ next if @test_files_with_time.key?(test_file_path)
123
+
124
+ @test_files_with_time[test_file_path] = {
125
+ time_execution: hash.fetch('time_execution'),
126
+ measured_time: hash.fetch('measured_time'),
127
+ }
128
+ end
129
+
130
+ @prerun_tests_loaded = true
76
131
  end
77
132
 
78
133
  def update_global_time(execution_time)
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '2.18.1'
2
+ VERSION = '3.1.1'
3
3
  end
data/lib/knapsack_pro.rb CHANGED
@@ -27,6 +27,7 @@ require_relative 'knapsack_pro/config/ci/github_actions'
27
27
  require_relative 'knapsack_pro/config/ci/heroku'
28
28
  require_relative 'knapsack_pro/config/env'
29
29
  require_relative 'knapsack_pro/config/env_generator'
30
+ require_relative 'knapsack_pro/config/temp_files'
30
31
  require_relative 'knapsack_pro/logger_wrapper'
31
32
  require_relative 'knapsack_pro/client/api/action'
32
33
  require_relative 'knapsack_pro/client/api/v1/base'
@@ -32,14 +32,13 @@ describe KnapsackPro::Adapters::BaseAdapter do
32
32
  context 'when CI node index 0' do
33
33
  let(:ci_node_index) { 0 }
34
34
 
35
- it { expect(subject).to eq 'tmp/knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt' }
36
-
35
+ it { expect(subject).to eq '.knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt' }
37
36
  end
38
37
 
39
38
  context 'when CI node index 1' do
40
39
  let(:ci_node_index) { 1 }
41
40
 
42
- it { expect(subject).to eq 'tmp/knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_1.txt' }
41
+ it { expect(subject).to eq '.knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_1.txt' }
43
42
  end
44
43
  end
45
44
 
@@ -93,18 +92,20 @@ describe KnapsackPro::Adapters::BaseAdapter do
93
92
  end
94
93
 
95
94
  describe '.verify_bind_method_called' do
95
+ let(:temp_directory_path) { '.knapsack_pro' }
96
+
96
97
  subject { described_class.verify_bind_method_called }
97
98
 
98
99
  before do
99
100
  expect(::Kernel).to receive(:at_exit).and_yield
100
- expect(File).to receive(:exists?).with('tmp/knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt').and_return(adapter_bind_method_called_file_exists)
101
+ expect(File).to receive(:exist?).with('.knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt').and_return(adapter_bind_method_called_file_exists)
101
102
  end
102
103
 
103
104
  context 'when adapter bind method called' do
104
105
  let(:adapter_bind_method_called_file_exists) { true }
105
106
 
106
107
  it do
107
- expect(File).to receive(:delete).with('tmp/knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt')
108
+ expect(File).to receive(:delete).with('.knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt')
108
109
  subject
109
110
  end
110
111
  end
@@ -120,12 +121,13 @@ describe KnapsackPro::Adapters::BaseAdapter do
120
121
  end
121
122
 
122
123
  describe '#bind' do
124
+ let(:temp_directory_path) { '.knapsack_pro' }
123
125
  let(:recording_enabled?) { false }
124
126
  let(:queue_recording_enabled?) { false }
125
127
 
126
128
  before do
127
- expect(FileUtils).to receive(:mkdir_p).with('tmp/knapsack_pro')
128
- expect(File).to receive(:write).with('tmp/knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt', nil)
129
+ expect(KnapsackPro::Config::TempFiles).to receive(:ensure_temp_directory_exists!)
130
+ expect(File).to receive(:write).with('.knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt', nil)
129
131
 
130
132
  expect(KnapsackPro::Config::Env).to receive(:recording_enabled?).and_return(recording_enabled?)
131
133
  expect(KnapsackPro::Config::Env).to receive(:queue_recording_enabled?).and_return(queue_recording_enabled?)
@@ -111,7 +111,7 @@ describe KnapsackPro::Adapters::RSpecAdapter do
111
111
  end
112
112
 
113
113
  describe '.test_path' do
114
- let(:current_example_metadata) do
114
+ let(:example_group) do
115
115
  {
116
116
  file_path: '1_shared_example.rb',
117
117
  parent_example_group: {
@@ -122,14 +122,19 @@ describe KnapsackPro::Adapters::RSpecAdapter do
122
122
  }
123
123
  }
124
124
  end
125
+ let(:current_example) do
126
+ OpenStruct.new(metadata: {
127
+ example_group: example_group
128
+ })
129
+ end
125
130
 
126
- subject { described_class.test_path(current_example_metadata) }
131
+ subject { described_class.test_path(current_example) }
127
132
 
128
133
  it { should eql 'a_spec.rb' }
129
134
 
130
135
  context 'with turnip features' do
131
136
  describe 'when the turnip version is less than 2' do
132
- let(:current_example_metadata) do
137
+ let(:example_group) do
133
138
  {
134
139
  file_path: "./spec/features/logging_in.feature",
135
140
  turnip: true,
@@ -145,7 +150,7 @@ describe KnapsackPro::Adapters::RSpecAdapter do
145
150
  end
146
151
 
147
152
  describe 'when turnip is version 2 or greater' do
148
- let(:current_example_metadata) do
153
+ let(:example_group) do
149
154
  {
150
155
  file_path: "gems/turnip-2.0.0/lib/turnip/rspec.rb",
151
156
  turnip: true,
@@ -170,13 +175,7 @@ describe KnapsackPro::Adapters::RSpecAdapter do
170
175
  let(:logger) { instance_double(Logger) }
171
176
  let(:global_time) { 'Global time: 01m 05s' }
172
177
  let(:test_path) { 'spec/a_spec.rb' }
173
- let(:example) { double }
174
- let(:example_group) { double }
175
- let(:current_example) do
176
- OpenStruct.new(metadata: {
177
- example_group: example_group
178
- })
179
- end
178
+ let(:current_example) { double }
180
179
 
181
180
  context 'when rspec split by test examples is disabled' do
182
181
  before do
@@ -189,19 +188,18 @@ describe KnapsackPro::Adapters::RSpecAdapter do
189
188
  allow(KnapsackPro).to receive(:tracker).and_return(tracker)
190
189
  expect(tracker).to receive(:start_timer).ordered
191
190
 
192
- expect(config).to receive(:around).with(:each).and_yield(example)
191
+ expect(config).to receive(:around).with(:each).and_yield(current_example)
193
192
  expect(config).to receive(:append_after).with(:context).and_yield
194
193
  expect(config).to receive(:after).with(:suite).and_yield
195
194
  expect(::RSpec).to receive(:configure).and_yield(config)
196
195
 
197
196
  expect(tracker).to receive(:stop_timer).ordered
198
197
 
199
- expect(::RSpec).to receive(:current_example).twice.and_return(current_example)
200
- expect(described_class).to receive(:test_path).with(example_group).and_return(test_path)
198
+ expect(described_class).to receive(:test_path).with(current_example).and_return(test_path)
201
199
 
202
200
  expect(tracker).to receive(:current_test_path=).with(test_path).ordered
203
201
 
204
- expect(example).to receive(:run)
202
+ expect(current_example).to receive(:run)
205
203
 
206
204
  expect(tracker).to receive(:stop_timer).ordered
207
205
 
@@ -226,26 +224,25 @@ describe KnapsackPro::Adapters::RSpecAdapter do
226
224
  end
227
225
 
228
226
  it 'records time for example.id' do
229
- expect(example).to receive(:id).and_return(test_example_path)
227
+ expect(current_example).to receive(:id).and_return(test_example_path)
230
228
 
231
229
  expect(config).to receive(:prepend_before).with(:context).and_yield
232
230
 
233
231
  allow(KnapsackPro).to receive(:tracker).and_return(tracker)
234
232
  expect(tracker).to receive(:start_timer).ordered
235
233
 
236
- expect(config).to receive(:around).with(:each).and_yield(example)
234
+ expect(config).to receive(:around).with(:each).and_yield(current_example)
237
235
  expect(config).to receive(:append_after).with(:context).and_yield
238
236
  expect(config).to receive(:after).with(:suite).and_yield
239
237
  expect(::RSpec).to receive(:configure).and_yield(config)
240
238
 
241
239
  expect(tracker).to receive(:stop_timer).ordered
242
240
 
243
- expect(::RSpec).to receive(:current_example).twice.and_return(current_example)
244
- expect(described_class).to receive(:test_path).with(example_group).and_return(test_path)
241
+ expect(described_class).to receive(:test_path).with(current_example).and_return(test_path)
245
242
 
246
243
  expect(tracker).to receive(:current_test_path=).with(test_example_path).ordered
247
244
 
248
- expect(example).to receive(:run)
245
+ expect(current_example).to receive(:run)
249
246
 
250
247
  expect(tracker).to receive(:stop_timer).ordered
251
248
 
@@ -268,19 +265,18 @@ describe KnapsackPro::Adapters::RSpecAdapter do
268
265
  allow(KnapsackPro).to receive(:tracker).and_return(tracker)
269
266
  expect(tracker).to receive(:start_timer).ordered
270
267
 
271
- expect(config).to receive(:around).with(:each).and_yield(example)
268
+ expect(config).to receive(:around).with(:each).and_yield(current_example)
272
269
  expect(config).to receive(:append_after).with(:context).and_yield
273
270
  expect(config).to receive(:after).with(:suite).and_yield
274
271
  expect(::RSpec).to receive(:configure).and_yield(config)
275
272
 
276
- expect(::RSpec).to receive(:current_example).twice.and_return(current_example)
277
- expect(described_class).to receive(:test_path).with(example_group).and_return(test_path)
273
+ expect(described_class).to receive(:test_path).with(current_example).and_return(test_path)
278
274
 
279
275
  expect(tracker).to receive(:stop_timer).ordered
280
276
 
281
277
  expect(tracker).to receive(:current_test_path=).with(test_path).ordered
282
278
 
283
- expect(example).to receive(:run)
279
+ expect(current_example).to receive(:run)
284
280
 
285
281
  expect(tracker).to receive(:stop_timer).ordered
286
282
 
@@ -950,4 +950,29 @@ describe KnapsackPro::Config::Env do
950
950
  it { should be_nil }
951
951
  end
952
952
  end
953
+
954
+ describe '.test_runner_adapter' do
955
+ subject { described_class.test_runner_adapter }
956
+
957
+ context 'when ENV exists' do
958
+ let(:test_runner_adapter) { 'RSpecAdapter' }
959
+ before { stub_const('ENV', { 'KNAPSACK_PRO_TEST_RUNNER_ADAPTER' => test_runner_adapter }) }
960
+ it { should eql 'RSpecAdapter' }
961
+ end
962
+
963
+ context "when ENV doesn't exist" do
964
+ it { should be_nil }
965
+ end
966
+ end
967
+
968
+ describe '.set_test_runner_adapter' do
969
+ let(:adapter_class) { KnapsackPro::Adapters::RSpecAdapter }
970
+
971
+ subject { described_class.set_test_runner_adapter(adapter_class) }
972
+
973
+ it 'sets test runner adapter' do
974
+ subject
975
+ expect(described_class.test_runner_adapter).to eql 'RSpecAdapter'
976
+ end
977
+ end
953
978
  end
@@ -0,0 +1,25 @@
1
+ describe KnapsackPro::Config::TempFiles do
2
+ describe 'TEMP_DIRECTORY_PATH' do
3
+ subject { described_class::TEMP_DIRECTORY_PATH }
4
+
5
+ it 'returns temporary directory path' do
6
+ expect(subject).to eq '.knapsack_pro'
7
+ end
8
+ end
9
+
10
+ describe '.ensure_temp_directory_exists!', :clear_tmp do
11
+ let(:gitignore_file_path) { '.knapsack_pro/.gitignore' }
12
+
13
+ subject { described_class.ensure_temp_directory_exists! }
14
+
15
+ it 'creates .gitignore file' do
16
+ expect { subject }.to change { File.exist?(gitignore_file_path) }.from(false).to(true)
17
+ end
18
+
19
+ it '.gitignore file has correct content to ignore all files in temporary directory' do
20
+ subject
21
+
22
+ expect(File.read(gitignore_file_path)).to match /^\*$/
23
+ end
24
+ end
25
+ end
@@ -25,6 +25,8 @@ describe KnapsackPro::Report do
25
25
  subset_queue_id = 'fake-subset-queue-id'
26
26
  expect(KnapsackPro::Config::Env).to receive(:subset_queue_id).and_return(subset_queue_id)
27
27
 
28
+ expect(KnapsackPro::Config::TempFiles).to receive(:ensure_temp_directory_exists!)
29
+
28
30
  queue_id = 'fake-queue-id'
29
31
  expect(KnapsackPro::Config::Env).to receive(:queue_id).twice.and_return(queue_id)
30
32
  end
@@ -34,7 +36,7 @@ describe KnapsackPro::Report do
34
36
 
35
37
  expect(
36
38
  JSON.parse(
37
- File.read('tmp/knapsack_pro/queue/fake-queue-id/fake-subset-queue-id.json')
39
+ File.read('.knapsack_pro/queue/fake-queue-id/fake-subset-queue-id.json')
38
40
  )
39
41
  ).to eq([
40
42
  { 'path' => fake_path }
@@ -56,7 +58,7 @@ describe KnapsackPro::Report do
56
58
  queue_id = 'fake-queue-id'
57
59
  expect(KnapsackPro::Config::Env).to receive(:queue_id).and_return(queue_id)
58
60
 
59
- expect(Dir).to receive(:glob).with('tmp/knapsack_pro/queue/fake-queue-id/*.json').and_return([
61
+ expect(Dir).to receive(:glob).with('.knapsack_pro/queue/fake-queue-id/*.json').and_return([
60
62
  json_test_file_a_path,
61
63
  json_test_file_b_path
62
64
  ])
@@ -89,7 +91,7 @@ describe KnapsackPro::Report do
89
91
  queue_id = 'fake-queue-id'
90
92
  expect(KnapsackPro::Config::Env).to receive(:queue_id).and_return(queue_id)
91
93
 
92
- expect(Dir).to receive(:glob).with('tmp/knapsack_pro/queue/fake-queue-id/*.json').and_return([
94
+ expect(Dir).to receive(:glob).with('.knapsack_pro/queue/fake-queue-id/*.json').and_return([
93
95
  json_test_file_a_path,
94
96
  json_test_file_b_path
95
97
  ])
@@ -102,9 +104,9 @@ describe KnapsackPro::Report do
102
104
  logger = instance_double(Logger)
103
105
  expect(KnapsackPro).to receive(:logger).exactly(4).and_return(logger)
104
106
  expect(logger).to receive(:warn).with('2 test files were executed on this CI node but the recorded time was lost due to:')
105
- expect(logger).to receive(:warn).with('1. Probably you have a code (i.e. RSpec hooks) that clears tmp directory in your project. Please ensure you do not remove the content of tmp/knapsack_pro/queue/ directory between tests run.')
106
- expect(logger).to receive(:warn).with('2. Another reason might be that you forgot to add Knapsack::Adapters::RSpecAdapter.bind in your rails_helper.rb or spec_helper.rb. Please follow the installation guide again: https://docs.knapsackpro.com/integration/')
107
- expect(logger).to receive(:warn).with('3. All your tests are empty test files, are pending tests or have syntax error and could not be executed hence no measured time execution by knapsack_pro.')
107
+ expect(logger).to receive(:warn).with('1. Please ensure you do not remove the contents of the .knapsack_pro directory between tests run.')
108
+ expect(logger).to receive(:warn).with("2. Ensure you've added Knapsack::Adapters::RSpecAdapter.bind in your rails_helper.rb or spec_helper.rb. Please follow the installation guide again: https://docs.knapsackpro.com/integration/")
109
+ expect(logger).to receive(:warn).with('3. Another potential reason for this warning is that all your tests are empty test files, pending tests, or they have syntax errors, and the time execution was not recorded for them.')
108
110
 
109
111
  expect(described_class).to receive(:create_build_subset).with(
110
112
  json_test_file_a + json_test_file_b
@@ -121,15 +123,14 @@ describe KnapsackPro::Report do
121
123
  queue_id = 'fake-queue-id'
122
124
  expect(KnapsackPro::Config::Env).to receive(:queue_id).and_return(queue_id)
123
125
 
124
- expect(Dir).to receive(:glob).with('tmp/knapsack_pro/queue/fake-queue-id/*.json').and_return([])
126
+ expect(Dir).to receive(:glob).with('.knapsack_pro/queue/fake-queue-id/*.json').and_return([])
125
127
  end
126
128
 
127
129
  it 'logs warning about reasons why no test files were executed on this CI node' do
128
130
  logger = instance_double(Logger)
129
- expect(KnapsackPro).to receive(:logger).exactly(3).and_return(logger)
131
+ expect(KnapsackPro).to receive(:logger).exactly(2).and_return(logger)
130
132
  expect(logger).to receive(:warn).with('No test files were executed on this CI node.')
131
- expect(logger).to receive(:debug).with('When you use knapsack_pro queue mode then probably reason might be that CI node was started after the test files from the queue were already executed by other CI nodes. That is why this CI node has no test files to execute.')
132
- expect(logger).to receive(:debug).with("Another reason might be when your CI node failed in a way that prevented knapsack_pro to save time execution data to Knapsack Pro API and you have just tried to retry failed CI node but instead you got no test files to execute. In that case knapsack_pro don't know what tests should be executed here.")
133
+ expect(logger).to receive(:debug).with('This CI node likely started work late after the test files were already executed by other CI nodes consuming the queue.')
133
134
 
134
135
  expect(described_class).to receive(:create_build_subset).with([])
135
136