Class: KnapsackPro::Runners::Queue::RSpecRunner
- Inherits:
-
BaseRunner
- Object
- BaseRunner
- KnapsackPro::Runners::Queue::RSpecRunner
show all
- Defined in:
- lib/knapsack_pro/runners/queue/rspec_runner.rb
Class Method Summary
collapse
Methods inherited from BaseRunner
#initialize, #test_dir, #test_file_paths
Class Method Details
.log_rspec_command(cli_args, test_file_paths, type) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/knapsack_pro/runners/queue/rspec_runner.rb', line 58
def self.log_rspec_command(cli_args, test_file_paths, type)
case type
when :subset_queue
KnapsackPro.logger.info("To retry in development the subset of tests fetched from API queue please run below command on your machine. If you use --order random then remember to add proper --seed 123 that you will find at the end of rspec command.")
when :end_of_queue
KnapsackPro.logger.info("To retry in development the tests for this CI node please run below command on your machine. It will run all tests in a single run. If you need to reproduce a particular subset of tests fetched from API queue then above after each request to Knapsack Pro API you will find example rspec command.")
end
stringify_cli_args = cli_args.join(' ')
stringify_cli_args.slice!("--format #{KnapsackPro::Formatters::RSpecQueueSummaryFormatter}")
KnapsackPro.logger.info(
"bundle exec rspec #{stringify_cli_args} " +
KnapsackPro::TestFilePresenter.stringify_paths(test_file_paths)
)
end
|
.run(args) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/knapsack_pro/runners/queue/rspec_runner.rb', line 5
def self.run(args)
require 'rspec/core'
require_relative '../../formatters/rspec_queue_summary_formatter'
ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_rspec
ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] = 'true'
ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id
runner = new(KnapsackPro::Adapters::RSpecAdapter)
cli_args = (args || '').split
cli_args += ['--format', 'progress'] unless cli_args.include?('--format')
cli_args += [
'--format', KnapsackPro::Formatters::RSpecQueueSummaryFormatter.to_s,
'--default-path', runner.test_dir,
]
run_tests(runner, true, cli_args, 0, [])
end
|
.run_tests(runner, can_initialize_queue, args, exitstatus, all_test_file_paths) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/knapsack_pro/runners/queue/rspec_runner.rb', line 26
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)
if test_file_paths.empty?
unless all_test_file_paths.empty?
KnapsackPro::Formatters::RSpecQueueSummaryFormatter.print_summary
log_rspec_command(args, all_test_file_paths, :end_of_queue)
end
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
all_test_file_paths += test_file_paths
cli_args = args + test_file_paths
log_rspec_command(args, test_file_paths, :subset_queue)
options = RSpec::Core::ConfigurationOptions.new(cli_args)
exit_code = RSpec::Core::Runner.new(options).run($stderr, $stdout)
exitstatus = exit_code if exit_code != 0
RSpec.world.example_groups.clear
run_tests(runner, false, args, exitstatus, all_test_file_paths)
end
end
|