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

adding better error reporting for bin tests #1578

Conversation

cdleu430
Copy link
Contributor

Adding the stdout or stderr to the AssertionErrors in our tests.

I imagine there are a couple of ways to accomplish this. This seemed like the least intrusive, but it still is a large amount of lines changed, oh well. Happy to take a different approach if others think it would look better, this is my first PR here

Issue:
#1558

Testing:
If you want to test this out yourself it's a bit tricky because you need the tests to fail (which I obviously don't want to do in my commit).
I found changing something like latlong_image value in test_exrenvmap.py was enough to get the test to fail and see what the output looks like.
You can run a single test like:
make test ARGS="-R 'exrenvmap' --output-on-failure"
you need to be in your _build dir to run that

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 13, 2023

CLA Not Signed

forgot a few things

Signed-off-by: cdleu430 <cleu@ilm.com>
@cdleu430 cdleu430 force-pushed the feature/better-error-reporting-bin-tests branch from fbfd13d to eeb5c7e Compare October 13, 2023 20:01
Comment on lines +19 to +20
assert(result.returncode != 0), "\n"+result.stderr
assert(result.stderr.startswith ("Usage: ")), "\n"+result.stderr
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a very fluent Python speaker. What does this mean

assert(condition), string

?? Does the string print if the assertion fails? What about if the assertion succeeds? Is this an idiomatic usage that Python experts would use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah basically it's just passing that string to the Exception. Same as if you did
Exception("This is my error message")
https://docs.python.org/3.9/reference/simple_stmts.html#the-assert-statement
I'm using "the extended form" here

So the string only prints if the assertion fails.

I think an alternative would be

try:
    assert(result.returncode != 0)
except AssertionError:
    print(result.stderr)
    raise

But that just felt like it took up too many lines for what it did.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, it's fine, it just wasn't a convention I was familiar with

Copy link
Member

@cary-ilm cary-ilm left a comment

Choose a reason for hiding this comment

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

Nice, succinct solution, thanks!

@cary-ilm cary-ilm merged commit de791a5 into AcademySoftwareFoundation:main Oct 14, 2023
29 checks passed
annguyen-ilm pushed a commit to annguyen-ilm/openexr that referenced this pull request Oct 24, 2023
…n#1578)

forgot a few things

Signed-off-by: cdleu430 <cleu@ilm.com>
Signed-off-by: An Nguyen <annguyen@ilm.com>
cary-ilm pushed a commit to cary-ilm/openexr that referenced this pull request Feb 13, 2024
…n#1578)

forgot a few things

Signed-off-by: cdleu430 <cleu@ilm.com>
cary-ilm pushed a commit that referenced this pull request Feb 16, 2024
forgot a few things

Signed-off-by: cdleu430 <cleu@ilm.com>
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.

3 participants