@VisibleForTesting static boolean isTestRunRequiredForTest( TestRule test, BuildEngine cachingBuildEngine, ExecutionContext executionContext, TestRuleKeyFileHelper testRuleKeyFileHelper, boolean isResultsCacheEnabled, boolean isRunningWithTestSelectors) throws IOException, ExecutionException, InterruptedException { boolean isTestRunRequired; BuildResult result; if (executionContext.isDebugEnabled()) { // If debug is enabled, then we should always run the tests as the user is expecting to // hook up a debugger. isTestRunRequired = true; } else if (isRunningWithTestSelectors) { // As a feature to aid developers, we'll assume that when we are using test selectors, // we should always run each test (and never look at the cache.) // TODO(user) When #3090004 and #3436849 are closed we can respect the cache again. isTestRunRequired = true; } else if (((result = cachingBuildEngine.getBuildRuleResult(test.getBuildTarget())) != null) && result.getSuccess() == BuildRuleSuccessType.MATCHING_RULE_KEY && isResultsCacheEnabled && test.hasTestResultFiles(executionContext) && testRuleKeyFileHelper.isRuleKeyInDir(test)) { // If this build rule's artifacts (which includes the rule's output and its test result // files) are up to date, then no commands are necessary to run the tests. The test result // files will be read from the XML files in interpretTestResults(). isTestRunRequired = false; } else { isTestRunRequired = true; } return isTestRunRequired; }