Class: SnapCI::ParallelTests::CLI
- Inherits:
-
Object
- Object
- SnapCI::ParallelTests::CLI
- Defined in:
- lib/snap_ci/parallel_tests/cli.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
-
#test_opts ⇒ Object
readonly
Returns the value of attribute test_opts.
Instance Method Summary collapse
-
#initialize(runner, argv) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(runner, argv) ⇒ CLI
Returns a new instance of CLI.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/snap_ci/parallel_tests/cli.rb', line 8 def initialize(runner, argv) @runner = runner @argv = argv.dup @test_opts = nil if split_index = @argv.index('--') @test_opts = @argv.drop(split_index + 1).join(' ') @argv = @argv.take(split_index) end end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
6 7 8 |
# File 'lib/snap_ci/parallel_tests/cli.rb', line 6 def argv @argv end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
6 7 8 |
# File 'lib/snap_ci/parallel_tests/cli.rb', line 6 def runner @runner end |
#test_opts ⇒ Object (readonly)
Returns the value of attribute test_opts.
6 7 8 |
# File 'lib/snap_ci/parallel_tests/cli.rb', line 6 def test_opts @test_opts end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/snap_ci/parallel_tests/cli.rb', line 20 def run = parse! test_files = find_all_tests([:files_or_dirs], ) if [:trace] $stderr.puts "Found the following #{runner.test_file_name}s" $stderr.puts test_files.collect { |t| " - #{t}" }.join("\n") end report_number_of_tests(test_files, SnapCI::ParallelTests.total_workers) test_files_to_run = SnapCI::ParallelTests.partition( things: test_files, total_workers: SnapCI::ParallelTests.total_workers, current_worker_index: SnapCI::ParallelTests.worker_index, group_by: [:group_by] ) if test_files_to_run.empty? $stderr.puts 'No tests to run' else if [:trace] $stderr.puts "Will run the following #{runner.test_file_name}s and ignore others" $stderr.puts test_files.collect { |t| " - #{t}" }.join("\n") end runner.execute(test_files_to_run, ) end end |