-
Notifications
You must be signed in to change notification settings - Fork 21.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
[ONNX] Diagnostic option 'warnings_as_errors' #105886
Changes from all commits
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 |
---|---|---|
|
@@ -319,6 +319,30 @@ def test_diagnostic_context_raises_if_diagnostic_is_error(self): | |
) | ||
) | ||
|
||
def test_diagnostic_context_raises_original_exception_from_diagnostic_created_from_it( | ||
self, | ||
): | ||
with self.assertRaises(ValueError): | ||
try: | ||
raise ValueError("original exception") | ||
except ValueError as e: | ||
diagnostic = infra.Diagnostic( | ||
self.rules.rule_without_message_args, infra.Level.ERROR | ||
) | ||
diagnostic = diagnostic.with_source_exception(e) | ||
self.context.log_and_raise_if_error(diagnostic) | ||
|
||
def test_diagnostic_context_raises_if_diagnostic_is_warning_and_warnings_as_errors_is_true( | ||
self, | ||
): | ||
with self.assertRaises(infra.RuntimeErrorWithDiagnostic): | ||
self.context.options.warnings_as_errors = True | ||
self.context.log_and_raise_if_error( | ||
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. Do we need to include this part to enable it? How do we use 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.
For regular diagnostics, one always need to log them into
|
||
infra.Diagnostic( | ||
self.rules.rule_without_message_args, infra.Level.WARNING | ||
) | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
common_utils.run_tests() |
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 clear test naming 🎉