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

[icon4pygen]: Print error message when codegen fails in tests #411

Merged
merged 5 commits into from
May 15, 2024

Conversation

tehrengruber
Copy link
Contributor

When code generation fails we previously just printed the processes exit code in the tests. This PR forwards the exception for easier debugging.

Copy link
Contributor

@egparedes egparedes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question and a minor issue.

@@ -136,7 +137,10 @@ def test_codegen(cli, stencil_module, stencil_name, flags) -> None:
with cli.isolated_filesystem():
cli_args = [module_path, BLOCK_SIZE, LEVELS_PER_THREAD, OUTPATH, *flags]
result = cli.invoke(main, cli_args)
assert result.exit_code == 0
if not result.exit_code == 0:
traceback.format_exception(*result.exc_info)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
traceback.format_exception(*result.exc_info)

Comment on lines 140 to 143
if not result.exit_code == 0:
traceback.format_exception(*result.exc_info)
msg = "".join(traceback.format_exception(*result.exc_info))
pytest.fail("Codegen failed with error:\n" + msg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like more to keep the assert statement because it's way simpler to read. What about using an assert with a custom message:

Suggested change
if not result.exit_code == 0:
traceback.format_exception(*result.exc_info)
msg = "".join(traceback.format_exception(*result.exc_info))
pytest.fail("Codegen failed with error:\n" + msg)
assert result.exit_code == 0, f"Codegen failed with error:\n{''.join(traceback.format_exception(*result.exc_info))}"

Copy link

Mandatory Tests

Please make sure you run these tests via comment before you merge!

  • cscs-ci run default
  • launch jenkins spack

Optional Tests

To run benchmarks you can use:

  • cscs-ci run benchmark

To run tests and benchmarks with the DaCe backend you can use:

  • cscs-ci run dace

In case your change might affect downstream icon-exclaim, please consider running

  • launch jenkins icon

For more detailed information please look at CI in the EXCLAIM universe.

Copy link
Contributor

@egparedes egparedes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ILGTM.

@tehrengruber
Copy link
Contributor Author

cscs-ci run default

@tehrengruber
Copy link
Contributor Author

launch jenkins spack

@tehrengruber tehrengruber merged commit 2d8abc3 into main May 15, 2024
5 checks passed
iomaganaris referenced this pull request in iomaganaris/icon4py Jun 18, 2024
When code generation fails we previously just printed the processes exit code in the tests. This PR forwards the exception for easier debugging.
@samkellerhals samkellerhals deleted the improve_icon4pygen_error branch December 20, 2024 08:36
OngChia pushed a commit that referenced this pull request Jan 14, 2025
When code generation fails we previously just printed the processes exit code in the tests. This PR forwards the exception for easier debugging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants