-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Regression tests: display stdout/stderr even if there was an exception before the report could be created. #38008
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
5ce0d7a
to
8d11352
Compare
before the report could be created.
8d11352
to
a8ce766
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving to not be blocking but please check out my suggestion, it could provide a more explicit error handling which would be simpler to debug.
And please bump the package version and add a changelog entry 🙏
exit_code, stdout, stderr = await get_exec_result(container) | ||
|
||
with open(path_to_report, "r") as fp: | ||
regression_test_report = fp.read() | ||
try: | ||
await container.file(path_to_report).export(path_to_report) | ||
with open(path_to_report, "r") as fp: | ||
regression_test_report = fp.read() | ||
except Exception as exc: | ||
main_logger.exception(f"Could not export or read report due to exception. traceback={traceback.format_exc()}", exc_info=exc) | ||
regression_test_report = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just summarizing my understanding of the flow.
get_exec_result
actually executes the command in the container- If there's an
ExecError
during the execution of this command we get stdout and stderr from the exception object - If an
ExecError
was thrown (and handled) executingcontainer.file()
will likely fail as we're trying to get a file that does not exist.
Instead of excepting a broad exception I'd be in favor of being more specific:
if "report.html" not in await container.directory(f"{regression_tests_artifacts_dir}/session_{self.run_id}").entries():
main_logger.exception("The report file was not generated, an unhandled error likely happened during regression test execution, please check the step stderr and stdout for more details")
else:
await container.file(path_to_report).export(path_to_report)
with open(path_to_report, "r") as fp:
regression_test_report = fp.read()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the suggestion, updated.
Currently if there's an exception running regression tests before the report is written, we get a generic exception that the report couldn't be exported from the container because it does not exist.
However, this causes us to not be able to see the stderr/stdout.
This code change makes a small modification so to handle the exception exporting the report so we can still see the stderr/stdout of the container.