Skip to content

Commit

Permalink
Catch Ruby error while TestUp runs the unit tests and dump it to a lo…
Browse files Browse the repository at this point in the history
…g file.
  • Loading branch information
thomthom committed Sep 3, 2024
1 parent 662f7a9 commit 13e0969
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ Output: C:\Users\Thomas\SourceTree\TestUp2\tests\results.json
# Overriding where the .log files from a test run will be saved.
LogPath: C:\Users\Thomas\SourceTree\TestUp2\logs

# Optional:
# Path to a .log file that will be used if TestUp itself runs into any errors
# while running the tests.
ErrorLogPath: C:\Users\Thomas\SourceTree\TestUp2\testup_errors.log

# Optional:
# Overriding where the .run files from a test run will be saved.
SavedRunsPath: C:\Users\Thomas\SourceTree\TestUp2\logs
Expand Down
12 changes: 11 additions & 1 deletion src/testup/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ def self.process_arguments
# @param [Hash] config
def self.ci_run(test_suite, config = {})
Execution.delay(1.0) do
API.run_suite_without_gui(test_suite, config)
begin
API.run_suite_without_gui(test_suite, config)
rescue Exception => error
# Ensure we log the error to a file so the CI system can log it.
if config['ErrorLogPath']
File.open(config['ErrorLogPath'], 'w') { |file|
file.puts(error.inspect)
file.puts(error.backtrace.join("\n"))
}
end
end
self.quit unless config['KeepOpen']
end
end
Expand Down

0 comments on commit 13e0969

Please sign in to comment.