Skip to content
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

When subprojects have missing reports, aggregation fails #292

Open
ghost opened this issue Sep 10, 2021 · 2 comments
Open

When subprojects have missing reports, aggregation fails #292

ghost opened this issue Sep 10, 2021 · 2 comments
Milestone

Comments

@ghost
Copy link

ghost commented Sep 10, 2021

Assuming a gradle project where some subprojects

  • have the pitest plugin disable; or
  • have failWhenNoMutations set

We will have some subprojects with to files to aggregate.

When attempting to run pitestReport on such a project then the following error is shown

Execution failed for task ':pitestReportAggregate'.
> A failure occurred while executing info.solidsoft.gradle.pitest.AggregateReportGenerator
   > /... snip .../build/reports/pitest/linecoverage.xml does not exist or is not a file

This is due to the check in ReportAggregator.Builder when a file is added to aggregation it must exist.

Whilst it is fairly easily to "hack" AggregateReportTask to strip out subprojects for which pitest is disabled, the failWhenNoMutations issue is trickier as this needs to be checked at task execution time.

So AggregateReportTask needs to determine whether reports are missing for a particular subproject and whether that should be an error or not.

Proposal

  • remove subprojects for which the pitest task is disabled from aggregation altogether
  • when building the report config, if a pitest task has failWhenNoMutations, allow the files to be missing and do not add them to be report aggregator.
@aSemy
Copy link

aSemy commented Oct 29, 2021

Can the aggregator task can be changed to depend on Pitest tasks, not projects with the Pitest plugin? I think that's what's tripping the agggregation up. I think the Gradle-ey way of doing this would to put the file-gathering work that is currently in PitestAggregatorPlugin in the aggregator task.

The Pitest task can be altered to explicitly output the required files (mutationFiles and lineCoverageFiles), then the aggregator task can depend on the tasks dependsOn(tasks.withType<PitestTask>()) and aggregate the files from the tasks.

I'm not sure that the worker queue is required.

@JoaoCipriano
Copy link

A workaround for this failure is to apply the Pitest plugin and settings only to the subprojects that will be tested. I created an internal method to make it clearer and easier to understand.

This solution worked for me because the method getProjectsWithPitestPlugin() of the class PitestAggregatorPlugin retrieve only the subprojects with the plugin; I believe that must work in almost every case.

The solution:

plugins {
	id 'info.solidsoft.pitest' version '1.9.11' apply false
}

apply plugin: 'info.solidsoft.pitest.aggregator'

subprojects {  
	apply plugin: 'java'    
  
	if (shouldApplyPitestPlugin(project.name)) {  
		apply plugin: 'info.solidsoft.pitest'  
  
		pitest {  
			junit5PluginVersion = '1.0.0' 
			useClasspathFile = true  
  
			outputFormats = [ "XML", "HTML" ]  
			exportLineCoverage = true  
			timestampedReports = false  
		}  
	}
}

static def shouldApplyPitestPlugin(projectName) {  
	def subProjectsToIgnorePitestPlugin = [  
		'module-without-any-test-1', 'module-without-any-test-2'
	]  
	return !(projectName in subProjectsToIgnorePitestPlugin)  
}

@szpak szpak modified the milestones: 1.14.0, 1.14.1 Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants