From c35af5d98590a1956c0edbdc1482b574d8353d0e Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Sat, 2 Jan 2021 23:34:35 +0100 Subject: [PATCH 01/24] Verify test runner adapter bind method is called to track test files time execution --- lib/knapsack_pro/adapters/base_adapter.rb | 16 ++++++++++++++++ lib/knapsack_pro/runners/rspec_runner.rb | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/knapsack_pro/adapters/base_adapter.rb b/lib/knapsack_pro/adapters/base_adapter.rb index acce5d1d..26c093bd 100644 --- a/lib/knapsack_pro/adapters/base_adapter.rb +++ b/lib/knapsack_pro/adapters/base_adapter.rb @@ -3,6 +3,8 @@ module Adapters class BaseAdapter # Just example, please overwrite constant in subclass TEST_DIR_PATTERN = 'test/**{,/*/**}/*_test.rb' + TMP_KNAPSACK_PRO_DIR = 'tmp/knapsack_pro' + ADAPTER_BIND_METHOD_CALLED_FILE = "#{TMP_KNAPSACK_PRO_DIR}/adapter_bind_method_called.txt" def self.slow_test_file?(adapter_class, test_file_path) @slow_test_file_paths ||= @@ -26,7 +28,21 @@ def self.bind adapter end + def self.verify_bind_method_called + ::Kernel.at_exit do + if File.exists?(ADAPTER_BIND_METHOD_CALLED_FILE) + File.delete(ADAPTER_BIND_METHOD_CALLED_FILE) + else + KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50) + raise "You forgot to call #{self}.bind method for your test runner to record test files time execution. Please follow installation guide to configure your project properly https://docs.knapsackpro.com/knapsack_pro-ruby/guide/" + end + end + end + def bind + FileUtils.mkdir_p(TMP_KNAPSACK_PRO_DIR) + File.write(ADAPTER_BIND_METHOD_CALLED_FILE, nil) + if KnapsackPro::Config::Env.recording_enabled? KnapsackPro.logger.debug('Test suite time execution recording enabled.') bind_time_tracker diff --git a/lib/knapsack_pro/runners/rspec_runner.rb b/lib/knapsack_pro/runners/rspec_runner.rb index ddfd3b3a..b4511c99 100644 --- a/lib/knapsack_pro/runners/rspec_runner.rb +++ b/lib/knapsack_pro/runners/rspec_runner.rb @@ -5,9 +5,12 @@ def self.run(args) ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_rspec ENV['KNAPSACK_PRO_RECORDING_ENABLED'] = 'true' - runner = new(KnapsackPro::Adapters::RSpecAdapter) + adapter_class = KnapsackPro::Adapters::RSpecAdapter + runner = new(adapter_class) if runner.test_files_to_execute_exist? + adapter_class.verify_bind_method_called + require 'rspec/core/rake_task' task_name = 'knapsack_pro:rspec_run' From 6a56e11e8cbe201bf4d4ace169793a6dbdf32579 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Sat, 2 Jan 2021 23:43:05 +0100 Subject: [PATCH 02/24] Update rspec_runner_spec.rb --- spec/knapsack_pro/runners/rspec_runner_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/knapsack_pro/runners/rspec_runner_spec.rb b/spec/knapsack_pro/runners/rspec_runner_spec.rb index 90a8df30..8fcc3083 100644 --- a/spec/knapsack_pro/runners/rspec_runner_spec.rb +++ b/spec/knapsack_pro/runners/rspec_runner_spec.rb @@ -34,6 +34,8 @@ let(:task) { double } before do + expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:verify_bind_method_called) + expect(Rake::Task).to receive(:[]).with('knapsack_pro:rspec_run').at_least(1).and_return(task) t = double From ee690ec4d4e3e3b668bcb549906c333f5d4a0e7e Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Sun, 3 Jan 2021 00:09:19 +0100 Subject: [PATCH 03/24] verify bind method called for queue mode in RSpec --- lib/knapsack_pro/runners/queue/rspec_runner.rb | 2 ++ spec/knapsack_pro/runners/queue/rspec_runner_spec.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/knapsack_pro/runners/queue/rspec_runner.rb b/lib/knapsack_pro/runners/queue/rspec_runner.rb index 53d8b527..c3e8b999 100644 --- a/lib/knapsack_pro/runners/queue/rspec_runner.rb +++ b/lib/knapsack_pro/runners/queue/rspec_runner.rb @@ -53,6 +53,8 @@ def self.run_tests(accumulator) if test_file_paths.empty? unless all_test_file_paths.empty? + KnapsackPro::Adapters::RSpecAdapter.verify_bind_method_called + KnapsackPro::Formatters::RSpecQueueSummaryFormatter.print_summary KnapsackPro::Formatters::RSpecQueueProfileFormatterExtension.print_summary diff --git a/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb b/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb index f6be1413..944fd52c 100644 --- a/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +++ b/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb @@ -249,6 +249,8 @@ let(:all_test_file_paths) { ['a_spec.rb'] } it do + expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:verify_bind_method_called) + expect(KnapsackPro::Formatters::RSpecQueueSummaryFormatter).to receive(:print_summary) expect(KnapsackPro::Formatters::RSpecQueueProfileFormatterExtension).to receive(:print_summary) From 90351bfc19d2970aa103b0e5138d4969d20731c3 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 14:35:13 +0100 Subject: [PATCH 04/24] Show 2 reasons why tests could not be recorded properly --- lib/knapsack_pro/adapters/base_adapter.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/knapsack_pro/adapters/base_adapter.rb b/lib/knapsack_pro/adapters/base_adapter.rb index 26c093bd..0e67bc03 100644 --- a/lib/knapsack_pro/adapters/base_adapter.rb +++ b/lib/knapsack_pro/adapters/base_adapter.rb @@ -34,7 +34,9 @@ def self.verify_bind_method_called File.delete(ADAPTER_BIND_METHOD_CALLED_FILE) else KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50) - raise "You forgot to call #{self}.bind method for your test runner to record test files time execution. Please follow installation guide to configure your project properly https://docs.knapsackpro.com/knapsack_pro-ruby/guide/" + KnapsackPro.logger.error("You forgot to call #{self}.bind method for your test runner to record test files time execution. Please follow the installation guide to configure your project properly https://docs.knapsackpro.com/knapsack_pro-ruby/guide/") + KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must have to delete tmp/knapsack_pro directory from the disk accidentally. Please ensure you do not remove tmp/knapsack_pro directory: https://knapsackpro.com/faq/question/why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard") + raise "There is an error in your project configuration. Please read above error message." end end end From f9d0d93b6c8b4f3abaa4be9010cccda07b563771 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 14:41:38 +0100 Subject: [PATCH 05/24] fix typo --- lib/knapsack_pro/adapters/base_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/knapsack_pro/adapters/base_adapter.rb b/lib/knapsack_pro/adapters/base_adapter.rb index 0e67bc03..d81b2366 100644 --- a/lib/knapsack_pro/adapters/base_adapter.rb +++ b/lib/knapsack_pro/adapters/base_adapter.rb @@ -35,7 +35,7 @@ def self.verify_bind_method_called else KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50) KnapsackPro.logger.error("You forgot to call #{self}.bind method for your test runner to record test files time execution. Please follow the installation guide to configure your project properly https://docs.knapsackpro.com/knapsack_pro-ruby/guide/") - KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must have to delete tmp/knapsack_pro directory from the disk accidentally. Please ensure you do not remove tmp/knapsack_pro directory: https://knapsackpro.com/faq/question/why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard") + KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must had to delete tmp/knapsack_pro directory from the disk accidentally. Please ensure you do not remove tmp/knapsack_pro directory: https://knapsackpro.com/faq/question/why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard") raise "There is an error in your project configuration. Please read above error message." end end From a2300799ef52487a3f4e9cf9f9c08c822f44ca57 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 14:52:30 +0100 Subject: [PATCH 06/24] Extract TMP_DIR --- lib/knapsack_pro/adapters/base_adapter.rb | 5 ++--- lib/knapsack_pro/config/env.rb | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/knapsack_pro/adapters/base_adapter.rb b/lib/knapsack_pro/adapters/base_adapter.rb index d81b2366..d91d3525 100644 --- a/lib/knapsack_pro/adapters/base_adapter.rb +++ b/lib/knapsack_pro/adapters/base_adapter.rb @@ -3,8 +3,7 @@ module Adapters class BaseAdapter # Just example, please overwrite constant in subclass TEST_DIR_PATTERN = 'test/**{,/*/**}/*_test.rb' - TMP_KNAPSACK_PRO_DIR = 'tmp/knapsack_pro' - ADAPTER_BIND_METHOD_CALLED_FILE = "#{TMP_KNAPSACK_PRO_DIR}/adapter_bind_method_called.txt" + ADAPTER_BIND_METHOD_CALLED_FILE = "#{KnapsackPro::Config::Env::TMP_DIR}/adapter_bind_method_called.txt" def self.slow_test_file?(adapter_class, test_file_path) @slow_test_file_paths ||= @@ -42,7 +41,7 @@ def self.verify_bind_method_called end def bind - FileUtils.mkdir_p(TMP_KNAPSACK_PRO_DIR) + FileUtils.mkdir_p(KnapsackPro::Config::Env::TMP_DIR) File.write(ADAPTER_BIND_METHOD_CALLED_FILE, nil) if KnapsackPro::Config::Env.recording_enabled? diff --git a/lib/knapsack_pro/config/env.rb b/lib/knapsack_pro/config/env.rb index 38f16dbd..d7c80d85 100644 --- a/lib/knapsack_pro/config/env.rb +++ b/lib/knapsack_pro/config/env.rb @@ -8,6 +8,7 @@ class Env 'info' => ::Logger::INFO, 'debug' => ::Logger::DEBUG, } + TMP_DIR = 'tmp/knapsack_pro' class << self def ci_node_total From 3a8213459af824f4a03310f4293b9987074d2306 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 14:58:05 +0100 Subject: [PATCH 07/24] Use TMP_DIR in other code places --- lib/knapsack_pro/report.rb | 2 +- lib/knapsack_pro/slow_test_file_determiner.rb | 2 +- .../test_case_detectors/rspec_test_example_detector.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/knapsack_pro/report.rb b/lib/knapsack_pro/report.rb index f018fb4d..fcba0418 100644 --- a/lib/knapsack_pro/report.rb +++ b/lib/knapsack_pro/report.rb @@ -80,7 +80,7 @@ def self.create_build_subset(test_files) def self.queue_path queue_id = KnapsackPro::Config::Env.queue_id - "tmp/knapsack_pro/queue/#{queue_id}" + "#{KnapsackPro::Config::Env::TMP_DIR}/queue/#{queue_id}" end end end diff --git a/lib/knapsack_pro/slow_test_file_determiner.rb b/lib/knapsack_pro/slow_test_file_determiner.rb index 59779ec1..bbc532fb 100644 --- a/lib/knapsack_pro/slow_test_file_determiner.rb +++ b/lib/knapsack_pro/slow_test_file_determiner.rb @@ -1,7 +1,7 @@ module KnapsackPro class SlowTestFileDeterminer TIME_THRESHOLD_PER_CI_NODE = 0.7 # 70% - REPORT_DIR = 'tmp/knapsack_pro/slow_test_file_determiner' + REPORT_DIR = "#{KnapsackPro::Config::Env::TMP_DIR}/slow_test_file_determiner" # test_files: { 'path' => 'a_spec.rb', 'time_execution' => 0.0 } # time_execution: of build distribution (total time of CI build run) diff --git a/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb b/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb index 98d3af9f..45c74672 100644 --- a/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +++ b/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb @@ -1,7 +1,7 @@ module KnapsackPro module TestCaseDetectors class RSpecTestExampleDetector - REPORT_DIR = 'tmp/knapsack_pro/test_case_detectors/rspec' + REPORT_DIR = "#{KnapsackPro::Config::Env::TMP_DIR}/test_case_detectors/rspec" def generate_json_report require 'rspec/core' From 9838fa69a2cd44ddddb1b468b3203702c2eac045 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 15:02:27 +0100 Subject: [PATCH 08/24] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87724997..fa3e21eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +### 2.11.0 + +* Verify test runner adapter bind method is called to track test files time execution and ensure tmp/knapsack_pro directory is not removed accidentally + + https://github.com/KnapsackPro/knapsack_pro-ruby/pull/137 + +https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.10.1...v2.11.0 + ### 2.10.1 * Fix RSpec split by test examples feature broken by lazy generating of JSON report with test example ids From ed28c7ed5295ebe171084b7ba8d8707f55e81820 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 15:34:51 +0100 Subject: [PATCH 09/24] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa3e21eb..14f9d6cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### 2.11.0 -* Verify test runner adapter bind method is called to track test files time execution and ensure tmp/knapsack_pro directory is not removed accidentally +* Verify test runner adapter bind method is called to track test files time execution and ensure `tmp/knapsack_pro` directory is not removed accidentally https://github.com/KnapsackPro/knapsack_pro-ruby/pull/137 From c63dc92321106725f6fe24434b204ce796b588c1 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 15:55:41 +0100 Subject: [PATCH 10/24] Update base_adapter.rb --- lib/knapsack_pro/adapters/base_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/knapsack_pro/adapters/base_adapter.rb b/lib/knapsack_pro/adapters/base_adapter.rb index d91d3525..20ad1edf 100644 --- a/lib/knapsack_pro/adapters/base_adapter.rb +++ b/lib/knapsack_pro/adapters/base_adapter.rb @@ -35,7 +35,7 @@ def self.verify_bind_method_called KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50) KnapsackPro.logger.error("You forgot to call #{self}.bind method for your test runner to record test files time execution. Please follow the installation guide to configure your project properly https://docs.knapsackpro.com/knapsack_pro-ruby/guide/") KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must had to delete tmp/knapsack_pro directory from the disk accidentally. Please ensure you do not remove tmp/knapsack_pro directory: https://knapsackpro.com/faq/question/why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard") - raise "There is an error in your project configuration. Please read above error message." + raise "There is an error in your project configuration. Please read the above error message." end end end From d7bbfe92a64ca2427a542045631638f8f9208feb Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 15:57:03 +0100 Subject: [PATCH 11/24] verify_bind_method_called for regular mode in cucumber --- lib/knapsack_pro/runners/cucumber_runner.rb | 5 ++++- spec/knapsack_pro/runners/cucumber_runner_spec.rb | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/knapsack_pro/runners/cucumber_runner.rb b/lib/knapsack_pro/runners/cucumber_runner.rb index 798ce4f8..e8ebdda4 100644 --- a/lib/knapsack_pro/runners/cucumber_runner.rb +++ b/lib/knapsack_pro/runners/cucumber_runner.rb @@ -5,9 +5,12 @@ def self.run(args) ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_cucumber ENV['KNAPSACK_PRO_RECORDING_ENABLED'] = 'true' - runner = new(KnapsackPro::Adapters::CucumberAdapter) + adapter_class = KnapsackPro::Adapters::CucumberAdapter + runner = new(adapter_class) if runner.test_files_to_execute_exist? + adapter_class.verify_bind_method_called + require 'cucumber/rake/task' task_name = 'knapsack_pro:cucumber_run' diff --git a/spec/knapsack_pro/runners/cucumber_runner_spec.rb b/spec/knapsack_pro/runners/cucumber_runner_spec.rb index da6411e2..97a30e64 100644 --- a/spec/knapsack_pro/runners/cucumber_runner_spec.rb +++ b/spec/knapsack_pro/runners/cucumber_runner_spec.rb @@ -34,6 +34,8 @@ let(:task) { double } before do + expect(KnapsackPro::Adapters::CucumberAdapter).to receive(:verify_bind_method_called) + expect(Rake::Task).to receive(:[]).with('knapsack_pro:cucumber_run').at_least(1).and_return(task) t = double From 432c7a03fe03e782bc2a73bd484465e030046896 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 17:06:43 +0100 Subject: [PATCH 12/24] Add spec to ensure KnapsackPro::Adapters::CucumberAdapter.verify_bind_method_called was called --- .../runners/queue/cucumber_runner.rb | 4 +++ .../runners/queue/cucumber_runner_spec.rb | 34 +++++++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/lib/knapsack_pro/runners/queue/cucumber_runner.rb b/lib/knapsack_pro/runners/queue/cucumber_runner.rb index 31d27400..f067d92a 100644 --- a/lib/knapsack_pro/runners/queue/cucumber_runner.rb +++ b/lib/knapsack_pro/runners/queue/cucumber_runner.rb @@ -39,6 +39,10 @@ def self.run_tests(accumulator) ) if test_file_paths.empty? + unless all_test_file_paths.empty? + KnapsackPro::Adapters::CucumberAdapter.verify_bind_method_called + end + KnapsackPro::Hooks::Queue.call_after_queue KnapsackPro::Report.save_node_queue_to_api diff --git a/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb b/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb index 9f5d17fa..8842aba8 100644 --- a/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +++ b/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb @@ -167,14 +167,34 @@ context "when test files don't exist" do let(:test_file_paths) { [] } - it 'returns exit code 0' do - expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue) - expect(KnapsackPro::Report).to receive(:save_node_queue_to_api) + context 'when all_test_file_paths exist' do + let(:all_test_file_paths) { ['a_spec.rb'] } - expect(subject).to eq({ - status: :completed, - exitstatus: exitstatus, - }) + it 'returns exit code 0' do + expect(KnapsackPro::Adapters::CucumberAdapter).to receive(:verify_bind_method_called) + + expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue) + expect(KnapsackPro::Report).to receive(:save_node_queue_to_api) + + expect(subject).to eq({ + status: :completed, + exitstatus: exitstatus, + }) + end + end + + context "when all_test_file_paths don't exist" do + let(:all_test_file_paths) { [] } + + it 'returns exit code 0' do + expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue) + expect(KnapsackPro::Report).to receive(:save_node_queue_to_api) + + expect(subject).to eq({ + status: :completed, + exitstatus: exitstatus, + }) + end end end end From 6be6381f8ed4678f59a483043385c8cd26aca323 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 17:09:33 +0100 Subject: [PATCH 13/24] Update base_adapter_spec.rb --- spec/knapsack_pro/adapters/base_adapter_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/knapsack_pro/adapters/base_adapter_spec.rb b/spec/knapsack_pro/adapters/base_adapter_spec.rb index a555dbae..d4490bff 100644 --- a/spec/knapsack_pro/adapters/base_adapter_spec.rb +++ b/spec/knapsack_pro/adapters/base_adapter_spec.rb @@ -76,6 +76,9 @@ let(:queue_recording_enabled?) { false } before do + expect(FileUtils).to receive(:mkdir_p).with('tmp/knapsack_pro') + expect(File).to receive(:write).with('tmp/knapsack_pro/adapter_bind_method_called.txt', nil) + expect(KnapsackPro::Config::Env).to receive(:recording_enabled?).and_return(recording_enabled?) expect(KnapsackPro::Config::Env).to receive(:queue_recording_enabled?).and_return(queue_recording_enabled?) end From 1507859eb116d4d668cb26998f372b831e3250ee Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 17:28:05 +0100 Subject: [PATCH 14/24] Add spec for verify_bind_method_called --- lib/knapsack_pro/adapters/base_adapter.rb | 2 +- .../adapters/base_adapter_spec.rb | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/knapsack_pro/adapters/base_adapter.rb b/lib/knapsack_pro/adapters/base_adapter.rb index 20ad1edf..675f866f 100644 --- a/lib/knapsack_pro/adapters/base_adapter.rb +++ b/lib/knapsack_pro/adapters/base_adapter.rb @@ -35,7 +35,7 @@ def self.verify_bind_method_called KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50) KnapsackPro.logger.error("You forgot to call #{self}.bind method for your test runner to record test files time execution. Please follow the installation guide to configure your project properly https://docs.knapsackpro.com/knapsack_pro-ruby/guide/") KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must had to delete tmp/knapsack_pro directory from the disk accidentally. Please ensure you do not remove tmp/knapsack_pro directory: https://knapsackpro.com/faq/question/why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard") - raise "There is an error in your project configuration. Please read the above error message." + raise 'There is an error in your project configuration. Please read the above error message.' end end end diff --git a/spec/knapsack_pro/adapters/base_adapter_spec.rb b/spec/knapsack_pro/adapters/base_adapter_spec.rb index d4490bff..c02cb8a3 100644 --- a/spec/knapsack_pro/adapters/base_adapter_spec.rb +++ b/spec/knapsack_pro/adapters/base_adapter_spec.rb @@ -71,6 +71,32 @@ it { should eql adapter } end + describe '.verify_bind_method_called' do + subject { described_class.verify_bind_method_called } + + before do + expect(::Kernel).to receive(:at_exit).and_yield + expect(File).to receive(:exists?).with('tmp/knapsack_pro/adapter_bind_method_called.txt').and_return(adapter_bind_method_called_file_exists) + end + + context 'when adapter bind method called' do + let(:adapter_bind_method_called_file_exists) { true } + + it do + expect(File).to receive(:delete).with('tmp/knapsack_pro/adapter_bind_method_called.txt') + subject + end + end + + context 'when adapter bind method was not call' do + let(:adapter_bind_method_called_file_exists) { false } + + it do + expect { subject }.to raise_error('There is an error in your project configuration. Please read the above error message.') + end + end + end + describe '#bind' do let(:recording_enabled?) { false } let(:queue_recording_enabled?) { false } From 7e231ce00b578f5b7f7ab90dd376ef8f1362baed Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 18:06:35 +0100 Subject: [PATCH 15/24] Explicitly exit process with 1 exit code when bind method not verified. Thanks to that when bind method not called in Queue Mode for Cucumber then exit code will be 1. If we would raise exception than this wouldn't change exit code in case of Cucumber (this was bug) --- lib/knapsack_pro/adapters/base_adapter.rb | 2 +- spec/knapsack_pro/adapters/base_adapter_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/knapsack_pro/adapters/base_adapter.rb b/lib/knapsack_pro/adapters/base_adapter.rb index 675f866f..e10809d2 100644 --- a/lib/knapsack_pro/adapters/base_adapter.rb +++ b/lib/knapsack_pro/adapters/base_adapter.rb @@ -35,7 +35,7 @@ def self.verify_bind_method_called KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50) KnapsackPro.logger.error("You forgot to call #{self}.bind method for your test runner to record test files time execution. Please follow the installation guide to configure your project properly https://docs.knapsackpro.com/knapsack_pro-ruby/guide/") KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must had to delete tmp/knapsack_pro directory from the disk accidentally. Please ensure you do not remove tmp/knapsack_pro directory: https://knapsackpro.com/faq/question/why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard") - raise 'There is an error in your project configuration. Please read the above error message.' + Kernel.exit(1) end end end diff --git a/spec/knapsack_pro/adapters/base_adapter_spec.rb b/spec/knapsack_pro/adapters/base_adapter_spec.rb index c02cb8a3..df98a8af 100644 --- a/spec/knapsack_pro/adapters/base_adapter_spec.rb +++ b/spec/knapsack_pro/adapters/base_adapter_spec.rb @@ -92,7 +92,8 @@ let(:adapter_bind_method_called_file_exists) { false } it do - expect { subject }.to raise_error('There is an error in your project configuration. Please read the above error message.') + expect(Kernel).to receive(:exit).with(1) + subject end end end From 9ed8e16140af2be642652d9629c565e479d21f9e Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 18:13:52 +0100 Subject: [PATCH 16/24] Print new lines to separate error from other messages --- lib/knapsack_pro/adapters/base_adapter.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/knapsack_pro/adapters/base_adapter.rb b/lib/knapsack_pro/adapters/base_adapter.rb index e10809d2..b453563b 100644 --- a/lib/knapsack_pro/adapters/base_adapter.rb +++ b/lib/knapsack_pro/adapters/base_adapter.rb @@ -32,6 +32,7 @@ def self.verify_bind_method_called if File.exists?(ADAPTER_BIND_METHOD_CALLED_FILE) File.delete(ADAPTER_BIND_METHOD_CALLED_FILE) else + puts "\n\n" KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50) KnapsackPro.logger.error("You forgot to call #{self}.bind method for your test runner to record test files time execution. Please follow the installation guide to configure your project properly https://docs.knapsackpro.com/knapsack_pro-ruby/guide/") KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must had to delete tmp/knapsack_pro directory from the disk accidentally. Please ensure you do not remove tmp/knapsack_pro directory: https://knapsackpro.com/faq/question/why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard") From 65a2f4acd9002facc23502c852ffe47869c17841 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 18:22:12 +0100 Subject: [PATCH 17/24] verify bind method called in regular mode for Minitest --- lib/knapsack_pro/runners/minitest_runner.rb | 5 ++++- spec/knapsack_pro/runners/minitest_runner_spec.rb | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/knapsack_pro/runners/minitest_runner.rb b/lib/knapsack_pro/runners/minitest_runner.rb index 4af5be0b..4fdca5ef 100644 --- a/lib/knapsack_pro/runners/minitest_runner.rb +++ b/lib/knapsack_pro/runners/minitest_runner.rb @@ -5,9 +5,12 @@ def self.run(args) ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_minitest ENV['KNAPSACK_PRO_RECORDING_ENABLED'] = 'true' - runner = new(KnapsackPro::Adapters::MinitestAdapter) + adapter_class = KnapsackPro::Adapters::MinitestAdapter + runner = new(adapter_class) if runner.test_files_to_execute_exist? + adapter_class.verify_bind_method_called + task_name = 'knapsack_pro:minitest_run' if Rake::Task.task_defined?(task_name) diff --git a/spec/knapsack_pro/runners/minitest_runner_spec.rb b/spec/knapsack_pro/runners/minitest_runner_spec.rb index 79b0bb99..71402f9c 100644 --- a/spec/knapsack_pro/runners/minitest_runner_spec.rb +++ b/spec/knapsack_pro/runners/minitest_runner_spec.rb @@ -14,6 +14,10 @@ end context 'when test files were returned by Knapsack Pro API' do + before do + expect(KnapsackPro::Adapters::MinitestAdapter).to receive(:verify_bind_method_called) + end + it 'runs tests' do test_file_paths = ['test_fake/a_test.rb', 'test_fake/b_test.rb'] runner = instance_double(described_class, From 532be3d0d69010ec42d665832fc7fa8dfe829677 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 18:26:09 +0100 Subject: [PATCH 18/24] Update cucumber_runner_spec.rb --- spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb b/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb index 8842aba8..352789a7 100644 --- a/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +++ b/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb @@ -168,7 +168,7 @@ let(:test_file_paths) { [] } context 'when all_test_file_paths exist' do - let(:all_test_file_paths) { ['a_spec.rb'] } + let(:all_test_file_paths) { ['features/a.feature'] } it 'returns exit code 0' do expect(KnapsackPro::Adapters::CucumberAdapter).to receive(:verify_bind_method_called) From 500f60c521af8e6dbe18bb87e0fee1d6bce20bd8 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 18:29:07 +0100 Subject: [PATCH 19/24] verify bind method called for minitest in queue mode --- .../runners/queue/minitest_runner.rb | 4 +++ .../runners/queue/minitest_runner_spec.rb | 34 +++++++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/lib/knapsack_pro/runners/queue/minitest_runner.rb b/lib/knapsack_pro/runners/queue/minitest_runner.rb index 71fa6c46..26ffef8f 100644 --- a/lib/knapsack_pro/runners/queue/minitest_runner.rb +++ b/lib/knapsack_pro/runners/queue/minitest_runner.rb @@ -46,6 +46,10 @@ def self.run_tests(accumulator) ) if test_file_paths.empty? + unless all_test_file_paths.empty? + KnapsackPro::Adapters::MinitestAdapter.verify_bind_method_called + end + KnapsackPro::Hooks::Queue.call_after_queue KnapsackPro::Report.save_node_queue_to_api diff --git a/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb b/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb index 43c8e888..da1d093e 100644 --- a/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +++ b/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb @@ -159,14 +159,34 @@ context "when test files don't exist" do let(:test_file_paths) { [] } - it 'returns exit code 0' do - expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue) - expect(KnapsackPro::Report).to receive(:save_node_queue_to_api) + context 'when all_test_file_paths exist' do + let(:all_test_file_paths) { ['a_test.rb'] } - expect(subject).to eq({ - status: :completed, - exitstatus: exitstatus, - }) + it 'returns exit code 0' do + expect(KnapsackPro::Adapters::MinitestAdapter).to receive(:verify_bind_method_called) + + expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue) + expect(KnapsackPro::Report).to receive(:save_node_queue_to_api) + + expect(subject).to eq({ + status: :completed, + exitstatus: exitstatus, + }) + end + end + + context "when all_test_file_paths don't exist" do + let(:all_test_file_paths) { [] } + + it 'returns exit code 0' do + expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue) + expect(KnapsackPro::Report).to receive(:save_node_queue_to_api) + + expect(subject).to eq({ + status: :completed, + exitstatus: exitstatus, + }) + end end end end From d3be7020e4425ee46c88f1dd4a627d6c58cfdf25 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 18:40:38 +0100 Subject: [PATCH 20/24] verify bind method called for Test::Unit in regular mode --- lib/knapsack_pro/runners/test_unit_runner.rb | 5 ++++- spec/knapsack_pro/runners/test_unit_runner_spec.rb | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/knapsack_pro/runners/test_unit_runner.rb b/lib/knapsack_pro/runners/test_unit_runner.rb index 8155eed8..fd36bba7 100644 --- a/lib/knapsack_pro/runners/test_unit_runner.rb +++ b/lib/knapsack_pro/runners/test_unit_runner.rb @@ -5,9 +5,12 @@ def self.run(args) ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_test_unit ENV['KNAPSACK_PRO_RECORDING_ENABLED'] = 'true' - runner = new(KnapsackPro::Adapters::TestUnitAdapter) + adapter_class = KnapsackPro::Adapters::TestUnitAdapter + runner = new(adapter_class) if runner.test_files_to_execute_exist? + adapter_class.verify_bind_method_called + require 'test/unit' cli_args = diff --git a/spec/knapsack_pro/runners/test_unit_runner_spec.rb b/spec/knapsack_pro/runners/test_unit_runner_spec.rb index 653b3a25..95f8271d 100644 --- a/spec/knapsack_pro/runners/test_unit_runner_spec.rb +++ b/spec/knapsack_pro/runners/test_unit_runner_spec.rb @@ -16,6 +16,8 @@ context 'when test files were returned by Knapsack Pro API' do it 'runs tests' do + expect(KnapsackPro::Adapters::TestUnitAdapter).to receive(:verify_bind_method_called) + test_file_paths = ['test-unit_fake/a_test.rb', 'test-unit_fake/b_test.rb'] runner = instance_double(described_class, test_dir: 'test-unit_fake', From 065d87f982abf4e959115a779639744aee3de5e9 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 18:46:51 +0100 Subject: [PATCH 21/24] verify bind method called for spinach in regular mode --- lib/knapsack_pro/runners/spinach_runner.rb | 5 ++++- spec/knapsack_pro/runners/spinach_runner_spec.rb | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/knapsack_pro/runners/spinach_runner.rb b/lib/knapsack_pro/runners/spinach_runner.rb index c1cc8f32..426a2bc4 100644 --- a/lib/knapsack_pro/runners/spinach_runner.rb +++ b/lib/knapsack_pro/runners/spinach_runner.rb @@ -4,9 +4,12 @@ class SpinachRunner < BaseRunner def self.run(args) ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_spinach - runner = new(KnapsackPro::Adapters::SpinachAdapter) + adapter_class = KnapsackPro::Adapters::SpinachAdapter + runner = new(adapter_class) if runner.test_files_to_execute_exist? + adapter_class.verify_bind_method_called + cmd = %Q[KNAPSACK_PRO_RECORDING_ENABLED=true KNAPSACK_PRO_TEST_SUITE_TOKEN=#{ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN']} bundle exec spinach #{args} --features_path #{runner.test_dir} -- #{runner.stringify_test_file_paths}] Kernel.system(cmd) diff --git a/spec/knapsack_pro/runners/spinach_runner_spec.rb b/spec/knapsack_pro/runners/spinach_runner_spec.rb index 62a31fd4..c1588fc2 100644 --- a/spec/knapsack_pro/runners/spinach_runner_spec.rb +++ b/spec/knapsack_pro/runners/spinach_runner_spec.rb @@ -26,6 +26,8 @@ end before do + expect(KnapsackPro::Adapters::SpinachAdapter).to receive(:verify_bind_method_called) + expect(Kernel).to receive(:system).with('KNAPSACK_PRO_RECORDING_ENABLED=true KNAPSACK_PRO_TEST_SUITE_TOKEN=spinach-token bundle exec spinach --custom-arg --features_path fake-test-dir -- features/a.feature features/b.feature') end From f9623d0e69b465a168d7fdc7fadcee9e61adf3bf Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 18:51:12 +0100 Subject: [PATCH 22/24] Update base_adapter.rb --- lib/knapsack_pro/adapters/base_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/knapsack_pro/adapters/base_adapter.rb b/lib/knapsack_pro/adapters/base_adapter.rb index b453563b..f844a738 100644 --- a/lib/knapsack_pro/adapters/base_adapter.rb +++ b/lib/knapsack_pro/adapters/base_adapter.rb @@ -34,7 +34,7 @@ def self.verify_bind_method_called else puts "\n\n" KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50) - KnapsackPro.logger.error("You forgot to call #{self}.bind method for your test runner to record test files time execution. Please follow the installation guide to configure your project properly https://docs.knapsackpro.com/knapsack_pro-ruby/guide/") + 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/") KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must had to delete tmp/knapsack_pro directory from the disk accidentally. Please ensure you do not remove tmp/knapsack_pro directory: https://knapsackpro.com/faq/question/why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard") Kernel.exit(1) end From f956fe929eeff5a78e895f94c7ce05ad50f79eff Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 20:15:09 +0100 Subject: [PATCH 23/24] add node index to adapter bind method called file to allow running tests in parallel on single machine with the same disk (i.e. when using parallel_tests gem) --- lib/knapsack_pro/adapters/base_adapter.rb | 11 +++++--- .../adapters/base_adapter_spec.rb | 27 ++++++++++++++++--- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/lib/knapsack_pro/adapters/base_adapter.rb b/lib/knapsack_pro/adapters/base_adapter.rb index f844a738..8cab8487 100644 --- a/lib/knapsack_pro/adapters/base_adapter.rb +++ b/lib/knapsack_pro/adapters/base_adapter.rb @@ -3,7 +3,10 @@ module Adapters class BaseAdapter # Just example, please overwrite constant in subclass TEST_DIR_PATTERN = 'test/**{,/*/**}/*_test.rb' - ADAPTER_BIND_METHOD_CALLED_FILE = "#{KnapsackPro::Config::Env::TMP_DIR}/adapter_bind_method_called.txt" + + def self.adapter_bind_method_called_file + "#{KnapsackPro::Config::Env::TMP_DIR}/adapter_bind_method_called_node_#{KnapsackPro::Config::Env.ci_node_index}.txt" + end def self.slow_test_file?(adapter_class, test_file_path) @slow_test_file_paths ||= @@ -29,8 +32,8 @@ def self.bind def self.verify_bind_method_called ::Kernel.at_exit do - if File.exists?(ADAPTER_BIND_METHOD_CALLED_FILE) - File.delete(ADAPTER_BIND_METHOD_CALLED_FILE) + if File.exists?(adapter_bind_method_called_file) + File.delete(adapter_bind_method_called_file) else puts "\n\n" KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50) @@ -43,7 +46,7 @@ def self.verify_bind_method_called def bind FileUtils.mkdir_p(KnapsackPro::Config::Env::TMP_DIR) - File.write(ADAPTER_BIND_METHOD_CALLED_FILE, nil) + File.write(self.class.adapter_bind_method_called_file, nil) if KnapsackPro::Config::Env.recording_enabled? KnapsackPro.logger.debug('Test suite time execution recording enabled.') diff --git a/spec/knapsack_pro/adapters/base_adapter_spec.rb b/spec/knapsack_pro/adapters/base_adapter_spec.rb index df98a8af..da6f5bd6 100644 --- a/spec/knapsack_pro/adapters/base_adapter_spec.rb +++ b/spec/knapsack_pro/adapters/base_adapter_spec.rb @@ -22,6 +22,27 @@ end end + describe '.adapter_bind_method_called_file' do + subject { described_class.adapter_bind_method_called_file } + + before do + expect(KnapsackPro::Config::Env).to receive(:ci_node_index).and_return(ci_node_index) + end + + context 'when CI node index 0' do + let(:ci_node_index) { 0 } + + it { expect(subject).to eq 'tmp/knapsack_pro/adapter_bind_method_called_node_0.txt' } + + end + + context 'when CI node index 1' do + let(:ci_node_index) { 1 } + + it { expect(subject).to eq 'tmp/knapsack_pro/adapter_bind_method_called_node_1.txt' } + end + end + describe '.slow_test_file?' do let(:adapter_class) { double } let(:slow_test_files) do @@ -76,14 +97,14 @@ before do expect(::Kernel).to receive(:at_exit).and_yield - expect(File).to receive(:exists?).with('tmp/knapsack_pro/adapter_bind_method_called.txt').and_return(adapter_bind_method_called_file_exists) + expect(File).to receive(:exists?).with('tmp/knapsack_pro/adapter_bind_method_called_node_0.txt').and_return(adapter_bind_method_called_file_exists) end context 'when adapter bind method called' do let(:adapter_bind_method_called_file_exists) { true } it do - expect(File).to receive(:delete).with('tmp/knapsack_pro/adapter_bind_method_called.txt') + expect(File).to receive(:delete).with('tmp/knapsack_pro/adapter_bind_method_called_node_0.txt') subject end end @@ -104,7 +125,7 @@ before do expect(FileUtils).to receive(:mkdir_p).with('tmp/knapsack_pro') - expect(File).to receive(:write).with('tmp/knapsack_pro/adapter_bind_method_called.txt', nil) + expect(File).to receive(:write).with('tmp/knapsack_pro/adapter_bind_method_called_node_0.txt', nil) expect(KnapsackPro::Config::Env).to receive(:recording_enabled?).and_return(recording_enabled?) expect(KnapsackPro::Config::Env).to receive(:queue_recording_enabled?).and_return(queue_recording_enabled?) From 7b0481064ccdb0019050757dd7f3a4fd1ca945df Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 4 Jan 2021 20:50:08 +0100 Subject: [PATCH 24/24] Use adapter class name in file to allow running different test runners at the same time on the common disk space --- lib/knapsack_pro/adapters/base_adapter.rb | 3 ++- spec/knapsack_pro/adapters/base_adapter_spec.rb | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/knapsack_pro/adapters/base_adapter.rb b/lib/knapsack_pro/adapters/base_adapter.rb index 8cab8487..2c202797 100644 --- a/lib/knapsack_pro/adapters/base_adapter.rb +++ b/lib/knapsack_pro/adapters/base_adapter.rb @@ -5,7 +5,8 @@ class BaseAdapter TEST_DIR_PATTERN = 'test/**{,/*/**}/*_test.rb' def self.adapter_bind_method_called_file - "#{KnapsackPro::Config::Env::TMP_DIR}/adapter_bind_method_called_node_#{KnapsackPro::Config::Env.ci_node_index}.txt" + adapter_name = self.to_s.gsub('::', '-') + "#{KnapsackPro::Config::Env::TMP_DIR}/#{adapter_name}-bind_method_called_for_node_#{KnapsackPro::Config::Env.ci_node_index}.txt" end def self.slow_test_file?(adapter_class, test_file_path) diff --git a/spec/knapsack_pro/adapters/base_adapter_spec.rb b/spec/knapsack_pro/adapters/base_adapter_spec.rb index da6f5bd6..d7d21e2b 100644 --- a/spec/knapsack_pro/adapters/base_adapter_spec.rb +++ b/spec/knapsack_pro/adapters/base_adapter_spec.rb @@ -32,14 +32,14 @@ context 'when CI node index 0' do let(:ci_node_index) { 0 } - it { expect(subject).to eq 'tmp/knapsack_pro/adapter_bind_method_called_node_0.txt' } + it { expect(subject).to eq 'tmp/knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt' } end context 'when CI node index 1' do let(:ci_node_index) { 1 } - it { expect(subject).to eq 'tmp/knapsack_pro/adapter_bind_method_called_node_1.txt' } + it { expect(subject).to eq 'tmp/knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_1.txt' } end end @@ -97,14 +97,14 @@ before do expect(::Kernel).to receive(:at_exit).and_yield - expect(File).to receive(:exists?).with('tmp/knapsack_pro/adapter_bind_method_called_node_0.txt').and_return(adapter_bind_method_called_file_exists) + expect(File).to receive(:exists?).with('tmp/knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt').and_return(adapter_bind_method_called_file_exists) end context 'when adapter bind method called' do let(:adapter_bind_method_called_file_exists) { true } it do - expect(File).to receive(:delete).with('tmp/knapsack_pro/adapter_bind_method_called_node_0.txt') + expect(File).to receive(:delete).with('tmp/knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt') subject end end @@ -125,7 +125,7 @@ before do expect(FileUtils).to receive(:mkdir_p).with('tmp/knapsack_pro') - expect(File).to receive(:write).with('tmp/knapsack_pro/adapter_bind_method_called_node_0.txt', nil) + expect(File).to receive(:write).with('tmp/knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt', nil) expect(KnapsackPro::Config::Env).to receive(:recording_enabled?).and_return(recording_enabled?) expect(KnapsackPro::Config::Env).to receive(:queue_recording_enabled?).and_return(queue_recording_enabled?)