Fixed
Status Update
Comments
uc...@google.com <uc...@google.com> #2
Thank you for your feedback. Team may reach out for more feedback in reproducing or triaging this issue.
tn...@google.com <tn...@google.com> #3
This is (finally!) fixed for Studio 4.2 by Change-Id: Ia07b4ab4fcc75023841bc9839adfea2d04f757dd. Now, when lint throws an error during analysis, instead of reporting the exception as a pretty printed string into the expected output, it's thrown as a real error such that the test runner can intercept it and handle it properly. There were lint unit tests which wanted to test that we gracefully handle exceptions (e.g. an exception doesn't take down the entire lint run) and for those narrow use cases there's a new DSL method (allowExceptions()) to set the behavior to trap the exceptions as before. Thanks for the report!
Description
I'm adding a new violation to my UastScanner and turns out my quick fix needs to be updated. However, the error thrown when running the Gradle test task was:
timber.lint.WrongTimberUsageDetectorTest > exceptionLoggingUsingExceptionMessage FAILED
org.junit.ComparisonFailure: expected:<[src/foo/Example.java:6: Warning: Explicitly logging exception message is redundant [TimberExceptionLogging]
Timber.d(e.getMessage());
~~~~~~~~~~~~~~~~~~~~~~~~
0] errors, 1 warnings> but was:<[project0: Error: Unexpected failure during lint analysis (this is a bug in lint or one of the libraries it depends on)
AssertionError:Assert.fail(Assert.java:88)←TestLintClient.report(TestLintClient.java:707)←LintDriver$LintClientWrapper.report(LintDriver.kt:1877)←Context.doReport(Context.kt:258)←JavaContext.report(JavaContext.kt:362)←WrongTimberUsageDetector.checkExceptionLogging(WrongTimberUsageDetector.java:545)←WrongTimberUsageDetector.visitMethod(WrongTimberUsageDetector.java:92)←UElementVisitor$DelegatingPsiVisitor.visitMethodCallExpression(UElementVisitor.kt:1027)
You can set environment variable LINT_PRINT_STACKTRACE=true to dump a full stacktrace to stdout. [LintError]
While the stacktrace highlights that the error is thrown at TestLintClient.report(TestLintClient.java:707), the message passed to the AssertionError isn't displayed:
fail("Did not find \"" + oldString + "\" in \"" + locationRange + "\" as suggested in the quickfix for issue " + issue);
I tried running the command again after setting the suggested environment variable using:
export LINT_PRINT_STACKTRACE=true
and:
gw test-command -PLINT_PRINT_STACKTRACE=true
but the output was the same.