knapsack_pro 3.6.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,8 +38,8 @@ module KnapsackPro
38
38
  else
39
39
  puts "\n\n"
40
40
  KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50)
41
- KnapsackPro.logger.error("You forgot to call #{self}.bind method in your test runner configuration file. It is needed to record test files time execution. Please follow the installation guide to configure your project properly https://docs.knapsackpro.com/knapsack_pro-ruby/guide/")
42
- KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must have deleted the .knapsack_pro directory from the disk accidentally. Please ensure you do not remove the .knapsack_pro directory: https://knapsackpro.com/faq/question/why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard")
41
+ KnapsackPro.logger.error("You forgot to call #{self}.bind method in your test runner configuration file. It is needed to record test files time execution. Please follow the installation guide to configure your project properly #{KnapsackPro::Urls::INSTALLATION_GUIDE}")
42
+ KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must have deleted the .knapsack_pro directory from the disk accidentally. Please ensure you do not remove the .knapsack_pro directory: #{KnapsackPro::Urls::DASHBOARD__ZEROISH_TEST_EXECUTION_TIMES}")
43
43
  Kernel.exit(1)
44
44
  end
45
45
  end
@@ -5,7 +5,7 @@ module KnapsackPro
5
5
 
6
6
  def self.ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!(cli_args)
7
7
  if KnapsackPro::Config::Env.rspec_split_by_test_examples? && has_tag_option?(cli_args)
8
- error_message = 'It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature. Please see: https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it#warning-dont-use-rspec-tag-option'
8
+ error_message = "It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature. Please see: #{KnapsackPro::Urls::RSPEC__SPLIT_BY_TEST_EXAMPLES__TAG}"
9
9
  KnapsackPro.logger.error(error_message)
10
10
  raise error_message
11
11
  end
@@ -48,12 +48,16 @@ module KnapsackPro
48
48
  end
49
49
 
50
50
  config.around(:each) do |example|
51
- # stop timer to update time for a previously run test example
52
- # this way we count time spend in runtime for the previous test example after around(:each) is already done
53
- KnapsackPro.tracker.stop_timer
54
-
55
51
  current_test_path = KnapsackPro::Adapters::RSpecAdapter.test_path(example)
56
52
 
53
+ # Stop timer to update time for a previously run test example.
54
+ # This way we count time spent in runtime for the previous test example after around(:each) is already done.
55
+ # Only do that if we're in the same test file. Otherwise, `before(:all)` execution time in the current file
56
+ # will be applied to the previously ran test file.
57
+ if KnapsackPro.tracker.current_test_path&.start_with?(KnapsackPro::TestFileCleaner.clean(current_test_path))
58
+ KnapsackPro.tracker.stop_timer
59
+ end
60
+
57
61
  KnapsackPro.tracker.current_test_path =
58
62
  if KnapsackPro::Config::Env.rspec_split_by_test_examples? && KnapsackPro::Adapters::RSpecAdapter.slow_test_file?(RSpecAdapter, current_test_path)
59
63
  example.id
@@ -62,7 +66,7 @@ module KnapsackPro
62
66
  end
63
67
 
64
68
  if example.metadata[:focus] && KnapsackPro::Adapters::RSpecAdapter.rspec_configuration.filter.rules[:focus]
65
- raise "We detected a test file path #{current_test_path} with a test using the metadata `:focus` tag. RSpec might not run some tests in the Queue Mode (causing random tests skipping problem). Please remove the `:focus` tag from your codebase. See more: https://knapsackpro.com/faq/question/rspec-is-not-running-some-tests"
69
+ raise "We detected a test file path #{current_test_path} with a test using the metadata `:focus` tag. RSpec might not run some tests in the Queue Mode (causing random tests skipping problem). Please remove the `:focus` tag from your codebase. See more: #{KnapsackPro::Urls::RSPEC__SKIPS_TESTS}"
66
70
  end
67
71
 
68
72
  example.run
@@ -119,7 +123,7 @@ module KnapsackPro
119
123
  # and didn't notice the class name changed
120
124
  class RspecAdapter < RSpecAdapter
121
125
  def self.bind
122
- error_message = 'You have attempted to call KnapsackPro::Adapters::RspecAdapter.bind. Please switch to using the new class name: KnapsackPro::Adapters::RSpecAdapter. See https://docs.knapsackpro.com/knapsack_pro-ruby/guide for up-to-date configuration instructions.'
126
+ error_message = "You have attempted to call KnapsackPro::Adapters::RspecAdapter.bind. Please switch to using the new class name: KnapsackPro::Adapters::RSpecAdapter. See #{KnapsackPro::Urls::INSTALLATION_GUIDE} for up-to-date configuration instructions."
123
127
  KnapsackPro.logger.error(error_message)
124
128
  raise error_message
125
129
  end
@@ -24,7 +24,7 @@ module KnapsackPro
24
24
  end
25
25
 
26
26
  unless found_valid_test_file_path
27
- KnapsackPro.logger.warn('cannot detect a valid test file path. Probably the test file contains only shared examples. Please add test cases to your test file. Read more at https://github.com/KnapsackPro/knapsack_pro-ruby/pull/123')
27
+ KnapsackPro.logger.warn("cannot detect a valid test file path. Probably the test file contains only shared examples. Please add test cases to your test file. Read more at #{KnapsackPro::Urls::TEST_UNIT__TEST_FILE_PATH_DETECTION}")
28
28
  KnapsackPro.logger.warn("See test file for #{obj.inspect}")
29
29
  end
30
30
 
@@ -25,18 +25,18 @@ module KnapsackPro
25
25
  raise ArgumentError.new(response) if connection.errors?
26
26
  prepare_test_files(response)
27
27
  elsif !KnapsackPro::Config::Env.fallback_mode_enabled?
28
- message = 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode'
28
+ message = "Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to #{KnapsackPro::Urls::REGULAR_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE}"
29
29
  KnapsackPro.logger.error(message)
30
30
  raise message
31
31
  elsif KnapsackPro::Config::Env.ci_node_retry_count > 0
32
- message = 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode'
32
+ message = "knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more #{KnapsackPro::Urls::REGULAR_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT}"
33
33
  unless KnapsackPro::Config::Env.fixed_test_suite_split?
34
- message += ' Please ensure you have set KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://github.com/KnapsackPro/knapsack_pro-ruby#knapsack_pro_fixed_test_suite_split-test-suite-split-based-on-seed'
34
+ message += " Please ensure you have set KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more #{KnapsackPro::Urls::FIXED_TEST_SUITE_SPLIT}"
35
35
  end
36
36
  KnapsackPro.logger.error(message)
37
37
  raise message
38
38
  else
39
- KnapsackPro.logger.warn("Fallback mode started. We could not connect with Knapsack Pro API. Your tests will be executed based on directory names. Read more about fallback mode at https://knapsackpro.com/faq/question/what-happens-when-knapsack-pro-api-is-not-availablenot-reachable-temporarily")
39
+ KnapsackPro.logger.warn("Fallback mode started. We could not connect with Knapsack Pro API. Your tests will be executed based on directory names. Read more about fallback mode at #{KnapsackPro::Urls::FALLBACK_MODE}")
40
40
  fallback_test_files
41
41
  end
42
42
  end
@@ -36,7 +36,7 @@ module KnapsackPro
36
36
  if adapter_class == KnapsackPro::Adapters::RSpecAdapter && KnapsackPro::Config::Env.rspec_split_by_test_examples?
37
37
  require 'rspec/core/version'
38
38
  unless Gem::Version.new(::RSpec::Core::Version::STRING) >= Gem::Version.new('3.3.0')
39
- raise 'RSpec >= 3.3.0 is required to split test files by test examples. Learn more: https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases'
39
+ raise "RSpec >= 3.3.0 is required to split test files by test examples. Learn more: #{KnapsackPro::Urls::SPLIT_BY_TEST_EXAMPLES}"
40
40
  end
41
41
 
42
42
  slow_test_files = get_slow_test_files
@@ -31,7 +31,7 @@ module KnapsackPro
31
31
  raise ArgumentError.new(response) if connection.errors?
32
32
  BuildDistributionEntity.new(response)
33
33
  else
34
- KnapsackPro.logger.warn("Slow test files fallback behaviour started. We could not connect with Knapsack Pro API to fetch last CI build test files that are needed to determine slow test files. No test files will be split by test cases. It means all test files will be split by the whole test files as if split by test cases would be disabled https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases")
34
+ KnapsackPro.logger.warn("Slow test files fallback behaviour started. We could not connect with Knapsack Pro API to fetch last CI build test files that are needed to determine slow test files. No test files will be split by test cases. It means all test files will be split by the whole test files as if split by test cases would be disabled #{KnapsackPro::Urls::SPLIT_BY_TEST_EXAMPLES}")
35
35
  BuildDistributionEntity.new({
36
36
  'time_execution' => 0.0,
37
37
  'test_files' => [],
@@ -27,19 +27,19 @@ module KnapsackPro
27
27
  raise ArgumentError.new(response) if connection.errors?
28
28
  prepare_test_files(response)
29
29
  elsif !KnapsackPro::Config::Env.fallback_mode_enabled?
30
- message = 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode'
30
+ message = "Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to #{KnapsackPro::Urls::QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE}"
31
31
  KnapsackPro.logger.error(message)
32
32
  raise message
33
33
  elsif KnapsackPro::Config::Env.ci_node_retry_count > 0
34
- message = 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode'
34
+ message = "knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more #{KnapsackPro::Urls::QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT}"
35
35
  unless KnapsackPro::Config::Env.fixed_queue_split?
36
- message += ' Please ensure you have set KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://github.com/KnapsackPro/knapsack_pro-ruby#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node'
36
+ message += " Please ensure you have set KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more #{KnapsackPro::Urls::FIXED_QUEUE_SPLIT}"
37
37
  end
38
38
  KnapsackPro.logger.error(message)
39
39
  raise message
40
40
  else
41
41
  @fallback_activated = true
42
- KnapsackPro.logger.warn("Fallback mode started. We could not connect with Knapsack Pro API. Your tests will be executed based on directory names. If other CI nodes were able to connect with Knapsack Pro API then you may notice that some of the test files will be executed twice across CI nodes. The most important thing is to guarantee each of test files is run at least once! Read more about fallback mode at https://knapsackpro.com/faq/question/what-happens-when-knapsack-pro-api-is-not-availablenot-reachable-temporarily")
42
+ KnapsackPro.logger.warn("Fallback mode started. We could not connect with Knapsack Pro API. Your tests will be executed based on directory names. If other CI nodes were able to connect with Knapsack Pro API then you may notice that some of the test files will be executed twice across CI nodes. The most important thing is to guarantee each of test files is run at least once! Read more about fallback mode at #{KnapsackPro::Urls::FALLBACK_MODE}")
43
43
  fallback_test_files(executed_test_files)
44
44
  end
45
45
  end
@@ -47,7 +47,7 @@ module KnapsackPro
47
47
  if test_files.size > 0 && measured_test_files.size == 0
48
48
  KnapsackPro.logger.warn("#{test_files.size} test files were executed on this CI node but the recorded time was lost due to:")
49
49
  KnapsackPro.logger.warn("1. Please ensure you do not remove the contents of the .knapsack_pro directory between tests run.")
50
- KnapsackPro.logger.warn("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/")
50
+ KnapsackPro.logger.warn("2. Ensure you've added Knapsack::Adapters::RSpecAdapter.bind in your rails_helper.rb or spec_helper.rb. Please follow the installation guide again: #{KnapsackPro::Urls::INSTALLATION_GUIDE}")
51
51
  KnapsackPro.logger.warn("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.")
52
52
  end
53
53
 
@@ -20,7 +20,7 @@ module KnapsackPro
20
20
  end
21
21
 
22
22
  def self.read_from_json_report
23
- raise '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!' unless File.exist?(report_path)
23
+ raise "The report with slow test files has not been generated yet. If you have enabled split by test cases #{KnapsackPro::Urls::SPLIT_BY_TEST_EXAMPLES} 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!" unless File.exist?(report_path)
24
24
  slow_test_files_json_report = File.read(report_path)
25
25
  JSON.parse(slow_test_files_json_report)
26
26
  end
@@ -6,7 +6,7 @@ module KnapsackPro
6
6
  # Returns slow test files.
7
7
  def self.call(adapter_class)
8
8
  if KnapsackPro::Config::Env.test_files_encrypted?
9
- raise 'Split by test cases is not possible when you have enabled test file names encryption ( https://github.com/KnapsackPro/knapsack_pro-ruby#test-file-names-encryption ). You need to disable encryption with KNAPSACK_PRO_TEST_FILES_ENCRYPTED=false in order to use split by test cases https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases'
9
+ raise "Split by test cases is not possible when you have enabled test file names encryption ( #{KnapsackPro::Urls::ENCRYPTION} ). You need to disable encryption with KNAPSACK_PRO_TEST_FILES_ENCRYPTED=false in order to use split by test cases #{KnapsackPro::Urls::SPLIT_BY_TEST_EXAMPLES}"
10
10
  end
11
11
 
12
12
  # get list of recorded test files for last CI Build
@@ -46,7 +46,8 @@ module KnapsackPro
46
46
  end
47
47
 
48
48
  def current_test_path
49
- raise("current_test_path needs to be set by Knapsack Pro Adapter's bind method") unless @current_test_path
49
+ return unless @current_test_path
50
+
50
51
  KnapsackPro::TestFileCleaner.clean(@current_test_path)
51
52
  end
52
53
 
@@ -111,7 +112,7 @@ module KnapsackPro
111
112
  end
112
113
 
113
114
  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
+ 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 #{KnapsackPro::Urls::SUPPORT}" unless File.exist?(prerun_tests_report_path)
115
116
  JSON.parse(File.read(prerun_tests_report_path))
116
117
  end
117
118
 
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KnapsackPro
4
+ module Urls
5
+ HOST = 'https://knapsackpro.com'
6
+
7
+ SUPPORT = "#{HOST}/perma/ruby/support"
8
+
9
+ DASHBOARD__ZEROISH_TEST_EXECUTION_TIMES = "#{HOST}/perma/ruby/dashboard-zeroish-test-execution-times"
10
+
11
+ ENCRYPTION = "#{HOST}/perma/ruby/encryption"
12
+
13
+ FALLBACK_MODE = "#{HOST}/perma/ruby/fallback-mode"
14
+
15
+ FIXED_QUEUE_SPLIT = "#{HOST}/perma/ruby/fixed-queue-split"
16
+
17
+ FIXED_TEST_SUITE_SPLIT = "#{HOST}/perma/ruby/fixed-test-suite-split"
18
+
19
+ INSTALLATION_GUIDE = "#{HOST}/perma/ruby/installation-guide"
20
+
21
+ QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE = "#{HOST}/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false"
22
+
23
+ QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT = "#{HOST}/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count"
24
+
25
+ REGULAR_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE = "#{HOST}/perma/ruby/regular-mode-connection-error-with-fallback-enabled-false"
26
+
27
+ REGULAR_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT = "#{HOST}/perma/ruby/regular-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count"
28
+
29
+ RSPEC__SKIPS_TESTS = "#{HOST}/perma/ruby/rspec-skips-tests"
30
+
31
+ RSPEC__SPLIT_BY_TEST_EXAMPLES__TAG = "#{HOST}/perma/ruby/rspec-split-by-test-examples-tag"
32
+
33
+ SPLIT_BY_TEST_EXAMPLES = "#{HOST}/perma/ruby/split-by-test-examples"
34
+
35
+ TEST_UNIT__TEST_FILE_PATH_DETECTION = "#{HOST}/perma/ruby/test-unit-test-file-path-detection"
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '3.6.0'
2
+ VERSION = '3.8.0'
3
3
  end
data/lib/knapsack_pro.rb CHANGED
@@ -6,6 +6,7 @@ require 'uri'
6
6
  require 'rake/testtask'
7
7
  require 'digest'
8
8
  require 'securerandom'
9
+ require_relative 'knapsack_pro/urls'
9
10
  require_relative 'knapsack_pro/version'
10
11
  require_relative 'knapsack_pro/extensions/time'
11
12
  require_relative 'knapsack_pro/hooks/queue'
@@ -243,6 +243,7 @@ describe KnapsackPro::Adapters::RSpecAdapter do
243
243
  expect(config).to receive(:around).with(:each).and_yield(current_example)
244
244
  expect(::RSpec).to receive(:configure).and_yield(config)
245
245
 
246
+ expect(tracker).to receive(:current_test_path).ordered.and_return(test_path)
246
247
  expect(tracker).to receive(:stop_timer).ordered
247
248
 
248
249
  expect(described_class).to receive(:test_path).with(current_example).and_return(test_path)
@@ -273,6 +274,7 @@ describe KnapsackPro::Adapters::RSpecAdapter do
273
274
  expect(config).to receive(:after).with(:suite).and_yield
274
275
  expect(::RSpec).to receive(:configure).and_yield(config)
275
276
 
277
+ expect(tracker).to receive(:current_test_path).ordered.and_return(test_path)
276
278
  expect(tracker).to receive(:stop_timer).ordered
277
279
 
278
280
  expect(described_class).to receive(:test_path).with(current_example).and_return(test_path)
@@ -316,6 +318,7 @@ describe KnapsackPro::Adapters::RSpecAdapter do
316
318
  expect(config).to receive(:after).with(:suite).and_yield
317
319
  expect(::RSpec).to receive(:configure).and_yield(config)
318
320
 
321
+ expect(tracker).to receive(:current_test_path).ordered.and_return(test_path)
319
322
  expect(tracker).to receive(:stop_timer).ordered
320
323
 
321
324
  expect(described_class).to receive(:test_path).with(current_example).and_return(test_path)
@@ -352,6 +355,7 @@ describe KnapsackPro::Adapters::RSpecAdapter do
352
355
 
353
356
  expect(described_class).to receive(:test_path).with(current_example).and_return(test_path)
354
357
 
358
+ expect(tracker).to receive(:current_test_path).ordered.and_return(test_path)
355
359
  expect(tracker).to receive(:stop_timer).ordered
356
360
 
357
361
  expect(tracker).to receive(:current_test_path=).with(test_path).ordered
@@ -28,7 +28,7 @@ describe KnapsackPro::Allocator do
28
28
  end
29
29
 
30
30
  it do
31
- expect { subject }.to raise_error(RuntimeError, 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode')
31
+ expect { subject }.to raise_error(RuntimeError, 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-false')
32
32
  end
33
33
  end
34
34
 
@@ -43,7 +43,7 @@ describe KnapsackPro::Allocator do
43
43
  end
44
44
 
45
45
  it do
46
- expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode')
46
+ expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
47
47
  end
48
48
  end
49
49
 
@@ -53,7 +53,7 @@ describe KnapsackPro::Allocator do
53
53
  end
54
54
 
55
55
  it do
56
- expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode Please ensure you have set KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://github.com/KnapsackPro/knapsack_pro-ruby#knapsack_pro_fixed_test_suite_split-test-suite-split-based-on-seed')
56
+ expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/regular-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count Please ensure you have set KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://knapsackpro.com/perma/ruby/fixed-test-suite-split')
57
57
  end
58
58
  end
59
59
  end
@@ -149,7 +149,7 @@ describe KnapsackPro::BaseAllocatorBuilder do
149
149
  end
150
150
 
151
151
  it do
152
- expect { subject }.to raise_error RuntimeError, 'RSpec >= 3.3.0 is required to split test files by test examples. Learn more: https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases'
152
+ expect { subject }.to raise_error RuntimeError, 'RSpec >= 3.3.0 is required to split test files by test examples. Learn more: https://knapsackpro.com/perma/ruby/split-by-test-examples'
153
153
  end
154
154
  end
155
155
 
@@ -31,7 +31,7 @@ describe KnapsackPro::QueueAllocator do
31
31
  end
32
32
 
33
33
  it do
34
- expect { subject }.to raise_error(RuntimeError, 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode')
34
+ expect { subject }.to raise_error(RuntimeError, 'Fallback Mode was disabled with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false. Please restart this CI node to retry tests. Most likely Fallback Mode was disabled due to https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false')
35
35
  end
36
36
  end
37
37
 
@@ -46,7 +46,7 @@ describe KnapsackPro::QueueAllocator do
46
46
  end
47
47
 
48
48
  it do
49
- expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode')
49
+ expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count')
50
50
  end
51
51
  end
52
52
 
@@ -56,7 +56,7 @@ describe KnapsackPro::QueueAllocator do
56
56
  end
57
57
 
58
58
  it do
59
- expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://github.com/KnapsackPro/knapsack_pro-ruby#required-ci-configuration-if-you-use-retry-single-failed-ci-node-feature-on-your-ci-server-when-knapsack_pro_fixed_queue_splittrue-in-queue-mode-or-knapsack_pro_fixed_test_suite_splittrue-in-regular-mode Please ensure you have set KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://github.com/KnapsackPro/knapsack_pro-ruby#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node')
59
+ expect { subject }.to raise_error(RuntimeError, 'knapsack_pro gem could not connect to Knapsack Pro API and the Fallback Mode cannot be used this time. Running tests in Fallback Mode are not allowed for retried parallel CI node to avoid running the wrong set of tests. Please manually retry this parallel job on your CI server then knapsack_pro gem will try to connect to Knapsack Pro API again and will run a correct set of tests for this CI node. Learn more https://knapsackpro.com/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count Please ensure you have set KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true to allow Knapsack Pro API remember the recorded CI node tests so when you retry failed tests on the CI node then the same set of tests will be executed. See more https://knapsackpro.com/perma/ruby/fixed-queue-split')
60
60
  end
61
61
  end
62
62
  end
@@ -105,7 +105,7 @@ describe KnapsackPro::Report do
105
105
  expect(KnapsackPro).to receive(:logger).exactly(4).and_return(logger)
106
106
  expect(logger).to receive(:warn).with('2 test files were executed on this CI node but the recorded time was lost due to:')
107
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/")
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://knapsackpro.com/perma/ruby/installation-guide")
109
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.')
110
110
 
111
111
  expect(described_class).to receive(:create_build_subset).with(
@@ -84,7 +84,7 @@ describe KnapsackPro::SlowTestFileDeterminer do
84
84
 
85
85
  context 'when json report does not exist' do
86
86
  it do
87
- 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!')
87
+ 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://knapsackpro.com/perma/ruby/split-by-test-examples 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!')
88
88
  end
89
89
  end
90
90
  end
@@ -36,7 +36,7 @@ describe KnapsackPro::SlowTestFileFinder do
36
36
  let(:test_files_encrypted?) { true }
37
37
 
38
38
  it do
39
- expect { subject }.to raise_error RuntimeError, 'Split by test cases is not possible when you have enabled test file names encryption ( https://github.com/KnapsackPro/knapsack_pro-ruby#test-file-names-encryption ). You need to disable encryption with KNAPSACK_PRO_TEST_FILES_ENCRYPTED=false in order to use split by test cases https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases'
39
+ expect { subject }.to raise_error RuntimeError, 'Split by test cases is not possible when you have enabled test file names encryption ( https://knapsackpro.com/perma/ruby/encryption ). You need to disable encryption with KNAPSACK_PRO_TEST_FILES_ENCRYPTED=false in order to use split by test cases https://knapsackpro.com/perma/ruby/split-by-test-examples'
40
40
  end
41
41
  end
42
42
  end
@@ -19,9 +19,7 @@ describe KnapsackPro::Tracker do
19
19
  subject { tracker.current_test_path }
20
20
 
21
21
  context 'when current_test_path not set' do
22
- it do
23
- expect { subject }.to raise_error("current_test_path needs to be set by Knapsack Pro Adapter's bind method")
24
- end
22
+ it { should eql nil }
25
23
  end
26
24
 
27
25
  context 'when current_test_path set' do
@@ -104,6 +102,7 @@ describe KnapsackPro::Tracker do
104
102
  before do
105
103
  test_paths.each_with_index do |test_path, index|
106
104
  tracker.current_test_path = test_path
105
+ sleep 0.001
107
106
  tracker.stop_timer
108
107
  end
109
108
  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: 3.6.0
4
+ version: 3.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-09 00:00:00.000000000 Z
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -190,6 +190,8 @@ extensions: []
190
190
  extra_rdoc_files: []
191
191
  files:
192
192
  - ".circleci/config.yml"
193
+ - ".github/assets/install-button.png"
194
+ - ".github/assets/knapsack-diamonds.png"
193
195
  - ".gitignore"
194
196
  - ".rspec"
195
197
  - CHANGELOG.md
@@ -276,6 +278,7 @@ files:
276
278
  - lib/knapsack_pro/test_files_with_test_cases_composer.rb
277
279
  - lib/knapsack_pro/test_flat_distributor.rb
278
280
  - lib/knapsack_pro/tracker.rb
281
+ - lib/knapsack_pro/urls.rb
279
282
  - lib/knapsack_pro/utils.rb
280
283
  - lib/knapsack_pro/version.rb
281
284
  - lib/tasks/cucumber.rake
@@ -405,7 +408,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
405
408
  - !ruby/object:Gem::Version
406
409
  version: '0'
407
410
  requirements: []
408
- rubygems_version: 3.3.7
411
+ rubygems_version: 3.2.3
409
412
  signing_key:
410
413
  specification_version: 4
411
414
  summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel