knapsack_pro 8.1.0 → 8.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9392d6bfe6377c70af5278f4b527314194c5516f5693badc4255d46c989de2c6
4
- data.tar.gz: 559425cde606e2dc159912dd3facf07467c5fa1ac507fced6734c0b655f246bf
3
+ metadata.gz: 0cb3592a7a5f0e3f69138e53d5659954e0e84190ad84380d823e776268d4e900
4
+ data.tar.gz: b40c96cebfb9c4446998291b01c435f6e29cd937a51848593510ed633e56b14b
5
5
  SHA512:
6
- metadata.gz: 35a9edadc691088d01e48fdde8f496d9ed1bebb49d9dff50ffe9887c0238a5bf4b5c4289fcfcc024afd9921b53a8c5a28500ae2a00d0ca860f6ad2bfdae81de4
7
- data.tar.gz: edeea08e31dfe17e0d614922665f93e76e0adbbf8564e56ef0d1f751bb38355e9e3b6f2bbd98d4f2d0ffb6a3ad417318497a150087723cf193b2f4e01f215e9f
6
+ metadata.gz: 8308e34071c72b055335ded1422bb49762c600fffbc86f83a54911dde1cc23db59e472233bd53c1ec558fbf612c11b537587e241774dd8824d14e6665fd914e8
7
+ data.tar.gz: 35829c1ba92de81be2d7b3f5bd428b9fb2a66a8ad3da940f21e196b02b7962ce13f0c453f27c85c3acfce681223b3a83145baf2b26ef12b10a66dcf67f0d9fa3
data/.circleci/config.yml CHANGED
@@ -445,27 +445,27 @@ workflows:
445
445
  name: integration__ruby-<< matrix.ruby >>__rspec-<< matrix.rspec >>
446
446
  matrix:
447
447
  parameters:
448
- ruby: ["3.0", "3.1", "3.2", "3.3"]
449
- rspec: ["3.10.2", "3.11.0", "3.12.2"]
448
+ ruby: ["3.2", "3.3", "3.4"]
449
+ rspec: ["3.12.3", "3.13.3"]
450
450
  - e2e-regular-rspec:
451
451
  name: e2e-regular__ruby-<< matrix.ruby >>__rspec-<< matrix.rspec >>
452
452
  matrix:
453
453
  parameters:
454
- ruby: ["3.0", "3.1", "3.2", "3.3"]
455
- rspec: ["3.10.2", "3.11.0", "3.12.2"]
454
+ ruby: ["3.2", "3.3", "3.4"]
455
+ rspec: ["3.12.3", "3.13.3"]
456
456
  - e2e-queue-rspec:
457
457
  name: e2e-queue__ruby-<< matrix.ruby >>__rspec-<< matrix.rspec >>
458
458
  matrix:
459
459
  parameters:
460
- ruby: ["3.0", "3.1", "3.2", "3.3"]
461
- rspec: ["3.10.2", "3.11.0", "3.12.2"]
460
+ ruby: ["3.2", "3.3", "3.4"]
461
+ rspec: ["3.12.3", "3.13.3"]
462
462
  - e2e-regular-minitest:
463
463
  name: e2e-regular__ruby-<< matrix.ruby >>__minitest
464
464
  matrix:
465
465
  parameters:
466
- ruby: ["3.0", "3.1", "3.2", "3.3"]
466
+ ruby: ["3.2", "3.3", "3.4"]
467
467
  - e2e-queue-minitest:
468
468
  name: e2e-queue__ruby-<< matrix.ruby >>__minitest
469
469
  matrix:
470
470
  parameters:
471
- ruby: ["3.0", "3.1", "3.2", "3.3"]
471
+ ruby: ["3.2", "3.3", "3.4"]
data/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # Changelog
2
2
 
3
+ ### 8.1.2
4
+
5
+ * Allow running RSpec with `--force-color` (and the default Split by Test Examples)
6
+
7
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/298
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.1.1...v8.1.2
10
+
11
+ ### 8.1.1
12
+
13
+ * Do not load Rake tasks on behalf of the user for RSpec and Minitest in Queue Mode
14
+
15
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/297
16
+
17
+ Workarounds like [this one](https://docs.knapsackpro.com/ruby/troubleshooting/#rake-tasks-under-tests-are-run-more-than-once-in-queue-mode) are no more needed to test Rake tasks, you can now remove them and test Rake tasks like you would normally do:
18
+
19
+ RSpec:
20
+
21
+ ```ruby
22
+ before do
23
+ MY_APPLICATION_NAME::Application.load_tasks if Rake::Task.tasks.empty?
24
+ end
25
+
26
+ after do
27
+ Rake::Task[MY_TASK_NAME].reenable
28
+ end
29
+
30
+ it "tests the rake task" do
31
+ Rake::Task[MY_TASK_NAME].invoke
32
+ # ...
33
+ end
34
+ ```
35
+
36
+ Minitest:
37
+
38
+ ```ruby
39
+ setup do
40
+ MY_APPLICATION_NAME::Application.load_tasks if Rake::Task.tasks.empty?
41
+ end
42
+
43
+ teardown do
44
+ Rake::Task[MY_TASK_NAME].reenable
45
+ end
46
+
47
+ test "tests the rake task" do
48
+ Rake::Task[MY_TASK_NAME].invoke
49
+ # ...
50
+ end
51
+ ```
52
+
53
+ It's also ok to use `Rake.application.rake_require("tasks/MY_TASK")` instead of `MY_APPLICATION_NAME::Application.load_tasks if Rake::Task.tasks.empty?`.
54
+
55
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.1.0...v8.1.1
56
+
3
57
  ### 8.1.0
4
58
 
5
59
  * Improve the performance of the [RSpec split by test examples](https://docs.knapsackpro.com/ruby/split-by-test-examples/).
@@ -33,32 +33,22 @@ module KnapsackPro
33
33
  # Apply a --format option which overrides formatters from the RSpec custom option files like `.rspec`.
34
34
  cli_args = cli_args_without_formatters + cli_format + [
35
35
  '--dry-run',
36
- '--no-color',
37
36
  '--out', report_path,
38
- '--default-path', test_dir,
37
+ '--default-path', test_dir
39
38
  ] + KnapsackPro::TestFilePresenter.paths(test_file_entities)
40
- options = ::RSpec::Core::ConfigurationOptions.new(cli_args)
41
- exit_code = ::RSpec::Core::Runner.new(options).run($stderr, $stdout)
42
- if exit_code != 0
43
- debug_cmd = ([
44
- 'bundle exec rspec',
45
- ] + cli_args).join(' ')
46
-
47
- KnapsackPro.logger.error('-'*10 + ' START of actionable error message ' + '-'*50)
48
- KnapsackPro.logger.error('RSpec (with a dry-run option) had a problem generating the report with test examples for the slow test files. Here is what you can do:')
49
-
50
- KnapsackPro.logger.error("a) Please look for an error message from RSpec in the output above or below. If you don't see anything, that is fine. Sometimes RSpec does not produce any errors in the output.")
51
-
52
- KnapsackPro.logger.error("b) Check if RSpec generated the report file #{report_path}. If the report exists, it may contain an error message. Here is a preview of the report file:")
53
- KnapsackPro.logger.error(report_content || 'N/A')
54
-
55
- KnapsackPro.logger.error('c) To reproduce the error manually, please run the following RSpec command. This way, you can find out what is causing the error. Please ensure you run the command in the same environment where the error occurred. For instance, if the error happens on the CI server, you should run the command in the CI environment:')
56
- KnapsackPro.logger.error(debug_cmd)
39
+ exit_code = begin
40
+ options = ::RSpec::Core::ConfigurationOptions.new(cli_args)
41
+ ::RSpec::Core::Runner.new(options).run($stderr, $stdout)
42
+ rescue SystemExit => e
43
+ e.status
44
+ end
57
45
 
58
- KnapsackPro.logger.error('-'*10 + ' END of actionable error message ' + '-'*50)
46
+ return if exit_code.zero?
59
47
 
60
- raise 'There was a problem while generating test examples for the slow test files. Please read the actionable error message above.'
61
- end
48
+ report.fetch('messages', []).each { |message| puts message }
49
+ command = (['bundle exec rspec'] + cli_args).join(' ')
50
+ KnapsackPro.logger.error("Failed to generate the slow test files report: #{command}")
51
+ exit exit_code
62
52
  end
63
53
 
64
54
  def test_file_example_paths
@@ -92,8 +82,9 @@ module KnapsackPro
92
82
  "#{report_dir}/rspec_dry_run_json_report_node_#{KnapsackPro::Config::Env.ci_node_index}.json"
93
83
  end
94
84
 
95
- def report_content
96
- File.read(report_path) if File.exist?(report_path)
85
+ def report
86
+ return {} unless File.exist?(report_path)
87
+ JSON.parse(File.read(report_path))
97
88
  end
98
89
 
99
90
  def adapter_class
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KnapsackPro
4
- VERSION = '8.1.0'
4
+ VERSION = '8.1.2'
5
5
  end
@@ -9,6 +9,7 @@ namespace :knapsack_pro do
9
9
  end
10
10
 
11
11
  task :minitest_go, [:minitest_args] do |_, args|
12
+ Rake::Task.clear
12
13
  KnapsackPro::Runners::Queue::MinitestRunner.run(args[:minitest_args])
13
14
  end
14
15
  end
@@ -9,6 +9,7 @@ namespace :knapsack_pro do
9
9
  end
10
10
 
11
11
  task :rspec_go, [:rspec_args] do |_, args|
12
+ Rake::Task.clear
12
13
  KnapsackPro::Runners::Queue::RSpecRunner.run(args[:rspec_args])
13
14
  end
14
15
  end
@@ -48,7 +48,6 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
48
48
  expect(RSpec::Core::ConfigurationOptions).to receive(:new).with(expected_args + [
49
49
  '--format', expected_format,
50
50
  '--dry-run',
51
- '--no-color',
52
51
  '--out', report_path,
53
52
  '--default-path', test_dir,
54
53
  'spec/a_spec.rb', 'spec/b_spec.rb',
@@ -78,7 +77,7 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
78
77
  end
79
78
 
80
79
  it do
81
- expect { subject }.to raise_error(RuntimeError, 'There was a problem while generating test examples for the slow test files. Please read the actionable error message above.')
80
+ expect { subject }.to raise_error(SystemExit) { |error| expect(error.status).to eq exit_code }
82
81
  end
83
82
  end
84
83
  end
@@ -123,6 +122,36 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
123
122
  expect { subject }.to raise_error("The internal KNAPSACK_PRO_RSPEC_OPTIONS environment variable is unset. Ensure it is not overridden accidentally. Otherwise, please report this as a bug: https://knapsackpro.com/perma/ruby/support")
124
123
  end
125
124
  end
125
+
126
+ context 'with --force-color' do
127
+ let(:rspec_args) { '--force-color' }
128
+ let(:expected_args) { ['--force-color'] }
129
+ let(:expected_format) { 'json' }
130
+
131
+ it_behaves_like 'generate_json_report runs RSpec::Core::Runner'
132
+ end
133
+
134
+ context 'with --no-color and --force-color' do
135
+ let(:rspec_args) { '--no-color --force-color' }
136
+
137
+ after { KnapsackPro.reset_logger! }
138
+
139
+ it do
140
+ subject_class = Class.new(KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector) do
141
+ define_method(:slow_test_files) do
142
+ [{ 'path' => 'spec/a_spec.rb' }]
143
+ end
144
+ end
145
+
146
+ expect do
147
+ KnapsackPro.logger = ::Logger.new($stdout)
148
+ subject_class.new.generate_json_report(rspec_args)
149
+ end
150
+ .to output(/Please only use one of `--force-color` and `--no-color`/).to_stderr
151
+ .and output(%r{ERROR -- : \[knapsack_pro\] Failed to generate the slow test files report: bundle exec rspec --no-color --force-color --format json --dry-run --out .knapsack_pro/test_case_detectors/rspec/rspec_dry_run_json_report_node_0.json --default-path spec spec/a_spec.rb}).to_stdout
152
+ .and raise_error(SystemExit) { |error| expect(error.status).to eq 1 }
153
+ end
154
+ end
126
155
  end
127
156
 
128
157
  describe '#test_file_example_paths' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.0
4
+ version: 8.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-25 00:00:00.000000000 Z
10
+ date: 2025-04-17 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake