Class: TestRunner::TestConfig
- Inherits:
-
Object
- Object
- TestRunner::TestConfig
- Defined in:
- lib/test-runner/test_config.rb
Instance Attribute Summary collapse
-
#test ⇒ Object
readonly
Returns the value of attribute test.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #build ⇒ Object
- #config_path ⇒ Object protected
-
#initialize(test) ⇒ TestConfig
constructor
A new instance of TestConfig.
Constructor Details
#initialize(test) ⇒ TestConfig
Returns a new instance of TestConfig.
16 17 18 19 |
# File 'lib/test-runner/test_config.rb', line 16 def initialize(test) @test = test @config = {} end |
Instance Attribute Details
#test ⇒ Object (readonly)
Returns the value of attribute test.
13 14 15 |
# File 'lib/test-runner/test_config.rb', line 13 def test @test end |
Class Method Details
.build(test) ⇒ Object
7 8 9 10 11 |
# File 'lib/test-runner/test_config.rb', line 7 def self.build(test) tc = new(test) tc.build tc end |
Instance Method Details
#[](key) ⇒ Object
42 43 44 |
# File 'lib/test-runner/test_config.rb', line 42 def [](key) @config[key] end |
#build ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/test-runner/test_config.rb', line 21 def build cmd = [ 'nix-build', '--attr', 'json', '--out-link', config_path ] if test.template? cmd << '--argstr' << 'templateArgsInJson' << test.args.to_json end cmd << "./tests/suite/#{test.file_path}" FileUtils.mkdir_p('result/tests') pid = spawn(*cmd) Process.wait(pid) raise 'nix-build failed' if $?.exitstatus != 0 @config = JSON.parse(File.read(config_path), symbolize_names: true) end |
#config_path ⇒ Object (protected)
48 49 50 |
# File 'lib/test-runner/test_config.rb', line 48 def config_path "result/tests/#{test.name}-config.json" end |