From e46af314d3c0339f013b3145aede856584247470 Mon Sep 17 00:00:00 2001 From: Alexander Jeurissen Date: Sun, 21 Mar 2021 21:55:38 +0100 Subject: [PATCH] Fix bug where empty node_tests executes complete test_suite --- lib/knapsack/runners/cucumber_runner.rb | 4 ++++ lib/knapsack/runners/minitest_runner.rb | 4 ++++ lib/knapsack/runners/rspec_runner.rb | 4 ++++ lib/knapsack/runners/spinach_runner.rb | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/lib/knapsack/runners/cucumber_runner.rb b/lib/knapsack/runners/cucumber_runner.rb index 4b87b59..3fc06e1 100644 --- a/lib/knapsack/runners/cucumber_runner.rb +++ b/lib/knapsack/runners/cucumber_runner.rb @@ -12,6 +12,10 @@ def self.run(args) Knapsack.logger.info allocator.leftover_node_tests Knapsack.logger.info + # NOTE: return if there are no specs to execute for this node. + # This can occurr if test_file_list_source_file is used with less then CI_NODES specs + return Knapsack.logger.warn('No specs to execute') if allocator.stringify_node_tests.empty? + cmd = %Q[bundle exec cucumber #{args} --require #{allocator.test_dir} -- #{allocator.stringify_node_tests}] system(cmd) diff --git a/lib/knapsack/runners/minitest_runner.rb b/lib/knapsack/runners/minitest_runner.rb index bc30654..b614099 100644 --- a/lib/knapsack/runners/minitest_runner.rb +++ b/lib/knapsack/runners/minitest_runner.rb @@ -12,6 +12,10 @@ def self.run(args) Knapsack.logger.info allocator.leftover_node_tests Knapsack.logger.info + # NOTE: return if there are no specs to execute for this node. + # This can occurr if test_file_list_source_file is used with less then CI_NODES specs + return Knapsack.logger.warn('No specs to execute') if allocator.stringify_node_tests.empty? + task_name = 'knapsack:minitest_run' if Rake::Task.task_defined?(task_name) diff --git a/lib/knapsack/runners/rspec_runner.rb b/lib/knapsack/runners/rspec_runner.rb index 19f6fb6..bff1635 100644 --- a/lib/knapsack/runners/rspec_runner.rb +++ b/lib/knapsack/runners/rspec_runner.rb @@ -12,6 +12,10 @@ def self.run(args) Knapsack.logger.info allocator.leftover_node_tests Knapsack.logger.info + # NOTE: return if there are no specs to execute for this node. + # This can occurr if test_file_list_source_file is used with less then CI_NODES specs + return Knapsack.logger.warn('No specs to execute') if allocator.stringify_node_tests.empty? + cmd = %Q[bundle exec rspec #{args} --default-path #{allocator.test_dir} -- #{allocator.stringify_node_tests}] exec(cmd) diff --git a/lib/knapsack/runners/spinach_runner.rb b/lib/knapsack/runners/spinach_runner.rb index ceed286..bb66218 100644 --- a/lib/knapsack/runners/spinach_runner.rb +++ b/lib/knapsack/runners/spinach_runner.rb @@ -12,6 +12,10 @@ def self.run(args) Knapsack.logger.info allocator.leftover_node_tests Knapsack.logger.info + # NOTE: return if there are no specs to execute for this node. + # This can occurr if test_file_list_source_file is used with less then CI_NODES specs + return Knapsack.logger.warn('No specs to execute') if allocator.stringify_node_tests.empty? + cmd = %Q[bundle exec spinach #{args} --features_path #{allocator.test_dir} -- #{allocator.stringify_node_tests}] system(cmd)