Class: TestRunner::TestConfig
- Inherits:
-
Object
- Object
- TestRunner::TestConfig
- Defined in:
- lib/test-runner/test_config.rb
Instance Attribute Summary collapse
- #test ⇒ Test readonly
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.
- #nix_quote_attr(s) ⇒ Object protected
- #nix_system ⇒ Object protected
Constructor Details
#initialize(test) ⇒ TestConfig
Returns a new instance of TestConfig.
18 19 20 21 |
# File 'lib/test-runner/test_config.rb', line 18 def initialize(test) @test = test @config = {} end |
Instance Attribute Details
#test ⇒ Test (readonly)
15 16 17 |
# File 'lib/test-runner/test_config.rb', line 15 def test @test end |
Class Method Details
.build(test) ⇒ Object
8 9 10 11 12 |
# File 'lib/test-runner/test_config.rb', line 8 def self.build(test) tc = new(test) tc.build tc end |
Instance Method Details
#[](key) ⇒ Object
41 42 43 |
# File 'lib/test-runner/test_config.rb', line 41 def [](key) @config[key] end |
#build ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/test-runner/test_config.rb', line 23 def build FileUtils.mkdir_p('result/tests') ref = ".#tests.#{nix_system}.\"#{nix_quote_attr(test.path)}\"" cmd = [ 'nix', 'build', '--impure', '--out-link', config_path, ref ] pid = spawn(*cmd) Process.wait(pid) raise 'nix build failed' if $?.exitstatus != 0 @config = JSON.parse(File.read(config_path)) end |
#config_path ⇒ Object (protected)
67 68 69 |
# File 'lib/test-runner/test_config.rb', line 67 def config_path "result/tests/#{test.name}-config.json" end |
#nix_quote_attr(s) ⇒ Object (protected)
63 64 65 |
# File 'lib/test-runner/test_config.rb', line 63 def nix_quote_attr(s) s.to_s.gsub('\\', '\\\\').gsub('"', '\\"') end |
#nix_system ⇒ Object (protected)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/test-runner/test_config.rb', line 47 def nix_system @nix_system ||= begin out, status = Open3.capture2( 'nix', 'eval', '--raw', '--impure', '--expr', 'builtins.currentSystem' ) raise "nix eval builtins.currentSystem failed (#{status.exitstatus})" unless status.success? out.strip end end |