Skip to content

Commit cb03227

Browse files
committed
Added a null check for the htmlDir in PyCoverageTask
Handling of an edge case: If the user configures the project to run covergae but there is no coverage output (i.e. no coverage to report), the htmlDir parsed from the output will ultimately be null, and thus the call to project.file(htmlDir) fails with IllegalArgumentException: path may not be null or empty string. path='null'
1 parent 963cc18 commit cb03227

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pygradle-plugin/src/main/groovy/com/linkedin/gradle/python/tasks/PyCoverageTask.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ class PyCoverageTask extends PyTestTask {
7373
String htmlDir = streamProcessor.htmlDir
7474
String coverage = streamProcessor.coverage
7575

76-
77-
FileUtils.copyDirectoryToDirectory(project.file(htmlDir), coverageOutputDir)
76+
// If there is no coverage to report, then the htmlDir value will be empty
77+
if (htmlDir != null) {
78+
FileUtils.copyDirectoryToDirectory(project.file(htmlDir), coverageOutputDir)
79+
}
7880

7981
CoverageXmlReporter coverageXmlReport = new CoverageXmlReporter(coverage)
8082
coverageReport.text = coverageXmlReport.generateXML()

0 commit comments

Comments
 (0)