Class: Funicular::Testing::NodeRunner
- Inherits:
-
Object
- Object
- Funicular::Testing::NodeRunner
- Defined in:
- lib/funicular/testing/node_runner.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- RESULT_MARKER =
"__FUNICULAR_TEST_RESULTS_JSON__="- DEFAULT_TEST_GLOB =
"test/funicular/client/**/*_picotest.rb"
Instance Attribute Summary collapse
-
#app_root ⇒ Object
readonly
Returns the value of attribute app_root.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#runtime_dir ⇒ Object
readonly
Returns the value of attribute runtime_dir.
-
#source_dir ⇒ Object
readonly
Returns the value of attribute source_dir.
-
#test_glob ⇒ Object
readonly
Returns the value of attribute test_glob.
-
#timeout_ms ⇒ Object
readonly
Returns the value of attribute timeout_ms.
Instance Method Summary collapse
-
#initialize(app_root: nil, source_dir: nil, test_glob: DEFAULT_TEST_GLOB, runtime_dir: nil, node: nil, timeout_ms: 5000) ⇒ NodeRunner
constructor
A new instance of NodeRunner.
- #run ⇒ Object
Constructor Details
#initialize(app_root: nil, source_dir: nil, test_glob: DEFAULT_TEST_GLOB, runtime_dir: nil, node: nil, timeout_ms: 5000) ⇒ NodeRunner
Returns a new instance of NodeRunner.
70 71 72 73 74 75 76 77 78 |
# File 'lib/funicular/testing/node_runner.rb', line 70 def initialize(app_root: nil, source_dir: nil, test_glob: DEFAULT_TEST_GLOB, runtime_dir: nil, node: nil, timeout_ms: 5000) @app_root = File.(app_root || rails_root || Dir.pwd) @source_dir = File.(source_dir || File.join(@app_root, "app", "funicular")) @test_glob = test_glob @runtime_dir = File.(runtime_dir || default_runtime_dir) @node = node || ENV["NODE"] || "node" @timeout_ms = timeout_ms end |
Instance Attribute Details
#app_root ⇒ Object (readonly)
Returns the value of attribute app_root.
68 69 70 |
# File 'lib/funicular/testing/node_runner.rb', line 68 def app_root @app_root end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
68 69 70 |
# File 'lib/funicular/testing/node_runner.rb', line 68 def node @node end |
#runtime_dir ⇒ Object (readonly)
Returns the value of attribute runtime_dir.
68 69 70 |
# File 'lib/funicular/testing/node_runner.rb', line 68 def runtime_dir @runtime_dir end |
#source_dir ⇒ Object (readonly)
Returns the value of attribute source_dir.
68 69 70 |
# File 'lib/funicular/testing/node_runner.rb', line 68 def source_dir @source_dir end |
#test_glob ⇒ Object (readonly)
Returns the value of attribute test_glob.
68 69 70 |
# File 'lib/funicular/testing/node_runner.rb', line 68 def test_glob @test_glob end |
#timeout_ms ⇒ Object (readonly)
Returns the value of attribute timeout_ms.
68 69 70 |
# File 'lib/funicular/testing/node_runner.rb', line 68 def timeout_ms @timeout_ms end |
Instance Method Details
#run ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/funicular/testing/node_runner.rb', line 80 def run manifest = build_manifest with_manifest_file(manifest) do |path| stdout, stderr, status = Open3.capture3(node, runner_js, path, chdir: app_root) stdout = strip_ansi(stdout) stderr = strip_ansi(stderr) results, stdout = extract_picotest_results(stdout) Result.new(status: status, stdout: stdout, stderr: stderr, picotest_results: results) end end |