Class: TestRunner::Test

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ Test

Returns a new instance of Test.

Parameters:

  • opts (Hash)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/test-runner/test.rb', line 43

def initialize(**opts)
  @path = opts[:path]
  @type = opts[:type]
  @template = opts[:template]
  @template_args = opts[:template_args]
  @test_args = opts[:test_args]
  @name = opts[:name]
  @description = opts[:description]
  @attempts = opts[:attempts]
  @expect_failure = opts[:expect_failure]
  @test_script_jobs = opts[:test_script_jobs] || 1
  @tags = opts[:tags]
  @labels = opts[:labels]
  @test_scripts = opts[:test_scripts].to_h do |ts_name, ts_opts|
    [
      ts_name,
      TestScript.new(
        self,
        ts_name,
        description: ts_opts['description'],
        expect_failure: ts_opts['expectFailure'],
        attempts: ts_opts['attempts'],
        tags: ts_opts.fetch('tags', []),
        labels: ts_opts.fetch('labels', {})
      )
    ]
  end

  return if @test_scripts.length != 1 || !@test_scripts.has_key?('default')

  @test_scripts['default'].set_singleton
end

Instance Attribute Details

#attemptsInteger (readonly)

Returns:

  • (Integer)


25
26
27
# File 'lib/test-runner/test.rb', line 25

def attempts
  @attempts
end

#descriptionString (readonly)

Returns:

  • (String)


22
23
24
# File 'lib/test-runner/test.rb', line 22

def description
  @description
end

#expect_failureBoolean (readonly)

Returns:

  • (Boolean)


28
29
30
# File 'lib/test-runner/test.rb', line 28

def expect_failure
  @expect_failure
end

#labelsHash<String, String> (readonly)

Returns:

  • (Hash<String, String>)


37
38
39
# File 'lib/test-runner/test.rb', line 37

def labels
  @labels
end

#nameString (readonly)

Returns:

  • (String)


19
20
21
# File 'lib/test-runner/test.rb', line 19

def name
  @name
end

#pathString (readonly)

Returns:

  • (String)


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

def path
  @path
end

#tagsArray<String> (readonly)

Returns:

  • (Array<String>)


34
35
36
# File 'lib/test-runner/test.rb', line 34

def tags
  @tags
end

#templateString (readonly)

Returns:

  • (String)


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

def template
  @template
end

#template_argsHash (readonly)

Returns:

  • (Hash)


13
14
15
# File 'lib/test-runner/test.rb', line 13

def template_args
  @template_args
end

#test_argsHash (readonly)

Returns:

  • (Hash)


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

def test_args
  @test_args
end

#test_script_jobsInteger (readonly)

Returns:

  • (Integer)


31
32
33
# File 'lib/test-runner/test.rb', line 31

def test_script_jobs
  @test_script_jobs
end

#test_scriptsHash<String, TestScript> (readonly)

Returns:



40
41
42
# File 'lib/test-runner/test.rb', line 40

def test_scripts
  @test_scripts
end

#typeString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/test-runner/test.rb', line 7

def type
  @type
end

Instance Method Details

#file_pathObject



80
81
82
83
84
85
86
# File 'lib/test-runner/test.rb', line 80

def file_path
  if template?
    "#{template}.nix"
  else
    "#{path}.nix"
  end
end

#template?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/test-runner/test.rb', line 76

def template?
  type == 'template'
end