-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from KnapsackPro/queue-mode-minitest
Add Queue Mode for Minitest
- Loading branch information
Showing
11 changed files
with
332 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
module KnapsackPro | ||
module Runners | ||
module Queue | ||
class MinitestRunner < BaseRunner | ||
def self.run(args) | ||
require 'minitest' | ||
|
||
ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_minitest | ||
ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] = 'true' | ||
ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id | ||
|
||
runner = new(KnapsackPro::Adapters::MinitestAdapter) | ||
|
||
# Add test_dir to load path to make work: | ||
# require 'test_helper' | ||
# in test files. | ||
$LOAD_PATH.unshift(runner.test_dir) | ||
|
||
cli_args = (args || '').split | ||
run_tests(runner, true, cli_args, 0, []) | ||
end | ||
|
||
def self.run_tests(runner, can_initialize_queue, args, exitstatus, all_test_file_paths) | ||
test_file_paths = runner.test_file_paths( | ||
can_initialize_queue: can_initialize_queue, | ||
executed_test_files: all_test_file_paths | ||
) | ||
|
||
if test_file_paths.empty? | ||
KnapsackPro::Hooks::Queue.call_after_queue | ||
|
||
KnapsackPro::Report.save_node_queue_to_api | ||
exit(exitstatus) | ||
else | ||
subset_queue_id = KnapsackPro::Config::EnvGenerator.set_subset_queue_id | ||
ENV['KNAPSACK_PRO_SUBSET_QUEUE_ID'] = subset_queue_id | ||
|
||
KnapsackPro.tracker.reset! | ||
|
||
all_test_file_paths += test_file_paths | ||
|
||
result = minitest_run(runner, test_file_paths, args) | ||
exitstatus = 1 unless result | ||
|
||
KnapsackPro::Hooks::Queue.call_after_subset_queue | ||
|
||
KnapsackPro::Report.save_subset_queue_to_file | ||
|
||
run_tests(runner, false, args, exitstatus, all_test_file_paths) | ||
end | ||
end | ||
|
||
private | ||
|
||
def self.minitest_run(runner, test_file_paths, args) | ||
test_file_paths.each do |test_file_path| | ||
require "./#{test_file_path}" | ||
end | ||
|
||
# duplicate args because Minitest modifies args | ||
result = Minitest.run(args.dup) | ||
|
||
Minitest::Runnable.reset | ||
|
||
result | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'knapsack_pro' | ||
|
||
namespace :knapsack_pro do | ||
namespace :queue do | ||
task :minitest, [:minitest_args] do |_, args| | ||
KnapsackPro::Runners::Queue::MinitestRunner.run(args[:minitest_args]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.