Class: TestRunner::TestScriptList

Inherits:
Object
  • Object
show all
Defined in:
lib/test-runner/test_script_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(system: NixCli::DEFAULT_SYSTEM, test_config_path: nil) ⇒ TestScriptList

Returns a new instance of TestScriptList.



3
4
5
# File 'lib/test-runner/test_script_list.rb', line 3

def initialize(system: NixCli::DEFAULT_SYSTEM, test_config_path: nil)
  @test_list = TestList.new(system:, test_config_path:)
end

Instance Method Details

#allArray<TestScript>

Return a list of all known test scripts

Returns:



9
10
11
# File 'lib/test-runner/test_script_list.rb', line 9

def all
  expand_scripts(@test_list.all)
end

#by_path(path) ⇒ TestScript

Return one test script specified by path

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/test-runner/test_script_list.rb', line 22

def by_path(path)
  test_path, script_name = path.split('#')

  test = @test_list.by_path(test_path)

  if script_name
    script = test.test_scripts[script_name]
    raise "Test #{test_path} does not have script ##{script_name}" if script.nil?

    script
  elsif test.test_scripts.length == 1
    test.test_scripts.first[1]
  else
    raise "Test #{test_path} has scripts #{test.test_scripts.each_key.map { |v| "##{v}" }.join(', ')}, choose one"
  end
end

#expand_scripts(test_list) ⇒ Object (protected)



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/test-runner/test_script_list.rb', line 41

def expand_scripts(test_list)
  ret = []

  test_list.each do |test|
    test.test_scripts.each_value do |ts|
      ret << ts
    end
  end

  ret
end

#filter {|| ... } ⇒ Array<TestScript>

Filter through all test scripts, return those that the filter matched

Yield Parameters:

Returns:



16
17
18
# File 'lib/test-runner/test_script_list.rb', line 16

def filter(&)
  all.select(&)
end