Allow suppression of AssertionError in TransformerAndroidTestRunner.

PiperOrigin-RevId: 440952335
This commit is contained in:
samrobinson 2022-04-11 19:41:16 +01:00 committed by Ian Baker
parent 7b78548e25
commit e4d7e5e7f5

View File

@ -94,8 +94,8 @@ public class TransformerAndroidTestRunner {
} }
/** /**
* Sets whether the runner should suppress any {@link Exception} that occurs as a result of * Sets whether to suppress failures that occurs as a result of post-transformation analysis,
* post-transformation analysis, such as SSIM calculation. * such as SSIM calculation.
* *
* <p>Regardless of this value, analysis exceptions are attached to the analysis file. * <p>Regardless of this value, analysis exceptions are attached to the analysis file.
* *
@ -294,13 +294,17 @@ public class TransformerAndroidTestRunner {
// calculation, so it should be thrown, rather than processed as part of the // calculation, so it should be thrown, rather than processed as part of the
// TransformationTestResult. // TransformationTestResult.
throw interruptedException; throw interruptedException;
} catch (Exception analysisException) { } catch (Throwable analysisFailure) {
// Catch all (checked and unchecked) exceptions throw by the SsimHelper and process them as // Catch all (checked and unchecked) failures throw by the SsimHelper and process them as
// part of the TransformationTestResult. // part of the TransformationTestResult.
Exception analysisException =
analysisFailure instanceof Exception
? (Exception) analysisFailure
: new IllegalStateException(analysisFailure);
resultBuilder.setAnalysisException(analysisException); resultBuilder.setAnalysisException(analysisException);
Log.e(TAG_PREFIX + testId, "SSIM calculation failed.", analysisException); Log.e(TAG_PREFIX + testId, "SSIM calculation failed.", analysisException);
} }
return resultBuilder.build(); return resultBuilder.build();
} }
} }