knapsack_pro 1.0.2 → 1.1.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
  SHA256:
3
- metadata.gz: 8608ce6cc56baf7be7b0be2a09c8ecbb0e4f5aa2e0e80ce796284aba9d2fc9bf
4
- data.tar.gz: b249d1169e73ecf370d055169189e158b0d0b2cee526540a07eb13b92bb12f6e
3
+ metadata.gz: 6c90349dc3633e515ef14c71464df3023abf3d43176547bfb2f1d3d9862195c0
4
+ data.tar.gz: bfda6b2b50c900b141fcd3e5c074a1195346fcc8ff8cd9caf8d1e0ca2b97157e
5
5
  SHA512:
6
- metadata.gz: 5868feda23ff81b692ba3053876c3036379e373f77e9004460b29691f18beb35ccbccd32175434f2b98ca8bb973a321f28cd4ac096f346e034a664534b82ccb1
7
- data.tar.gz: 76efa329752999c325af61c9479f5b496719b84aac9e0b0de2b8ab4838ebd2303a3ba05951e54adcf1f5eb32d552fb482ac2b9e6a836d0a8780ff1687f9d3384
6
+ metadata.gz: fd531919cc65cc8130d39573b328bedfb55f2528618b2492d695b463340d250619598e204719090d130ffb5f6963fa7b64104b00a67d387e16983ec03df1f699
7
+ data.tar.gz: 535766bb3747204085c54147dd19d1bb3b8f0fe76a77b941df0a2e17cf2e5d886fc034cbf6342120f240366a896fa7c5d2a9cae2a076ccd544316582d307b098
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 1.1.0
6
+
7
+ * Add test file exclude pattern.
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/72
10
+
11
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.0.2...v1.1.0
12
+
5
13
  ### 1.0.2
6
14
 
7
15
  * Track time execution of all tests assigned to CI node in Queue Mode even when they did not run due syntax error or being pending/empty in test run.
data/README.md CHANGED
@@ -155,6 +155,7 @@ The knapsack_pro has also [queue mode](#queue-mode) to get an optimal test suite
155
155
  - [Why I don't see all test files being recorded in user dashboard](#why-i-dont-see-all-test-files-being-recorded-in-user-dashboard)
156
156
  - [Why when I use 2 different CI providers then not all test files are executed?](#why-when-i-use-2-different-ci-providers-then-not-all-test-files-are-executed)
157
157
  - [How to run only RSpec feature tests or non feature tests?](#how-to-run-only-rspec-feature-tests-or-non-feature-tests)
158
+ - [How to exclude tests from running them?](#how-to-exclude-tests-from-running-them)
158
159
  - [How to use CodeClimate with knapsack_pro?](#how-to-use-codeclimate-with-knapsack_pro)
159
160
  - [How to run knapsack_pro only on a few parallel CI nodes instead of all?](#how-to-run-knapsack_pro-only-on-a-few-parallel-ci-nodes-instead-of-all)
160
161
  - [How to use simplecov in Queue Mode?](#how-to-use-simplecov-in-queue-mode)
@@ -1864,6 +1865,27 @@ KNAPSACK_PRO_TEST_FILE_PATTERN="spec/features/**{,/*/**}/*_spec.rb" \
1864
1865
  bundle exec rake knapsack_pro:queue:rspec
1865
1866
  ```
1866
1867
 
1868
+ You can also learn [how to use exclude pattern](#how-to-exclude-tests-from-running-them).
1869
+
1870
+ #### How to exclude tests from running them?
1871
+
1872
+ For instance you would like to run all tests except tests in `features` directory then you could do:
1873
+
1874
+ ```
1875
+ KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN="spec/features/**{,/*/**}/*_spec.rb" \
1876
+ bundle exec rake knapsack_pro:queue:rspec
1877
+ ```
1878
+
1879
+ You can define at the same time the pattern for tests you would like to run and the exclude pattern. For instance run all controller tests except admin controller tests.
1880
+
1881
+ ```
1882
+ KNAPSACK_PRO_TEST_FILE_PATTERN="spec/controllers/**{,/*/**}/*_spec.rb" \
1883
+ KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN="spec/controllers/admin/**{,/*/**}/*_spec.rb" \
1884
+ bundle exec rake knapsack_pro:queue:rspec
1885
+ ```
1886
+
1887
+ The test file pattern and exclude pattern support any glob pattern handled by [`Dir.glob`](http://ruby-doc.org/core-2.4.1/Dir.html#method-c-glob).
1888
+
1867
1889
  #### How to use CodeClimate with knapsack_pro?
1868
1890
 
1869
1891
  You can check CodeClimate docs about [parallel and multiple test suites](https://docs.codeclimate.com/docs/configuring-test-coverage#section-parallel-and-multiple-test-suites).
@@ -47,6 +47,10 @@ module KnapsackPro
47
47
  ENV['KNAPSACK_PRO_TEST_FILE_PATTERN']
48
48
  end
49
49
 
50
+ def test_file_exclude_pattern
51
+ ENV['KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN']
52
+ end
53
+
50
54
  def test_dir
51
55
  ENV['KNAPSACK_PRO_TEST_DIR']
52
56
  end
@@ -21,7 +21,16 @@ module KnapsackPro
21
21
  attr_reader :test_file_pattern
22
22
 
23
23
  def test_files
24
- Dir.glob(test_file_pattern).uniq.sort
24
+ test_file_paths = Dir.glob(test_file_pattern).uniq
25
+
26
+ excluded_test_file_paths =
27
+ if KnapsackPro::Config::Env.test_file_exclude_pattern
28
+ Dir.glob(KnapsackPro::Config::Env.test_file_exclude_pattern).uniq
29
+ else
30
+ []
31
+ end
32
+
33
+ (test_file_paths - excluded_test_file_paths).sort
25
34
  end
26
35
 
27
36
  def test_file_hash_for(test_file_path)
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '1.0.2'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -153,6 +153,20 @@ describe KnapsackPro::Config::Env do
153
153
  end
154
154
  end
155
155
 
156
+ describe '.test_file_exclude_pattern' do
157
+ subject { described_class.test_file_exclude_pattern }
158
+
159
+ context 'when ENV exists' do
160
+ let(:test_file_exclude_pattern) { 'spec/features/*_spec.rb' }
161
+ before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN' => test_file_exclude_pattern }) }
162
+ it { should eq test_file_exclude_pattern }
163
+ end
164
+
165
+ context "when ENV doesn't exist" do
166
+ it { should be_nil }
167
+ end
168
+ end
169
+
156
170
  describe '.test_dir' do
157
171
  subject { described_class.test_dir }
158
172
 
@@ -18,18 +18,39 @@ describe KnapsackPro::TestFileFinder do
18
18
 
19
19
  subject { described_class.new(test_file_pattern).call }
20
20
 
21
- it do
22
- should eq([
23
- {
24
- 'path' => 'spec_fake/controllers/users_controller_spec.rb',
25
- },
26
- {
27
- 'path' => 'spec_fake/models/admin_spec.rb',
28
- },
29
- {
30
- 'path' => 'spec_fake/models/user_spec.rb',
31
- },
32
- ])
21
+ context 'when KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN is not defined' do
22
+ it do
23
+ should eq([
24
+ {
25
+ 'path' => 'spec_fake/controllers/users_controller_spec.rb',
26
+ },
27
+ {
28
+ 'path' => 'spec_fake/models/admin_spec.rb',
29
+ },
30
+ {
31
+ 'path' => 'spec_fake/models/user_spec.rb',
32
+ },
33
+ ])
34
+ end
35
+ end
36
+
37
+ context 'when KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN is defined' do
38
+ let(:test_file_exclude_pattern) { 'spec_fake/controllers/*_spec.rb' }
39
+
40
+ before do
41
+ stub_const("ENV", { 'KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN' => test_file_exclude_pattern })
42
+ end
43
+
44
+ it do
45
+ should eq([
46
+ {
47
+ 'path' => 'spec_fake/models/admin_spec.rb',
48
+ },
49
+ {
50
+ 'path' => 'spec_fake/models/user_spec.rb',
51
+ },
52
+ ])
53
+ end
33
54
  end
34
55
  end
35
56
  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: 1.0.2
4
+ version: 1.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: 2018-10-26 00:00:00.000000000 Z
11
+ date: 2018-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake