Class: TestRunner::Cli::Command
- Inherits:
-
OsCtl::Lib::Cli::Command
- Object
- OsCtl::Lib::Cli::Command
- TestRunner::Cli::Command
- Defined in:
- lib/test-runner/cli/command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #debug ⇒ Object
- #list ⇒ Object
- #select_test_scripts(pattern) ⇒ Array<TestScript> protected
- #state_dir ⇒ Object protected
- #test ⇒ Object
Class Method Details
.run(method) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/test-runner/cli/command.rb', line 5 def self.run(method) proc do |global_opts, opts, args| cmd = new(global_opts, opts, args) cmd.method(method).call end end |
Instance Method Details
#debug ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/test-runner/cli/command.rb', line 42 def debug require_args!('test') tsl = TestRunner::TestScriptList.new test_script = tsl.by_path(args[0]) ev = TestRunner::TestEvaluator.new( test_script.test, [test_script], state_dir: File.join(state_dir, "os-test-#{test_script.test.name}"), sock_dir: File.join(state_dir, 'socks'), default_timeout: opts['timeout'], destructive: false ) ev.interactive end |
#list ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/test-runner/cli/command.rb', line 12 def list test_scripts = select_test_scripts(args[0]) test_scripts.each do |ts| puts ts.path end end |
#select_test_scripts(pattern) ⇒ Array<TestScript> (protected)
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/test-runner/cli/command.rb', line 62 def select_test_scripts(pattern) tsl = TestRunner::TestScriptList.new attr_filters = Cli::LabelFilters.new(opts['label']) tag_filters = Cli::TagFilters.new(opts['tag']) tsl.filter do |ts| (pattern.nil? || ts.path_matches?(pattern)) \ && attr_filters.pass?(ts) \ && tag_filters.pass?(ts) end end |
#state_dir ⇒ Object (protected)
75 76 77 |
# File 'lib/test-runner/cli/command.rb', line 75 def state_dir File.join(opts['state-dir'] || File.join(ENV['TMPDIR'] || '/tmp', 'os-test-runner')) end |
#test ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/test-runner/cli/command.rb', line 20 def test test_scripts = select_test_scripts(args[0]) puts 'The following test scripts will be run:' test_scripts.each { |t| puts " #{t.path}" } puts exec = TestRunner::Executor.new( test_scripts, state_dir:, jobs: opts['jobs'], default_timeout: opts['timeout'], stop_on_failure: opts['stop-on-failure'], destructive: opts['destructive'] ) results = exec.run return unless results.detect(&:unexpected_result?) raise 'one or more tests did not have expected results' end |