knapsack 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +8 -0
- data/README.md +31 -1
- data/lib/knapsack/allocator.rb +1 -1
- data/lib/knapsack/allocator_builder.rb +1 -1
- data/lib/knapsack/config/env.rb +4 -0
- data/lib/knapsack/version.rb +1 -1
- data/spec/knapsack/allocator_builder_spec.rb +18 -8
- data/spec/knapsack/allocator_spec.rb +17 -5
- data/spec/knapsack/config/env_spec.rb +14 -0
- data/spec_engine_examples/1_spec.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d9f16bd65a7c6af4fdd57f421108b1f3cc22008
|
4
|
+
data.tar.gz: aca4f9264ed06bc1ca55ba107c4382d05f2821b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eba6f582a89e2df694accf1b63b9d213c8db0781102276323514c41702837ee1749c775d912df95a5510704adf7ac3518acbd307311ac62475f68002ba867c00
|
7
|
+
data.tar.gz: bc55f58146b90c4acaf835566be3e657341eca9c0653f64c47a908d1151725de4bb17d0cf55e4a28fb692d969870248b2151afcca1efa419b49e76c4a72519d0
|
data/.travis.yml
CHANGED
@@ -49,6 +49,8 @@ script:
|
|
49
49
|
- rm spec_examples/fast/1_spec.rb
|
50
50
|
- KNAPSACK_TEST_FILE_PATTERN="spec_examples/**{,/*/**}/*_spec.rb" bundle exec rake knapsack:rspec
|
51
51
|
|
52
|
+
- bin/print_header.sh "Run specs from multiple directories with manually specified test_dir"
|
53
|
+
- KNAPSACK_TEST_DIR=spec_examples KNAPSACK_TEST_FILE_PATTERN="{spec_examples,spec_engine_examples}/**{,/*/**}/*_spec.rb" bundle exec rake knapsack:rspec
|
52
54
|
|
53
55
|
- bin/print_header.sh "------------------------------------------------------"
|
54
56
|
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
* TODO
|
4
4
|
|
5
|
+
### 1.7.0
|
6
|
+
|
7
|
+
* Add ability to run tests from multiple directories
|
8
|
+
|
9
|
+
https://github.com/ArturT/knapsack/pull/35
|
10
|
+
|
11
|
+
https://github.com/ArturT/knapsack/compare/v1.6.1...v1.7.0
|
12
|
+
|
5
13
|
### 1.6.1
|
6
14
|
|
7
15
|
* Changed rake task in minitest_runner.rb to have no warnings output
|
data/README.md
CHANGED
@@ -68,6 +68,10 @@ Presentations about gem:
|
|
68
68
|
- [Step 1](#step-1-4)
|
69
69
|
- [Step 2](#step-2-4)
|
70
70
|
- [FAQ](#faq)
|
71
|
+
- [What time offset warning means?](#what-time-offset-warning-means)
|
72
|
+
- [How to generate knapsack report?](#how-to-generate-knapsack-report)
|
73
|
+
- [What does "leftover specs" mean?](#what-does-leftover-specs-mean)
|
74
|
+
- [How can I run tests from multiple directories?](#how-can-i-run-tests-from-multiple-directories)
|
71
75
|
- [Gem tests](#gem-tests)
|
72
76
|
- [Spec](#spec)
|
73
77
|
- [Spec examples](#spec-examples)
|
@@ -492,7 +496,7 @@ Knapsack supports snap-ci.com ENVs `SNAP_WORKER_TOTAL` and `SNAP_WORKER_INDEX`.
|
|
492
496
|
|
493
497
|
## FAQ
|
494
498
|
|
495
|
-
|
499
|
+
### What time offset warning means?
|
496
500
|
|
497
501
|
At the end of tests execution results you can see warning like this:
|
498
502
|
|
@@ -509,12 +513,38 @@ Exceeded time: 37s
|
|
509
513
|
|
510
514
|
`Exceeded time: 37s` - it means tests on particular CI node took 37s longer than `max allowed node time execution`. Sometimes this value is negative when tests executed faster than `max allowed node time execution`.
|
511
515
|
|
516
|
+
### How to generate knapsack report?
|
517
|
+
|
512
518
|
If you want to regenerate report take a look [here](#common-step).
|
513
519
|
|
514
520
|
`KNAPSACK_GENERATE_REPORT=true bundle exec rspec spec`
|
515
521
|
|
516
522
|
If you run command like this on your development machine then test suite time execution might be different than if you generate a report on CI machine (for instance tests might be faster on your machine then on CI node) so that might be a reason why you see warning about regenerating report. You can generate the report on single CI node which should give you result specific for your CI node instead of your development machine. In case you don't want to bother about manually regenerating knapsack report please take a look on [knapsack_pro gem](http://knapsackpro.com).
|
517
523
|
|
524
|
+
### What does "leftover specs" mean?
|
525
|
+
|
526
|
+
When you run your specs with knapsack rake task then you will see in the output something like:
|
527
|
+
|
528
|
+
```
|
529
|
+
Report specs:
|
530
|
+
spec/models/user_spec.rb
|
531
|
+
spec/controllers/users_controller_spec.rb
|
532
|
+
|
533
|
+
Leftover specs:
|
534
|
+
spec/models/book_spec.rb
|
535
|
+
spec/models/author_spec.rb
|
536
|
+
```
|
537
|
+
|
538
|
+
The leftover specs mean we don't have recorded time execution for those test files so the leftover specs were distributed across CI nodes based on file name instead.
|
539
|
+
The reason might be that someone added a new test file after knapsack report was generated. Another reason might be an empty spec file.
|
540
|
+
If you have a lot of leftover specs then you can [generate knapsack report again](#how-to-generate-knapsack-report) to improve you test distribution across CI nodes.
|
541
|
+
|
542
|
+
### How can I run tests from multiple directories?
|
543
|
+
|
544
|
+
The test file pattern config option supports any glob pattern handled by [`Dir.glob`](http://ruby-doc.org/core-2.2.0/Dir.html#method-c-glob) and can be configured to pull test files from multiple directories. An example of this when using RSpec would be `"{spec,engines/**/spec}/**{,/*/**}/*_spec.rb"`. For complex cases like this, the test directory can't be extracted and must be specified manually using the `KNAPSACK_TEST_DIR` environment variable:
|
545
|
+
|
546
|
+
$ KNAPSACK_TEST_DIR=spec KNAPSACK_TEST_FILE_PATTERN="{spec,engines/**/spec}/**{,/*/**}/*_spec.rb" bundle exec rake knapsack:rspec
|
547
|
+
|
518
548
|
## Gem tests
|
519
549
|
|
520
550
|
### Spec
|
data/lib/knapsack/allocator.rb
CHANGED
data/lib/knapsack/config/env.rb
CHANGED
data/lib/knapsack/version.rb
CHANGED
@@ -97,18 +97,28 @@ describe Knapsack::AllocatorBuilder do
|
|
97
97
|
|
98
98
|
subject { allocator_builder.test_dir }
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
context 'when ENV test_file_pattern has value' do
|
105
|
-
let(:env_test_file_pattern) { 'custom_spec/**{,/*/**}/*_spec.rb' }
|
100
|
+
context 'when ENV test_dir has value' do
|
101
|
+
before do
|
102
|
+
expect(Knapsack::Config::Env).to receive(:test_dir).and_return("custom_spec")
|
103
|
+
end
|
106
104
|
|
107
105
|
it { should eq 'custom_spec' }
|
108
106
|
end
|
109
107
|
|
110
|
-
context 'when ENV
|
111
|
-
|
108
|
+
context 'when ENV test_dir has no value' do
|
109
|
+
before do
|
110
|
+
expect(Knapsack::Config::Env).to receive(:test_file_pattern).and_return(env_test_file_pattern)
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when ENV test_file_pattern has value' do
|
114
|
+
let(:env_test_file_pattern) { 'custom_spec/**{,/*/**}/*_spec.rb' }
|
115
|
+
|
116
|
+
it { should eq 'custom_spec' }
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'when ENV test_file_pattern has no value' do
|
120
|
+
it { should eq 'spec' }
|
121
|
+
end
|
112
122
|
end
|
113
123
|
end
|
114
124
|
end
|
@@ -43,14 +43,26 @@ describe Knapsack::Allocator do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
describe '#test_dir' do
|
46
|
-
let(:test_file_pattern) { "test_dir/**{,/*/**}/*_spec.rb" }
|
47
|
-
|
48
46
|
subject { allocator.test_dir }
|
49
47
|
|
50
|
-
|
51
|
-
|
48
|
+
context 'when ENV test_dir has value' do
|
49
|
+
let(:test_dir) { "custom_dir" }
|
50
|
+
|
51
|
+
before do
|
52
|
+
expect(Knapsack::Config::Env).to receive(:test_dir).and_return(test_dir)
|
53
|
+
end
|
54
|
+
|
55
|
+
it { should eql 'custom_dir' }
|
52
56
|
end
|
53
57
|
|
54
|
-
|
58
|
+
context 'when ENV test_dir has no value' do
|
59
|
+
let(:test_file_pattern) { "test_dir/**{,/*/**}/*_spec.rb" }
|
60
|
+
|
61
|
+
before do
|
62
|
+
expect(report_distributor).to receive(:test_file_pattern).and_return(test_file_pattern)
|
63
|
+
end
|
64
|
+
|
65
|
+
it { should eql 'test_dir/' }
|
66
|
+
end
|
55
67
|
end
|
56
68
|
end
|
@@ -96,4 +96,18 @@ describe Knapsack::Config::Env do
|
|
96
96
|
it { should be_nil }
|
97
97
|
end
|
98
98
|
end
|
99
|
+
|
100
|
+
describe '.test_dir' do
|
101
|
+
subject { described_class.test_dir }
|
102
|
+
|
103
|
+
context 'when ENV exists' do
|
104
|
+
let(:test_dir) { 'spec' }
|
105
|
+
before { stub_const("ENV", { 'KNAPSACK_TEST_DIR' => test_dir }) }
|
106
|
+
it { should eql test_dir }
|
107
|
+
end
|
108
|
+
|
109
|
+
context "when ENV doesn't exist" do
|
110
|
+
it { should be_nil }
|
111
|
+
end
|
112
|
+
end
|
99
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knapsack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -220,6 +220,7 @@ files:
|
|
220
220
|
- spec/support/fakes/cucumber.rb
|
221
221
|
- spec/support/fakes/minitest.rb
|
222
222
|
- spec/support/shared_examples/adapter.rb
|
223
|
+
- spec_engine_examples/1_spec.rb
|
223
224
|
- spec_examples/fast/1_spec.rb
|
224
225
|
- spec_examples/fast/2_spec.rb
|
225
226
|
- spec_examples/fast/3_spec.rb
|