knapsack_pro 2.18.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.gitignore +1 -0
- data/CHANGELOG.md +33 -0
- data/README.md +3 -3
- data/knapsack_pro.gemspec +1 -1
- data/lib/knapsack_pro.rb +1 -0
- data/lib/knapsack_pro/adapters/base_adapter.rb +4 -4
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +5 -10
- data/lib/knapsack_pro/base_allocator_builder.rb +1 -0
- data/lib/knapsack_pro/config/env.rb +8 -1
- data/lib/knapsack_pro/config/temp_files.rb +38 -0
- data/lib/knapsack_pro/report.rb +7 -8
- data/lib/knapsack_pro/runners/cucumber_runner.rb +3 -0
- data/lib/knapsack_pro/runners/minitest_runner.rb +3 -0
- data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +3 -1
- data/lib/knapsack_pro/runners/queue/minitest_runner.rb +3 -1
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +1 -0
- data/lib/knapsack_pro/runners/rspec_runner.rb +3 -0
- data/lib/knapsack_pro/runners/spinach_runner.rb +3 -0
- data/lib/knapsack_pro/runners/test_unit_runner.rb +3 -0
- data/lib/knapsack_pro/slow_test_file_determiner.rb +8 -4
- data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +9 -6
- data/lib/knapsack_pro/tracker.rb +56 -1
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/adapters/base_adapter_spec.rb +9 -7
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +20 -24
- data/spec/knapsack_pro/config/env_spec.rb +25 -0
- data/spec/knapsack_pro/config/temp_files_spec.rb +25 -0
- data/spec/knapsack_pro/report_spec.rb +11 -10
- data/spec/knapsack_pro/runners/cucumber_runner_spec.rb +9 -1
- data/spec/knapsack_pro/runners/minitest_runner_spec.rb +6 -1
- data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +2 -0
- data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +2 -0
- data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +2 -0
- data/spec/knapsack_pro/runners/rspec_runner_spec.rb +9 -1
- data/spec/knapsack_pro/runners/spinach_runner_spec.rb +9 -1
- data/spec/knapsack_pro/runners/test_unit_runner_spec.rb +6 -1
- data/spec/knapsack_pro/slow_test_file_determiner_spec.rb +2 -2
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +8 -6
- data/spec/knapsack_pro/tracker_spec.rb +67 -2
- data/spec/spec_helper.rb +5 -2
- metadata +6 -9
@@ -18,16 +18,20 @@ describe KnapsackPro::Runners::CucumberRunner do
|
|
18
18
|
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_TEST_SUITE_TOKEN', test_suite_token_cucumber)
|
19
19
|
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_RECORDING_ENABLED', 'true')
|
20
20
|
|
21
|
+
expect(KnapsackPro::Config::Env).to receive(:set_test_runner_adapter).with(KnapsackPro::Adapters::CucumberAdapter)
|
22
|
+
|
21
23
|
expect(described_class).to receive(:new)
|
22
24
|
.with(KnapsackPro::Adapters::CucumberAdapter).and_return(runner)
|
23
25
|
end
|
24
26
|
|
25
27
|
context 'when test files were returned by Knapsack Pro API' do
|
26
28
|
let(:test_dir) { 'fake-test-dir' }
|
27
|
-
let(:
|
29
|
+
let(:test_file_paths) { ['features/fake1.scenario', 'features/fake2.scenario'] }
|
30
|
+
let(:stringify_test_file_paths) { test_file_paths.join(' ') }
|
28
31
|
let(:runner) do
|
29
32
|
instance_double(described_class,
|
30
33
|
test_dir: test_dir,
|
34
|
+
test_file_paths: test_file_paths,
|
31
35
|
stringify_test_file_paths: stringify_test_file_paths,
|
32
36
|
test_files_to_execute_exist?: true)
|
33
37
|
end
|
@@ -36,6 +40,10 @@ describe KnapsackPro::Runners::CucumberRunner do
|
|
36
40
|
before do
|
37
41
|
expect(KnapsackPro::Adapters::CucumberAdapter).to receive(:verify_bind_method_called)
|
38
42
|
|
43
|
+
tracker = instance_double(KnapsackPro::Tracker)
|
44
|
+
expect(KnapsackPro).to receive(:tracker).and_return(tracker)
|
45
|
+
expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
|
46
|
+
|
39
47
|
expect(Rake::Task).to receive(:[]).with('knapsack_pro:cucumber_run').at_least(1).and_return(task)
|
40
48
|
|
41
49
|
t = double
|
@@ -14,12 +14,17 @@ describe KnapsackPro::Runners::MinitestRunner do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
context 'when test files were returned by Knapsack Pro API' do
|
17
|
+
let(:test_file_paths) { ['test_fake/a_test.rb', 'test_fake/b_test.rb'] }
|
18
|
+
|
17
19
|
before do
|
18
20
|
expect(KnapsackPro::Adapters::MinitestAdapter).to receive(:verify_bind_method_called)
|
21
|
+
|
22
|
+
tracker = instance_double(KnapsackPro::Tracker)
|
23
|
+
expect(KnapsackPro).to receive(:tracker).and_return(tracker)
|
24
|
+
expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
|
19
25
|
end
|
20
26
|
|
21
27
|
it 'runs tests' do
|
22
|
-
test_file_paths = ['test_fake/a_test.rb', 'test_fake/b_test.rb']
|
23
28
|
runner = instance_double(described_class,
|
24
29
|
test_dir: 'test',
|
25
30
|
test_file_paths: test_file_paths,
|
@@ -19,6 +19,8 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
|
|
19
19
|
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_QUEUE_RECORDING_ENABLED', 'true')
|
20
20
|
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_QUEUE_ID', queue_id)
|
21
21
|
|
22
|
+
expect(KnapsackPro::Config::Env).to receive(:set_test_runner_adapter).with(KnapsackPro::Adapters::CucumberAdapter)
|
23
|
+
|
22
24
|
expect(described_class).to receive(:new).with(KnapsackPro::Adapters::CucumberAdapter).and_return(runner)
|
23
25
|
end
|
24
26
|
|
@@ -19,6 +19,8 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
|
|
19
19
|
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_QUEUE_RECORDING_ENABLED', 'true')
|
20
20
|
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_QUEUE_ID', queue_id)
|
21
21
|
|
22
|
+
expect(KnapsackPro::Config::Env).to receive(:set_test_runner_adapter).with(KnapsackPro::Adapters::MinitestAdapter)
|
23
|
+
|
22
24
|
expect(described_class).to receive(:new).with(KnapsackPro::Adapters::MinitestAdapter).and_return(runner)
|
23
25
|
|
24
26
|
expect($LOAD_PATH).to receive(:unshift).with(test_dir)
|
@@ -26,6 +26,8 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
|
|
26
26
|
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_QUEUE_RECORDING_ENABLED', 'true')
|
27
27
|
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_QUEUE_ID', queue_id)
|
28
28
|
|
29
|
+
expect(KnapsackPro::Config::Env).to receive(:set_test_runner_adapter).with(KnapsackPro::Adapters::RSpecAdapter)
|
30
|
+
|
29
31
|
expect(described_class).to receive(:new).with(KnapsackPro::Adapters::RSpecAdapter).and_return(runner)
|
30
32
|
end
|
31
33
|
|
@@ -18,16 +18,20 @@ describe KnapsackPro::Runners::RSpecRunner do
|
|
18
18
|
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_TEST_SUITE_TOKEN', test_suite_token_rspec)
|
19
19
|
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_RECORDING_ENABLED', 'true')
|
20
20
|
|
21
|
+
expect(KnapsackPro::Config::Env).to receive(:set_test_runner_adapter).with(KnapsackPro::Adapters::RSpecAdapter)
|
22
|
+
|
21
23
|
expect(described_class).to receive(:new)
|
22
24
|
.with(KnapsackPro::Adapters::RSpecAdapter).and_return(runner)
|
23
25
|
end
|
24
26
|
|
25
27
|
context 'when test files were returned by Knapsack Pro API' do
|
26
28
|
let(:test_dir) { 'fake-test-dir' }
|
27
|
-
let(:
|
29
|
+
let(:test_file_paths) { ['spec/a_spec.rb', 'spec/b_spec.rb[1:1]'] }
|
30
|
+
let(:stringify_test_file_paths) { test_file_paths.join(' ') }
|
28
31
|
let(:runner) do
|
29
32
|
instance_double(described_class,
|
30
33
|
test_dir: test_dir,
|
34
|
+
test_file_paths: test_file_paths,
|
31
35
|
stringify_test_file_paths: stringify_test_file_paths,
|
32
36
|
test_files_to_execute_exist?: true)
|
33
37
|
end
|
@@ -37,6 +41,10 @@ describe KnapsackPro::Runners::RSpecRunner do
|
|
37
41
|
expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:verify_bind_method_called).ordered
|
38
42
|
expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!).with(['--profile', '--color']).ordered
|
39
43
|
|
44
|
+
tracker = instance_double(KnapsackPro::Tracker)
|
45
|
+
expect(KnapsackPro).to receive(:tracker).and_return(tracker)
|
46
|
+
expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
|
47
|
+
|
40
48
|
expect(Rake::Task).to receive(:[]).with('knapsack_pro:rspec_run').at_least(1).and_return(task)
|
41
49
|
|
42
50
|
t = double
|
@@ -11,16 +11,20 @@ describe KnapsackPro::Runners::SpinachRunner do
|
|
11
11
|
before do
|
12
12
|
stub_const("ENV", { 'KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH' => 'spinach-token' })
|
13
13
|
|
14
|
+
expect(KnapsackPro::Config::Env).to receive(:set_test_runner_adapter).with(KnapsackPro::Adapters::SpinachAdapter)
|
15
|
+
|
14
16
|
expect(described_class).to receive(:new)
|
15
17
|
.with(KnapsackPro::Adapters::SpinachAdapter).and_return(runner)
|
16
18
|
end
|
17
19
|
|
18
20
|
context 'when test files were returned by Knapsack Pro API' do
|
19
|
-
let(:
|
21
|
+
let(:test_file_paths) { ['features/a.feature', 'features/b.feature'] }
|
22
|
+
let(:stringify_test_file_paths) { test_file_paths.join(' ') }
|
20
23
|
let(:test_dir) { 'fake-test-dir' }
|
21
24
|
let(:runner) do
|
22
25
|
instance_double(described_class,
|
23
26
|
test_dir: test_dir,
|
27
|
+
test_file_paths: test_file_paths,
|
24
28
|
stringify_test_file_paths: stringify_test_file_paths,
|
25
29
|
test_files_to_execute_exist?: true)
|
26
30
|
end
|
@@ -29,6 +33,10 @@ describe KnapsackPro::Runners::SpinachRunner do
|
|
29
33
|
before do
|
30
34
|
expect(KnapsackPro::Adapters::SpinachAdapter).to receive(:verify_bind_method_called)
|
31
35
|
|
36
|
+
tracker = instance_double(KnapsackPro::Tracker)
|
37
|
+
expect(KnapsackPro).to receive(:tracker).and_return(tracker)
|
38
|
+
expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
|
39
|
+
|
32
40
|
expect(Kernel).to receive(:system).with('KNAPSACK_PRO_RECORDING_ENABLED=true KNAPSACK_PRO_TEST_SUITE_TOKEN=spinach-token bundle exec spinach --custom-arg --features_path fake-test-dir -- features/a.feature features/b.feature')
|
33
41
|
|
34
42
|
allow(described_class).to receive(:child_status).and_return(child_status)
|
@@ -13,10 +13,15 @@ describe KnapsackPro::Runners::TestUnitRunner do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'when test files were returned by Knapsack Pro API' do
|
16
|
+
let(:test_file_paths) { ['test-unit_fake/a_test.rb', 'test-unit_fake/b_test.rb'] }
|
17
|
+
|
16
18
|
it 'runs tests' do
|
17
19
|
expect(KnapsackPro::Adapters::TestUnitAdapter).to receive(:verify_bind_method_called)
|
18
20
|
|
19
|
-
|
21
|
+
tracker = instance_double(KnapsackPro::Tracker)
|
22
|
+
expect(KnapsackPro).to receive(:tracker).and_return(tracker)
|
23
|
+
expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
|
24
|
+
|
20
25
|
runner = instance_double(described_class,
|
21
26
|
test_dir: 'test-unit_fake',
|
22
27
|
test_file_paths: test_file_paths,
|
@@ -27,7 +27,7 @@ describe KnapsackPro::SlowTestFileDeterminer do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe '.save_to_json_report', :clear_tmp do
|
30
|
-
let(:json_report_path) { '
|
30
|
+
let(:json_report_path) { '.knapsack_pro/slow_test_file_determiner/slow_test_files_node_0.json' }
|
31
31
|
let(:test_files) do
|
32
32
|
[
|
33
33
|
{ 'path' => 'a_spec.rb', 'time_execution' => 1.0 },
|
@@ -67,7 +67,7 @@ describe KnapsackPro::SlowTestFileDeterminer do
|
|
67
67
|
|
68
68
|
context 'when json report does not exist' do
|
69
69
|
it do
|
70
|
-
expect { subject }.to raise_error(RuntimeError, '
|
70
|
+
expect { subject }.to raise_error(RuntimeError, 'The report with slow test files has not been generated yet. If you have enabled split by test cases https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases and you see this error it means that your tests accidentally cleaned up the .knapsack_pro directory. Please do not remove this directory during tests runtime!')
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
|
2
|
-
let(:report_dir) { '
|
3
|
-
let(:report_path) { '
|
2
|
+
let(:report_dir) { '.knapsack_pro/test_case_detectors/rspec' }
|
3
|
+
let(:report_path) { '.knapsack_pro/test_case_detectors/rspec/rspec_dry_run_json_report_node_0.json' }
|
4
4
|
let(:rspec_test_example_detector) { described_class.new }
|
5
5
|
|
6
6
|
describe '#generate_json_report' do
|
7
7
|
subject { rspec_test_example_detector.generate_json_report }
|
8
8
|
|
9
9
|
before do
|
10
|
+
expect(KnapsackPro::Config::TempFiles).to receive(:ensure_temp_directory_exists!)
|
11
|
+
|
10
12
|
expect(FileUtils).to receive(:mkdir_p).with(report_dir)
|
11
13
|
|
12
|
-
expect(File).to receive(:
|
14
|
+
expect(File).to receive(:exist?).with(report_path).and_return(true)
|
13
15
|
expect(File).to receive(:delete).with(report_path)
|
14
16
|
|
15
17
|
expect(rspec_test_example_detector).to receive(:slow_test_files).and_return(test_file_entities)
|
@@ -95,7 +97,7 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
|
|
95
97
|
|
96
98
|
context 'when JSON report exists' do
|
97
99
|
it do
|
98
|
-
expect(File).to receive(:
|
100
|
+
expect(File).to receive(:exist?).with(report_path).and_return(true)
|
99
101
|
|
100
102
|
json_file = {
|
101
103
|
'examples' => [
|
@@ -114,9 +116,9 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
|
|
114
116
|
|
115
117
|
context 'when JSON report does not exist' do
|
116
118
|
it do
|
117
|
-
expect(File).to receive(:
|
119
|
+
expect(File).to receive(:exist?).with(report_path).and_return(false)
|
118
120
|
|
119
|
-
expect { subject }.to raise_error(RuntimeError,
|
121
|
+
expect { subject }.to raise_error(RuntimeError, "No report found at .knapsack_pro/test_case_detectors/rspec/rspec_dry_run_json_report_node_0.json")
|
120
122
|
end
|
121
123
|
end
|
122
124
|
end
|
@@ -1,11 +1,18 @@
|
|
1
1
|
shared_examples 'default trakcer attributes' do
|
2
2
|
it { expect(tracker.global_time).to eql 0 }
|
3
3
|
it { expect(tracker.test_files_with_time).to eql({}) }
|
4
|
+
it { expect(tracker.prerun_tests_loaded).to be false }
|
4
5
|
end
|
5
6
|
|
6
7
|
describe KnapsackPro::Tracker do
|
8
|
+
let(:adapter) { 'RSpecAdapter' }
|
7
9
|
let(:tracker) { described_class.send(:new) }
|
8
10
|
|
11
|
+
before do
|
12
|
+
allow(KnapsackPro::Config::Env).to receive(:test_runner_adapter).and_return(adapter)
|
13
|
+
allow(KnapsackPro::Config::Env).to receive(:ci_node_index).and_return(0)
|
14
|
+
end
|
15
|
+
|
9
16
|
it_behaves_like 'default trakcer attributes'
|
10
17
|
|
11
18
|
describe '#current_test_path' do
|
@@ -34,6 +41,10 @@ describe KnapsackPro::Tracker do
|
|
34
41
|
let(:test_paths) { ['a_spec.rb', 'b_spec.rb'] }
|
35
42
|
let(:delta) { 0.02 }
|
36
43
|
|
44
|
+
before do
|
45
|
+
tracker.set_prerun_tests(test_paths)
|
46
|
+
end
|
47
|
+
|
37
48
|
shared_examples '#to_a' do
|
38
49
|
subject { tracker.to_a }
|
39
50
|
|
@@ -55,13 +66,14 @@ describe KnapsackPro::Tracker do
|
|
55
66
|
end
|
56
67
|
|
57
68
|
it { expect(tracker.global_time).to be_within(delta).of(0.3) }
|
69
|
+
it { expect(tracker.prerun_tests_loaded).to be true }
|
58
70
|
it { expect(tracker.test_files_with_time.keys.size).to eql 2 }
|
59
71
|
it { expect(tracker.test_files_with_time['a_spec.rb'][:time_execution]).to be_within(delta).of(0.1) }
|
60
72
|
it { expect(tracker.test_files_with_time['b_spec.rb'][:time_execution]).to be_within(delta).of(0.2) }
|
61
73
|
it_behaves_like '#to_a'
|
62
74
|
end
|
63
75
|
|
64
|
-
context "with Timecop - Timecop shouldn't have impact on measured test time" do
|
76
|
+
context "with Timecop - Timecop shouldn't have impact on the measured test time" do
|
65
77
|
let(:now) { Time.now }
|
66
78
|
|
67
79
|
before do
|
@@ -80,6 +92,7 @@ describe KnapsackPro::Tracker do
|
|
80
92
|
|
81
93
|
it { expect(tracker.global_time).to be > 0 }
|
82
94
|
it { expect(tracker.global_time).to be_within(delta).of(0) }
|
95
|
+
it { expect(tracker.prerun_tests_loaded).to be true }
|
83
96
|
it { expect(tracker.test_files_with_time.keys.size).to eql 2 }
|
84
97
|
it { expect(tracker.test_files_with_time['a_spec.rb'][:time_execution]).to be_within(delta).of(0) }
|
85
98
|
it { expect(tracker.test_files_with_time['b_spec.rb'][:time_execution]).to be_within(delta).of(0) }
|
@@ -96,6 +109,7 @@ describe KnapsackPro::Tracker do
|
|
96
109
|
end
|
97
110
|
|
98
111
|
it { expect(tracker.global_time).to be > 0 }
|
112
|
+
it { expect(tracker.prerun_tests_loaded).to be true }
|
99
113
|
it { expect(tracker.test_files_with_time.keys.size).to eql 2 }
|
100
114
|
it { expect(tracker.test_files_with_time['a_spec.rb'][:time_execution]).to eq 0 }
|
101
115
|
it '2nd spec (b_spec.rb) should have recorded time execution - because start_time was set during first call of stop_timer for the first spec (a_spec.rb)' do
|
@@ -103,15 +117,62 @@ describe KnapsackPro::Tracker do
|
|
103
117
|
end
|
104
118
|
it_behaves_like '#to_a'
|
105
119
|
end
|
120
|
+
|
121
|
+
context 'when a new tracker instance is created' do
|
122
|
+
let(:non_pending_test_paths) { ['a_spec.rb', 'b_spec.rb'] }
|
123
|
+
let(:test_paths) { non_pending_test_paths + ['pending_spec.rb'] }
|
124
|
+
|
125
|
+
before do
|
126
|
+
# measure tests only for non pending tests
|
127
|
+
non_pending_test_paths.each_with_index do |test_path, index|
|
128
|
+
tracker.current_test_path = test_path
|
129
|
+
tracker.start_timer
|
130
|
+
sleep index.to_f / 10 + 0.1
|
131
|
+
tracker.stop_timer
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
it '2nd tracker instance loads prerun tests from the disk' do
|
136
|
+
expect(tracker.prerun_tests_loaded).to be true
|
137
|
+
expect(tracker.to_a.size).to eq 3
|
138
|
+
expect(tracker.to_a[0][:path]).to eq 'a_spec.rb'
|
139
|
+
expect(tracker.to_a[0][:time_execution]).to be >= 0
|
140
|
+
expect(tracker.to_a[1][:path]).to eq 'b_spec.rb'
|
141
|
+
expect(tracker.to_a[1][:time_execution]).to be >= 0
|
142
|
+
expect(tracker.to_a[2][:path]).to eq 'pending_spec.rb'
|
143
|
+
expect(tracker.to_a[2][:time_execution]).to eq 0
|
144
|
+
|
145
|
+
tracker2 = described_class.send(:new)
|
146
|
+
expect(tracker2.prerun_tests_loaded).to be false
|
147
|
+
expect(tracker2.to_a.size).to eq 3
|
148
|
+
expect(tracker2.to_a[0][:path]).to eq 'a_spec.rb'
|
149
|
+
expect(tracker2.to_a[0][:time_execution]).to be >= 0
|
150
|
+
expect(tracker2.to_a[1][:path]).to eq 'b_spec.rb'
|
151
|
+
expect(tracker2.to_a[1][:time_execution]).to be >= 0
|
152
|
+
expect(tracker2.to_a[2][:path]).to eq 'pending_spec.rb'
|
153
|
+
expect(tracker2.to_a[2][:time_execution]).to eq 0
|
154
|
+
expect(tracker2.prerun_tests_loaded).to be true
|
155
|
+
end
|
156
|
+
end
|
106
157
|
end
|
107
158
|
|
108
159
|
describe '#reset!' do
|
160
|
+
let(:test_file_path) { 'a_spec.rb' }
|
161
|
+
|
109
162
|
before do
|
110
|
-
tracker.
|
163
|
+
tracker.set_prerun_tests([test_file_path])
|
164
|
+
end
|
165
|
+
|
166
|
+
before do
|
167
|
+
expect(tracker.prerun_tests_loaded).to be true
|
168
|
+
|
169
|
+
tracker.current_test_path = test_file_path
|
111
170
|
tracker.start_timer
|
112
171
|
sleep 0.1
|
113
172
|
tracker.stop_timer
|
173
|
+
|
114
174
|
expect(tracker.global_time).not_to eql 0
|
175
|
+
|
115
176
|
tracker.reset!
|
116
177
|
end
|
117
178
|
|
@@ -120,5 +181,9 @@ describe KnapsackPro::Tracker do
|
|
120
181
|
it "global time since beginning won't be reset" do
|
121
182
|
expect(tracker.global_time_since_beginning).to be >= 0.1
|
122
183
|
end
|
184
|
+
|
185
|
+
it 'resets prerun_tests_loaded to false' do
|
186
|
+
expect(tracker.prerun_tests_loaded).to be false
|
187
|
+
end
|
123
188
|
end
|
124
189
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,6 +16,8 @@ require 'knapsack_pro'
|
|
16
16
|
|
17
17
|
Dir["#{KnapsackPro.root}/spec/{support,fixtures}/**/*.rb"].each { |f| require f }
|
18
18
|
|
19
|
+
KNAPSACK_PRO_TMP_DIR = File.join(KnapsackPro.root, '.knapsack_pro')
|
20
|
+
|
19
21
|
RSpec.configure do |config|
|
20
22
|
config.order = :random
|
21
23
|
config.mock_with :rspec do |mocks|
|
@@ -29,13 +31,14 @@ RSpec.configure do |config|
|
|
29
31
|
|
30
32
|
config.before(:each) do
|
31
33
|
if RSpec.current_example.metadata[:clear_tmp]
|
32
|
-
FileUtils.
|
34
|
+
FileUtils.rm_r(KNAPSACK_PRO_TMP_DIR) if File.exist?(KNAPSACK_PRO_TMP_DIR)
|
35
|
+
FileUtils.mkdir_p(KNAPSACK_PRO_TMP_DIR)
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
36
39
|
config.after(:each) do
|
37
40
|
if RSpec.current_example.metadata[:clear_tmp]
|
38
|
-
FileUtils.rm_r(File.
|
41
|
+
FileUtils.rm_r(KNAPSACK_PRO_TMP_DIR) if File.exist?(KNAPSACK_PRO_TMP_DIR)
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knapsack_pro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -45,9 +45,6 @@ dependencies:
|
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.0'
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 2.10.0
|
51
48
|
type: :development
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -55,9 +52,6 @@ dependencies:
|
|
55
52
|
- - "~>"
|
56
53
|
- !ruby/object:Gem::Version
|
57
54
|
version: '3.0'
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 2.10.0
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: rspec-its
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -239,6 +233,7 @@ files:
|
|
239
233
|
- lib/knapsack_pro/config/ci/travis.rb
|
240
234
|
- lib/knapsack_pro/config/env.rb
|
241
235
|
- lib/knapsack_pro/config/env_generator.rb
|
236
|
+
- lib/knapsack_pro/config/temp_files.rb
|
242
237
|
- lib/knapsack_pro/crypto/branch_encryptor.rb
|
243
238
|
- lib/knapsack_pro/crypto/decryptor.rb
|
244
239
|
- lib/knapsack_pro/crypto/digestor.rb
|
@@ -334,6 +329,7 @@ files:
|
|
334
329
|
- spec/knapsack_pro/config/ci/travis_spec.rb
|
335
330
|
- spec/knapsack_pro/config/env_generator_spec.rb
|
336
331
|
- spec/knapsack_pro/config/env_spec.rb
|
332
|
+
- spec/knapsack_pro/config/temp_files_spec.rb
|
337
333
|
- spec/knapsack_pro/crypto/branch_encryptor_spec.rb
|
338
334
|
- spec/knapsack_pro/crypto/decryptor_spec.rb
|
339
335
|
- spec/knapsack_pro/crypto/digestor_spec.rb
|
@@ -409,7 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
409
405
|
- !ruby/object:Gem::Version
|
410
406
|
version: '0'
|
411
407
|
requirements: []
|
412
|
-
rubygems_version: 3.2.
|
408
|
+
rubygems_version: 3.2.22
|
413
409
|
signing_key:
|
414
410
|
specification_version: 4
|
415
411
|
summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
|
@@ -455,6 +451,7 @@ test_files:
|
|
455
451
|
- spec/knapsack_pro/config/ci/travis_spec.rb
|
456
452
|
- spec/knapsack_pro/config/env_generator_spec.rb
|
457
453
|
- spec/knapsack_pro/config/env_spec.rb
|
454
|
+
- spec/knapsack_pro/config/temp_files_spec.rb
|
458
455
|
- spec/knapsack_pro/crypto/branch_encryptor_spec.rb
|
459
456
|
- spec/knapsack_pro/crypto/decryptor_spec.rb
|
460
457
|
- spec/knapsack_pro/crypto/digestor_spec.rb
|