-
Notifications
You must be signed in to change notification settings - Fork 27
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
Cleaner failure reports #62
base: main
Are you sure you want to change the base?
Changes from all commits
8a3a8f3
60c9059
519c6fb
70c07dd
6229f99
5bda7e5
0366a7d
0d0aff5
5f0efc7
1d28c5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
from functools import reduce | ||
from operator import ior | ||
from pathlib import Path | ||
from typing import Iterable, Optional, List, Type | ||
from typing import Iterable, Optional, List, Type, Any | ||
|
||
import test_framework | ||
import test_framework.basic | ||
|
@@ -23,6 +23,16 @@ | |
from test_framework.tacky.suite import Optimizations | ||
|
||
|
||
class MyTextTestResult(unittest.TextTestResult): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works fine! Now the only thing left is naming, I guess. This is a very lazy name... Should we stick to it? An alternative could be |
||
def addFailure(self, test: Any, err: Any) -> None: | ||
super(MyTextTestResult, self).addFailure(test, (err[0], err[1], None)) | ||
|
||
def getDescription(self, test: unittest.TestCase) -> str: | ||
return test.shortDescription() or super(MyTextTestResult, self).getDescription( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to fall back on the description instead of putting "MISSING" :) |
||
test | ||
) | ||
|
||
|
||
def get_optimization_flags( | ||
latest_chapter: int, | ||
optimization_opt: Optional[test_framework.tacky.suite.Optimizations], | ||
|
@@ -518,7 +528,11 @@ def main() -> int: | |
unittest.installHandler() | ||
|
||
# run it | ||
runner = unittest.TextTestRunner(verbosity=args.verbose, failfast=args.failfast) | ||
runner = unittest.TextTestRunner( | ||
verbosity=args.verbose, | ||
failfast=args.failfast, | ||
resultclass=MyTextTestResult, | ||
) | ||
result = runner.run(test_suite) | ||
if result.wasSuccessful(): | ||
return 0 | ||
|
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.
Not sure if that's really necessary, but instead of adding the
source_file
three times I decided to create this closure :)