[GRADLE-2915] Standalone test report fails if no data Created: 04/Oct/13  Updated: 07/Nov/13  Resolved: 16/Oct/13

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 1.9-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Fixed Votes: 0


 Description   

We are having an aggregated test report task specified along this lines:

task aggregatedTestReport(type: TestReport) {
testResultDirs = subprojects*.tasks*.withType(Test).flatten().binResultsDir
destinationDir = file("$buildDir/reports/tests")
allprojects.tasks*.withType(Test).flatten()*.finalizedBy it
}

Typically it works fine, except one very specific case:
1. gradle clean
2. gradle aggregatedTestReport // passes
3. gradle aggregatedTestReport // fails!

What happens is that the first time the binary test results is empty and the constructor in TestOutputStore.Reader#Reader() creates an empty 'output.bin' file. The second time arround, it sees that the outputs file exists and takes a different branch, throwing exception because the index file is missing.

If we snip the irrelevant code, it looks like this:

public Reader() {
File indexFile = getIndexFile();
File outputsFile = getOutputsFile();

if (outputsFile.exists()) {
if (!indexFile.exists()) {
throw new IllegalStateException(String.format("Test outputs data file '{}' exists but the index file '{}' does not", outputsFile, indexFile));
}
// snipped
} else { // no outputs file
if (indexFile.exists()) {
throw new IllegalStateException(String.format("Test outputs data file '{}' does not exist but the index file '{}' does", outputsFile, indexFile));
}

GFileUtils.touch(getOutputsFile());
index = new Index();
}

// snipped
}

The root cause is that we are running the report without having run the tests, but that seems to be intentionally supported behavior, so I would deem this as a bug.



 Comments   
Comment by Gradle Forums [ 04/Oct/13 ]

Which Gradle version are you using? I think this may have been fixed already.

Comment by Gradle Forums [ 04/Oct/13 ]

This is with 1.8 - haven't tested with others

Comment by Pablo Munoz [ 25/Oct/13 ]

TestReport will fail on incremental builds (2nd time) if there are disabled (with onlyIf) test task(s).
Will the fix address this use case?

Generated at Wed Jun 30 12:34:53 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.