-
Notifications
You must be signed in to change notification settings - Fork 622
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
adding better error reporting for bin tests #1578
Conversation
|
forgot a few things Signed-off-by: cdleu430 <[email protected]>
fbfd13d
to
eeb5c7e
Compare
assert(result.returncode != 0), "\n"+result.stderr | ||
assert(result.stderr.startswith ("Usage: ")), "\n"+result.stderr |
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'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?
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.
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.
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.
No, it's fine, it just wasn't a convention I was familiar with
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.
Nice, succinct solution, thanks!
…n#1578) forgot a few things Signed-off-by: cdleu430 <[email protected]> Signed-off-by: An Nguyen <[email protected]>
…n#1578) forgot a few things Signed-off-by: cdleu430 <[email protected]>
forgot a few things Signed-off-by: cdleu430 <[email protected]>
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