Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openc3-cosmos-script-runner-api/spec/models/script_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def setup_process_suite_mocks(language:, stdout_content: '{"suite":"data"}', std
allow(process_double).to receive(:environment).and_return(process_env)
allow(process_double).to receive(:io).and_return(io_double)
allow(process_double).to receive(:start)
allow(process_double).to receive(:wait)
allow(process_double).to receive(:poll_for_exit).with(10)
allow(process_double).to receive(:exit_code).and_return(exit_code)

allow(ChildProcess).to receive(:build).and_return(process_double)
Expand Down
13 changes: 10 additions & 3 deletions openc3/lib/openc3/utilities/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,23 @@ def self.process_suite(name, contents, new_process: true, username: nil, scope:)
process.io.stdout = stdout
process.io.stderr = stderr
process.start
process.wait
begin
process.poll_for_exit(10) # wait for max 10s
rescue ChildProcess::TimeoutError
process.stop
stderr_results = "Suite analysis timed out - possible infinite loop in script\n"
success = false
end
stdout.rewind
stdout_results = stdout.read
stdout.close
stdout.unlink
stderr.rewind
stderr_results = stderr.read
stderr_results ||= ""
stderr_results += stderr.read
stderr.close
stderr.unlink
success = process.exit_code == 0
success = process.exit_code == 0 if success
else
require temp.path
stdout_results = OpenC3::SuiteRunner.build_suites.as_json().to_json(allow_nan: true)
Expand Down
Loading