Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch Ruby error while TestUp runs the unit tests and dump it to a log file. #242

Merged
merged 1 commit into from
Sep 4, 2024
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
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
Loading