knapsack_pro 9.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/knapsack_pro/adapters/minitest_adapter.rb +8 -13
- data/lib/knapsack_pro/client/connection.rb +1 -1
- data/lib/knapsack_pro/config/env.rb +1 -24
- data/lib/knapsack_pro/version.rb +1 -1
- metadata +2 -196
- data/.circleci/config.yml +0 -468
- data/.github/assets/install-button.png +0 -0
- data/.github/assets/knapsack-diamonds.png +0 -0
- data/.github/dependabot.yml +0 -11
- data/.github/pull_request_template.md +0 -11
- data/.gitignore +0 -39
- data/.rspec +0 -5
- data/CHANGELOG.md +0 -1995
- data/Gemfile +0 -13
- data/LICENSE +0 -22
- data/README.md +0 -90
- data/Rakefile +0 -2
- data/knapsack_pro.gemspec +0 -43
- data/spec/fixtures/test_file_list_source_file.txt +0 -6
- data/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/invalid_test_suite_token.yml +0 -59
- data/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/success.yml +0 -61
- data/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/invalid_test_suite_token.yml +0 -50
- data/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/success.yml +0 -50
- data/spec/integration/api/build_distributions_subset_spec.rb +0 -77
- data/spec/integration/api/build_subsets_create_spec.rb +0 -77
- data/spec/integration/runners/fallback_spec.rb +0 -131
- data/spec/integration/runners/queue/cucumber_runner_fallback_spec.rb +0 -129
- data/spec/integration/runners/queue/minitest_runner_fallback_spec.rb +0 -129
- data/spec/integration/runners/queue/rspec_runner.rb +0 -80
- data/spec/integration/runners/queue/rspec_runner_fallback_spec.rb +0 -137
- data/spec/integration/runners/queue/rspec_runner_spec.rb +0 -2672
- data/spec/knapsack_pro/adapters/base_adapter_spec.rb +0 -221
- data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +0 -216
- data/spec/knapsack_pro/adapters/minitest_adapter_spec.rb +0 -189
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +0 -427
- data/spec/knapsack_pro/adapters/spinach_adapter_spec.rb +0 -61
- data/spec/knapsack_pro/adapters/test_unit_adapter_spec.rb +0 -86
- data/spec/knapsack_pro/base_allocator_builder_spec.rb +0 -102
- data/spec/knapsack_pro/build_distribution_fetcher_spec.rb +0 -89
- data/spec/knapsack_pro/client/api/action_spec.rb +0 -17
- data/spec/knapsack_pro/client/api/v1/base_spec.rb +0 -2
- data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +0 -95
- data/spec/knapsack_pro/client/api/v1/build_subsets_spec.rb +0 -35
- data/spec/knapsack_pro/client/api/v1/queues_spec.rb +0 -83
- data/spec/knapsack_pro/client/connection_spec.rb +0 -581
- data/spec/knapsack_pro/config/ci/app_veyor_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/base_spec.rb +0 -10
- data/spec/knapsack_pro/config/ci/buildkite_spec.rb +0 -135
- data/spec/knapsack_pro/config/ci/circle_spec.rb +0 -122
- data/spec/knapsack_pro/config/ci/cirrus_ci_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/codefresh_spec.rb +0 -81
- data/spec/knapsack_pro/config/ci/codeship_spec.rb +0 -80
- data/spec/knapsack_pro/config/ci/github_actions_spec.rb +0 -140
- data/spec/knapsack_pro/config/ci/gitlab_ci_spec.rb +0 -137
- data/spec/knapsack_pro/config/ci/heroku_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/semaphore2_spec.rb +0 -133
- data/spec/knapsack_pro/config/ci/semaphore_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/travis_spec.rb +0 -73
- data/spec/knapsack_pro/config/env_generator_spec.rb +0 -52
- data/spec/knapsack_pro/config/env_spec.rb +0 -1291
- data/spec/knapsack_pro/config/temp_files_spec.rb +0 -25
- data/spec/knapsack_pro/crypto/branch_encryptor_spec.rb +0 -53
- data/spec/knapsack_pro/crypto/decryptor_spec.rb +0 -83
- data/spec/knapsack_pro/crypto/digestor_spec.rb +0 -13
- data/spec/knapsack_pro/crypto/encryptor_spec.rb +0 -58
- data/spec/knapsack_pro/formatters/time_tracker_fetcher_spec.rb +0 -27
- data/spec/knapsack_pro/formatters/time_tracker_spec.rb +0 -448
- data/spec/knapsack_pro/hooks/queue_spec.rb +0 -199
- data/spec/knapsack_pro/presenter_spec.rb +0 -57
- data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +0 -248
- data/spec/knapsack_pro/queue_spec.rb +0 -35
- data/spec/knapsack_pro/report_spec.rb +0 -232
- data/spec/knapsack_pro/repository_adapter_initiator_spec.rb +0 -21
- data/spec/knapsack_pro/repository_adapters/base_adapter_spec.rb +0 -13
- data/spec/knapsack_pro/repository_adapters/env_adapter_spec.rb +0 -27
- data/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb +0 -106
- data/spec/knapsack_pro/runners/base_runner_spec.rb +0 -87
- data/spec/knapsack_pro/runners/cucumber_runner_spec.rb +0 -92
- data/spec/knapsack_pro/runners/minitest_runner_spec.rb +0 -57
- data/spec/knapsack_pro/runners/queue/base_runner_spec.rb +0 -73
- data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +0 -209
- data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +0 -203
- data/spec/knapsack_pro/runners/rspec_runner_spec.rb +0 -111
- data/spec/knapsack_pro/runners/spinach_runner_spec.rb +0 -56
- data/spec/knapsack_pro/runners/test_unit_runner_spec.rb +0 -62
- data/spec/knapsack_pro/slow_test_file_determiner_spec.rb +0 -119
- data/spec/knapsack_pro/slow_test_file_finder_spec.rb +0 -42
- data/spec/knapsack_pro/task_loader_spec.rb +0 -14
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +0 -217
- data/spec/knapsack_pro/test_case_mergers/base_merger_spec.rb +0 -27
- data/spec/knapsack_pro/test_case_mergers/rspec_merger_spec.rb +0 -81
- data/spec/knapsack_pro/test_file_cleaner_spec.rb +0 -11
- data/spec/knapsack_pro/test_file_finder_spec.rb +0 -176
- data/spec/knapsack_pro/test_file_pattern_spec.rb +0 -49
- data/spec/knapsack_pro/test_file_presenter_spec.rb +0 -22
- data/spec/knapsack_pro/test_files_with_test_cases_composer_spec.rb +0 -41
- data/spec/knapsack_pro/test_flat_distributor_spec.rb +0 -60
- data/spec/knapsack_pro/tracker_spec.rb +0 -184
- data/spec/knapsack_pro/utils_spec.rb +0 -55
- data/spec/knapsack_pro_spec.rb +0 -116
- data/spec/spec_helper.rb +0 -47
- data/spec/support/.gitkeep +0 -0
- data/spec/support/fakes/cucumber.rb +0 -25
- data/spec/support/fakes/minitest.rb +0 -18
- data/spec/support/shared_examples/adapter.rb +0 -17
- data/spec_fake/controllers/users_controller_spec.rb +0 -0
- data/spec_fake/models/admin_spec.rb +0 -0
- data/spec_fake/models/user_spec.rb +0 -0
- data/spec_fake/spec_helper.rb +0 -0
- data/spec_time_tracker/spec_helper.rb +0 -29
- data/test_fake/a_test.rb +0 -0
- data/test_fake/b_test.rb +0 -0
|
@@ -1,25 +0,0 @@
|
|
|
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
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Crypto::BranchEncryptor do
|
|
2
|
-
let(:branch) { 'feature-branch' }
|
|
3
|
-
let(:encryptor) { described_class.new(branch) }
|
|
4
|
-
|
|
5
|
-
describe '.call' do
|
|
6
|
-
subject { described_class.call(branch) }
|
|
7
|
-
|
|
8
|
-
before do
|
|
9
|
-
expect(KnapsackPro::Config::Env).to receive(:branch_encrypted?).and_return(branch_encrypted?)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context 'when branch encrypted flag enabled' do
|
|
13
|
-
let(:branch_encrypted?) { true }
|
|
14
|
-
let(:encryptor) { instance_double(described_class) }
|
|
15
|
-
|
|
16
|
-
it do
|
|
17
|
-
expect(described_class).to receive(:new).with(branch).and_return(encryptor)
|
|
18
|
-
result = double
|
|
19
|
-
expect(encryptor).to receive(:call).and_return(result)
|
|
20
|
-
|
|
21
|
-
expect(subject).to eq result
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context 'when test files encrypted flag disabled' do
|
|
26
|
-
let(:branch_encrypted?) { false }
|
|
27
|
-
|
|
28
|
-
it { should eq branch }
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe '#call' do
|
|
33
|
-
subject { encryptor.call }
|
|
34
|
-
|
|
35
|
-
context 'when encryptable branch name' do
|
|
36
|
-
let(:branch) { 'feature-branch' }
|
|
37
|
-
|
|
38
|
-
before do
|
|
39
|
-
expect(KnapsackPro::Config::Env).to receive(:salt).at_least(1).and_return('123')
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it { should eq '49e5bb1' }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
described_class::NON_ENCRYPTABLE_BRANCHES.each do |branch_name|
|
|
46
|
-
context "when non encryptable branch name: #{branch_name}" do
|
|
47
|
-
let(:branch) { branch_name }
|
|
48
|
-
|
|
49
|
-
it { should eq branch_name }
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Crypto::Decryptor do
|
|
2
|
-
let(:test_files) do
|
|
3
|
-
[
|
|
4
|
-
{ 'path' => 'a_spec.rb' },
|
|
5
|
-
{ 'path' => 'b_spec.rb' },
|
|
6
|
-
]
|
|
7
|
-
end
|
|
8
|
-
let(:encrypted_test_files) do
|
|
9
|
-
[
|
|
10
|
-
{ 'path' => '93131469d5aee8158473f9945847cd411ba975644b617897b7c33164adc55038', 'time_execution' => 1.2 },
|
|
11
|
-
{ 'path' => '716143a50194e2d2173b757b3418564f5efd12ce3c52332c02db60bb70c240bc', 'time_execution' => 2.3 },
|
|
12
|
-
]
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
let(:decryptor) { described_class.new(test_files, encrypted_test_files) }
|
|
16
|
-
|
|
17
|
-
describe '.call' do
|
|
18
|
-
let(:test_suite) { instance_double(KnapsackPro::TestSuite, calculate_test_files: instance_double(KnapsackPro::TestSuite::Result, test_files: test_files)) }
|
|
19
|
-
|
|
20
|
-
subject { described_class.call(test_suite, encrypted_test_files) }
|
|
21
|
-
|
|
22
|
-
before do
|
|
23
|
-
expect(KnapsackPro::Config::Env).to receive(:test_files_encrypted?).and_return(test_files_encrypted?)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context 'when test files encrypted flag enabled' do
|
|
27
|
-
let(:test_files_encrypted?) { true }
|
|
28
|
-
let(:decryptor) { instance_double(described_class) }
|
|
29
|
-
|
|
30
|
-
it do
|
|
31
|
-
expect(described_class).to receive(:new).with(test_files, encrypted_test_files).and_return(decryptor)
|
|
32
|
-
result = double
|
|
33
|
-
expect(decryptor).to receive(:call).and_return(result)
|
|
34
|
-
|
|
35
|
-
expect(subject).to eq result
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
context 'when test files encrypted flag disabled' do
|
|
40
|
-
let(:test_files_encrypted?) { false }
|
|
41
|
-
let(:encrypted_test_files) { double }
|
|
42
|
-
|
|
43
|
-
it { should eq encrypted_test_files }
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe '#call' do
|
|
48
|
-
subject { decryptor.call }
|
|
49
|
-
|
|
50
|
-
before do
|
|
51
|
-
expect(KnapsackPro::Config::Env).to receive(:salt).at_least(1).and_return('123')
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it do
|
|
55
|
-
should eq([
|
|
56
|
-
{ 'path' => 'a_spec.rb', 'time_execution' => 1.2 },
|
|
57
|
-
{ 'path' => 'b_spec.rb', 'time_execution' => 2.3 },
|
|
58
|
-
])
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
context 'when missing encrypted test file' do
|
|
62
|
-
let(:encrypted_test_files) { [] }
|
|
63
|
-
|
|
64
|
-
it do
|
|
65
|
-
expect(subject).to eq []
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context 'when too many encrypted test files with the same encrypted path' do
|
|
70
|
-
let(:encrypted_test_files) do
|
|
71
|
-
[
|
|
72
|
-
{ 'path' => '93131469d5aee8158473f9945847cd411ba975644b617897b7c33164adc55038', 'time_execution' => 1.2 },
|
|
73
|
-
{ 'path' => '716143a50194e2d2173b757b3418564f5efd12ce3c52332c02db60bb70c240bc', 'time_execution' => 2.3 },
|
|
74
|
-
{ 'path' => '716143a50194e2d2173b757b3418564f5efd12ce3c52332c02db60bb70c240bc', 'time_execution' => 2.4 }, # duplicate
|
|
75
|
-
]
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it do
|
|
79
|
-
expect { subject }.to raise_error(KnapsackPro::Crypto::Decryptor::TooManyEncryptedTestFilesError)
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Crypto::Digestor do
|
|
2
|
-
describe '.salt_hexdigest' do
|
|
3
|
-
let(:str_to_encrypt) { 'a_spec.rb' }
|
|
4
|
-
|
|
5
|
-
subject { described_class.salt_hexdigest(str_to_encrypt) }
|
|
6
|
-
|
|
7
|
-
before do
|
|
8
|
-
expect(KnapsackPro::Config::Env).to receive(:salt).at_least(1).and_return('123')
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it { should eq '93131469d5aee8158473f9945847cd411ba975644b617897b7c33164adc55038' }
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Crypto::Encryptor do
|
|
2
|
-
let(:test_files) do
|
|
3
|
-
[
|
|
4
|
-
{ 'path' => 'a_spec.rb', 'time_execution' => 1.2 },
|
|
5
|
-
{ 'path' => 'b_spec.rb', 'time_execution' => 2.3 },
|
|
6
|
-
]
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
let(:encryptor) { described_class.new(test_files) }
|
|
10
|
-
|
|
11
|
-
describe '.call' do
|
|
12
|
-
subject { described_class.call(test_files) }
|
|
13
|
-
|
|
14
|
-
before do
|
|
15
|
-
expect(KnapsackPro::Config::Env).to receive(:test_files_encrypted?).and_return(test_files_encrypted?)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context 'when test files encrypted flag enabled' do
|
|
19
|
-
let(:test_files_encrypted?) { true }
|
|
20
|
-
let(:encryptor) { instance_double(described_class) }
|
|
21
|
-
|
|
22
|
-
it do
|
|
23
|
-
expect(described_class).to receive(:new).with(test_files).and_return(encryptor)
|
|
24
|
-
result = double
|
|
25
|
-
expect(encryptor).to receive(:call).and_return(result)
|
|
26
|
-
|
|
27
|
-
expect(subject).to eq result
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'when test files encrypted flag disabled' do
|
|
32
|
-
let(:test_files_encrypted?) { false }
|
|
33
|
-
|
|
34
|
-
it { should eq test_files }
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe '#call' do
|
|
39
|
-
subject { encryptor.call }
|
|
40
|
-
|
|
41
|
-
before do
|
|
42
|
-
expect(KnapsackPro::Config::Env).to receive(:salt).at_least(1).and_return('123')
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should not modify input test files array" do
|
|
46
|
-
test_files_original = Marshal.load(Marshal.dump(test_files))
|
|
47
|
-
subject
|
|
48
|
-
expect(test_files).to eq test_files_original
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it do
|
|
52
|
-
should eq([
|
|
53
|
-
{ 'path' => '93131469d5aee8158473f9945847cd411ba975644b617897b7c33164adc55038', 'time_execution' => 1.2 },
|
|
54
|
-
{ 'path' => '716143a50194e2d2173b757b3418564f5efd12ce3c52332c02db60bb70c240bc', 'time_execution' => 2.3 },
|
|
55
|
-
])
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require(KnapsackPro.root + '/lib/knapsack_pro/formatters/time_tracker')
|
|
2
|
-
|
|
3
|
-
describe KnapsackPro::Formatters::TimeTrackerFetcher do
|
|
4
|
-
describe '.unexecuted_test_files' do
|
|
5
|
-
subject { described_class.unexecuted_test_files }
|
|
6
|
-
|
|
7
|
-
context 'when the time tracker formatter not found' do
|
|
8
|
-
it do
|
|
9
|
-
expect(subject).to eq []
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context 'when the time tracker formatter is found' do
|
|
14
|
-
let(:time_tracker) { instance_double(KnapsackPro::Formatters::TimeTracker) }
|
|
15
|
-
let(:unexecuted_test_files) { double(:unexecuted_test_files) }
|
|
16
|
-
|
|
17
|
-
before do
|
|
18
|
-
expect(described_class).to receive(:call).and_return(time_tracker)
|
|
19
|
-
expect(time_tracker).to receive(:unexecuted_test_files).and_return(unexecuted_test_files)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it do
|
|
23
|
-
expect(subject).to eq unexecuted_test_files
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,448 +0,0 @@
|
|
|
1
|
-
require 'open3'
|
|
2
|
-
require 'tmpdir'
|
|
3
|
-
|
|
4
|
-
describe 'TimeTracker' do
|
|
5
|
-
around(:each) do |example|
|
|
6
|
-
Dir.mktmpdir(nil, 'spec_time_tracker') do |dir|
|
|
7
|
-
@dir = dir
|
|
8
|
-
example.run
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe '#queue' do
|
|
13
|
-
it 'single example' do
|
|
14
|
-
spec = <<~SPEC
|
|
15
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
16
|
-
it do
|
|
17
|
-
sleep 0.1
|
|
18
|
-
expect(1).to eq 1
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
SPEC
|
|
22
|
-
|
|
23
|
-
run_specs(spec, 'queue') do |spec_paths, queue|
|
|
24
|
-
expect(queue.size).to eq(1)
|
|
25
|
-
expect(queue[0]['path']).to eq(spec_paths[0])
|
|
26
|
-
expect(queue[0]['time_execution']).to be_between(0.10, 0.15)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'two files' do
|
|
31
|
-
spec0 = <<~SPEC
|
|
32
|
-
describe 'KnapsackPro::Formatters::TimeTracker 1' do
|
|
33
|
-
it do
|
|
34
|
-
sleep 0.1
|
|
35
|
-
expect(1).to eq 1
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
SPEC
|
|
39
|
-
|
|
40
|
-
spec1 = <<~SPEC
|
|
41
|
-
describe 'KnapsackPro::Formatters::TimeTracker 2' do
|
|
42
|
-
it do
|
|
43
|
-
sleep 0.2
|
|
44
|
-
expect(1).to eq 1
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
SPEC
|
|
48
|
-
|
|
49
|
-
run_specs([spec0, spec1], 'queue') do |spec_paths, queue|
|
|
50
|
-
expect(queue.size).to eq(2)
|
|
51
|
-
expect(queue[0]['path']).to eq(spec_paths[0])
|
|
52
|
-
expect(queue[0]['time_execution']).to be_between(0.10, 0.15)
|
|
53
|
-
expect(queue[1]['path']).to eq(spec_paths[1])
|
|
54
|
-
expect(queue[1]['time_execution']).to be_between(0.20, 0.25)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it 'failing example' do
|
|
59
|
-
spec = <<~SPEC
|
|
60
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
61
|
-
it do
|
|
62
|
-
sleep 0.1
|
|
63
|
-
expect(1).to eq 2
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
SPEC
|
|
67
|
-
|
|
68
|
-
run_specs(spec, 'queue') do |spec_paths, queue|
|
|
69
|
-
expect(queue.size).to eq(1)
|
|
70
|
-
expect(queue[0]['path']).to eq(spec_paths[0])
|
|
71
|
-
expect(queue[0]['time_execution']).to be_between(0.10, 0.15)
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it 'pending example' do
|
|
76
|
-
spec = <<~SPEC
|
|
77
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
78
|
-
xit do
|
|
79
|
-
sleep 0.1
|
|
80
|
-
expect(1).to eq 2
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
SPEC
|
|
84
|
-
|
|
85
|
-
run_specs(spec, 'queue') do |spec_paths, queue|
|
|
86
|
-
expect(queue.size).to eq(1)
|
|
87
|
-
expect(queue[0]['path']).to eq(spec_paths[0])
|
|
88
|
-
expect(queue[0]['time_execution']).to eq(0.0)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it 'multiple top level groups' do
|
|
93
|
-
spec = <<~SPEC
|
|
94
|
-
describe 'KnapsackPro::Formatters::TimeTracker 1' do
|
|
95
|
-
it do
|
|
96
|
-
sleep 0.1
|
|
97
|
-
expect(1).to eq 1
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
describe 'KnapsackPro::Formatters::TimeTracker 2' do
|
|
102
|
-
it do
|
|
103
|
-
sleep 0.2
|
|
104
|
-
expect(1).to eq 1
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
SPEC
|
|
108
|
-
|
|
109
|
-
run_specs(spec, 'queue') do |spec_paths, queue|
|
|
110
|
-
expect(queue.size).to eq(1)
|
|
111
|
-
expect(queue[0]['path']).to eq(spec_paths[0])
|
|
112
|
-
expect(queue[0]['time_execution']).to be_between(0.30, 0.35)
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
it 'rspec split by test example' do
|
|
117
|
-
spec = <<~SPEC
|
|
118
|
-
describe 'KnapsackPro::Formatters::TimeTracker 1' do
|
|
119
|
-
it do
|
|
120
|
-
expect(1).to eq 1
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it do
|
|
124
|
-
sleep 0.1
|
|
125
|
-
expect(1).to eq 1
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
describe 'KnapsackPro::Formatters::TimeTracker 2' do
|
|
130
|
-
it do
|
|
131
|
-
sleep 0.2
|
|
132
|
-
expect(1).to eq 1
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
it do
|
|
136
|
-
sleep 0.3
|
|
137
|
-
expect(1).to eq 1
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
SPEC
|
|
141
|
-
|
|
142
|
-
run_specs(spec, 'queue', env: 'TEST__SBTE=1') do |spec_paths, queue|
|
|
143
|
-
expect(queue.size).to eq(4)
|
|
144
|
-
|
|
145
|
-
spec_path = spec_paths[0]
|
|
146
|
-
expect(queue.find { |time| time['path'] == "#{spec_path}[1:1]" }['time_execution']).to be_between(0.00, 0.05).exclusive
|
|
147
|
-
expect(queue.find { |time| time['path'] == "#{spec_path}[1:2]" }['time_execution']).to be_between(0.10, 0.15)
|
|
148
|
-
expect(queue.find { |time| time['path'] == "#{spec_path}[2:1]" }['time_execution']).to be_between(0.20, 0.25)
|
|
149
|
-
expect(queue.find { |time| time['path'] == "#{spec_path}[2:2]" }['time_execution']).to be_between(0.30, 0.35)
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
it 'hooks' do
|
|
154
|
-
spec = <<~SPEC
|
|
155
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
156
|
-
before(:all) do
|
|
157
|
-
sleep 0.1
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
before(:each) do
|
|
161
|
-
sleep 0.1
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
after(:each) do
|
|
165
|
-
sleep 0.1
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
it do
|
|
169
|
-
expect(1).to eq 1
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
it do
|
|
173
|
-
expect(1).to eq 1
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
after(:all) do
|
|
177
|
-
sleep 0.1
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
SPEC
|
|
181
|
-
|
|
182
|
-
run_specs(spec, 'queue') do |spec_paths, queue|
|
|
183
|
-
expect(queue.size).to eq(1)
|
|
184
|
-
expect(queue[0]['path']).to eq(spec_paths[0])
|
|
185
|
-
expect(queue[0]['time_execution']).to be_between(0.60, 0.65)
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
it 'nested hooks' do
|
|
190
|
-
spec = <<~SPEC
|
|
191
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
192
|
-
before(:all) do
|
|
193
|
-
sleep 0.1
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
after(:all) do
|
|
197
|
-
sleep 0.1
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
it do
|
|
201
|
-
expect(1).to eq 1
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
describe do
|
|
205
|
-
before(:all) do
|
|
206
|
-
sleep 0.1
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
after(:all) do
|
|
210
|
-
sleep 0.1
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
it do
|
|
214
|
-
expect(1).to eq 1
|
|
215
|
-
end
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
describe do
|
|
219
|
-
before(:all) do
|
|
220
|
-
sleep 0.1
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
after(:all) do
|
|
224
|
-
sleep 0.1
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
it do
|
|
228
|
-
expect(1).to eq 1
|
|
229
|
-
end
|
|
230
|
-
end
|
|
231
|
-
end
|
|
232
|
-
SPEC
|
|
233
|
-
|
|
234
|
-
run_specs(spec, 'queue') do |spec_paths, queue|
|
|
235
|
-
expect(queue.size).to eq(1)
|
|
236
|
-
expect(queue[0]['path']).to eq(spec_paths[0])
|
|
237
|
-
expect(queue[0]['time_execution']).to be_between(0.60, 0.65)
|
|
238
|
-
end
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
it 'hooks with rspec split by test example' do
|
|
242
|
-
spec = <<~SPEC
|
|
243
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
244
|
-
before(:all) do
|
|
245
|
-
sleep 0.1
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
before(:each) do
|
|
249
|
-
sleep 0.1
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
after(:each) do
|
|
253
|
-
sleep 0.1
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
it do
|
|
257
|
-
expect(1).to eq 1
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
it do
|
|
261
|
-
expect(1).to eq 1
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
after(:all) do
|
|
265
|
-
sleep 0.1
|
|
266
|
-
end
|
|
267
|
-
end
|
|
268
|
-
SPEC
|
|
269
|
-
|
|
270
|
-
run_specs(spec, 'queue', env: 'TEST__SBTE=1') do |spec_paths, queue|
|
|
271
|
-
expect(queue.size).to eq(2)
|
|
272
|
-
|
|
273
|
-
spec_path = spec_paths[0]
|
|
274
|
-
expect(queue.find { |time| time['path'] == "#{spec_path}[1:1]" }['time_execution']).to be_between(0.40, 0.45)
|
|
275
|
-
expect(queue.find { |time| time['path'] == "#{spec_path}[1:2]" }['time_execution']).to be_between(0.40, 0.45)
|
|
276
|
-
end
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
it 'nested hooks with rspec split by test example' do
|
|
280
|
-
spec = <<~SPEC
|
|
281
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
282
|
-
before(:all) do
|
|
283
|
-
sleep 0.1
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
after(:all) do
|
|
287
|
-
sleep 0.1
|
|
288
|
-
end
|
|
289
|
-
|
|
290
|
-
it do
|
|
291
|
-
expect(1).to eq 1
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
describe do
|
|
295
|
-
before(:all) do
|
|
296
|
-
sleep 0.1
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
after(:all) do
|
|
300
|
-
sleep 0.1
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
it do
|
|
304
|
-
expect(1).to eq 1
|
|
305
|
-
end
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
describe do
|
|
309
|
-
before(:all) do
|
|
310
|
-
sleep 0.1
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
-
after(:all) do
|
|
314
|
-
sleep 0.1
|
|
315
|
-
end
|
|
316
|
-
|
|
317
|
-
it do
|
|
318
|
-
expect(1).to eq 1
|
|
319
|
-
end
|
|
320
|
-
end
|
|
321
|
-
end
|
|
322
|
-
SPEC
|
|
323
|
-
|
|
324
|
-
run_specs(spec, 'queue', env: 'TEST__SBTE=1') do |spec_paths, queue|
|
|
325
|
-
expect(queue.size).to eq(3)
|
|
326
|
-
|
|
327
|
-
spec_path = spec_paths[0]
|
|
328
|
-
expect(queue.find { |time| time['path'] == "#{spec_path}[1:1]" }['time_execution']).to be_between(0.20, 0.25)
|
|
329
|
-
expect(queue.find { |time| time['path'] == "#{spec_path}[1:2:1]" }['time_execution']).to be_between(0.40, 0.45)
|
|
330
|
-
expect(queue.find { |time| time['path'] == "#{spec_path}[1:3:1]" }['time_execution']).to be_between(0.40, 0.45)
|
|
331
|
-
end
|
|
332
|
-
end
|
|
333
|
-
|
|
334
|
-
it 'unknown path' do
|
|
335
|
-
spec = <<~SPEC
|
|
336
|
-
RSpec.configure do |config|
|
|
337
|
-
config.before(:all) do
|
|
338
|
-
time_tracker = ::RSpec.configuration.formatters.find { |f| f.class.to_s == 'TestableTimeTracker' }
|
|
339
|
-
time_tracker.scheduled_paths = ['#{@dir}/0_spec.rb']
|
|
340
|
-
end
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
344
|
-
it do
|
|
345
|
-
expect(1).to eq 1
|
|
346
|
-
end
|
|
347
|
-
end
|
|
348
|
-
SPEC
|
|
349
|
-
|
|
350
|
-
run_specs(spec, 'queue', env: 'TEST__EMPTY_FILE_PATH=1') do |spec_paths, queue|
|
|
351
|
-
expect(queue.size).to eq(1)
|
|
352
|
-
expect(queue[0]['path']).to eq(spec_paths[0])
|
|
353
|
-
expect(queue[0]['time_execution']).to eq(0.0)
|
|
354
|
-
end
|
|
355
|
-
end
|
|
356
|
-
|
|
357
|
-
it 'empty group' do
|
|
358
|
-
spec = <<~SPEC
|
|
359
|
-
RSpec.configure do |config|
|
|
360
|
-
config.before(:suite) do
|
|
361
|
-
time_tracker = ::RSpec.configuration.formatters.find { |f| f.class.to_s == 'TestableTimeTracker' }
|
|
362
|
-
time_tracker.scheduled_paths = ['#{@dir}/0_spec.rb']
|
|
363
|
-
end
|
|
364
|
-
end
|
|
365
|
-
|
|
366
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
367
|
-
end
|
|
368
|
-
SPEC
|
|
369
|
-
|
|
370
|
-
run_specs(spec, 'queue') do |spec_paths, queue|
|
|
371
|
-
expect(queue.size).to eq(1)
|
|
372
|
-
expect(queue[0]['path']).to eq(spec_paths[0])
|
|
373
|
-
expect(queue[0]['time_execution']).to eq(0.0)
|
|
374
|
-
end
|
|
375
|
-
end
|
|
376
|
-
end
|
|
377
|
-
|
|
378
|
-
describe '#duration' do
|
|
379
|
-
it do
|
|
380
|
-
spec = <<~SPEC
|
|
381
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
382
|
-
it do
|
|
383
|
-
expect(1).to eq 1
|
|
384
|
-
end
|
|
385
|
-
end
|
|
386
|
-
SPEC
|
|
387
|
-
|
|
388
|
-
run_specs(spec, 'duration') do |_, duration|
|
|
389
|
-
expect(duration).to be_between(0.00, 0.05).exclusive
|
|
390
|
-
end
|
|
391
|
-
end
|
|
392
|
-
end
|
|
393
|
-
|
|
394
|
-
describe '#unexecuted_test_files' do
|
|
395
|
-
it do
|
|
396
|
-
spec = <<~SPEC
|
|
397
|
-
RSpec.configure do |config|
|
|
398
|
-
config.before(:all) do
|
|
399
|
-
time_tracker = ::RSpec.configuration.formatters.find { |f| f.class.to_s == 'TestableTimeTracker' }
|
|
400
|
-
time_tracker.scheduled_paths = ['#{@dir}/0_spec.rb', 'foo_spec.rb[1:1]']
|
|
401
|
-
end
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
405
|
-
xit do
|
|
406
|
-
end
|
|
407
|
-
end
|
|
408
|
-
SPEC
|
|
409
|
-
|
|
410
|
-
run_specs(spec, 'unexecuted_test_files') do |spec_paths, unexecuted_test_files|
|
|
411
|
-
expect(unexecuted_test_files).to eq(["#{@dir}/0_spec.rb", 'foo_spec.rb[1:1]'])
|
|
412
|
-
end
|
|
413
|
-
end
|
|
414
|
-
end
|
|
415
|
-
|
|
416
|
-
describe '#batch' do
|
|
417
|
-
it do
|
|
418
|
-
spec = <<~SPEC
|
|
419
|
-
describe 'KnapsackPro::Formatters::TimeTracker' do
|
|
420
|
-
it do
|
|
421
|
-
sleep 0.1
|
|
422
|
-
expect(1).to eq 1
|
|
423
|
-
end
|
|
424
|
-
end
|
|
425
|
-
SPEC
|
|
426
|
-
|
|
427
|
-
run_specs(spec, 'batch') do |spec_paths, batch|
|
|
428
|
-
expect(batch.size).to eq(1)
|
|
429
|
-
expect(batch[0]['path']).to eq(spec_paths[0])
|
|
430
|
-
expect(batch[0]['time_execution']).to be_between(0.10, 0.15)
|
|
431
|
-
end
|
|
432
|
-
end
|
|
433
|
-
end
|
|
434
|
-
|
|
435
|
-
def run_specs(specs, method, env: '')
|
|
436
|
-
paths = Array(specs).map.with_index do |spec, i|
|
|
437
|
-
path = "#{@dir}/#{i}_spec.rb"
|
|
438
|
-
File.write(path, spec)
|
|
439
|
-
path
|
|
440
|
-
end
|
|
441
|
-
|
|
442
|
-
out, err, _status = Open3.capture3("#{env} TEST__METHOD=#{method} bundle exec rspec --default-path spec_time_tracker -f TestableTimeTracker spec_time_tracker")
|
|
443
|
-
puts err if ENV['TEST__DEBUG']
|
|
444
|
-
result = Marshal.load(out.lines.last)
|
|
445
|
-
|
|
446
|
-
yield(paths, result)
|
|
447
|
-
end
|
|
448
|
-
end
|