From ab31c19ebd96884885edb12411cd4087c3e4a78a Mon Sep 17 00:00:00 2001 From: Emma Lautz Date: Fri, 22 Nov 2019 14:45:04 -0800 Subject: [PATCH] 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' --- .../com/linkedin/gradle/python/tasks/PyCoverageTask.groovy | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pygradle-plugin/src/main/groovy/com/linkedin/gradle/python/tasks/PyCoverageTask.groovy b/pygradle-plugin/src/main/groovy/com/linkedin/gradle/python/tasks/PyCoverageTask.groovy index 2d7fc2ae..039b0c4d 100644 --- a/pygradle-plugin/src/main/groovy/com/linkedin/gradle/python/tasks/PyCoverageTask.groovy +++ b/pygradle-plugin/src/main/groovy/com/linkedin/gradle/python/tasks/PyCoverageTask.groovy @@ -73,8 +73,10 @@ class PyCoverageTask extends PyTestTask { String htmlDir = streamProcessor.htmlDir String coverage = streamProcessor.coverage - - FileUtils.copyDirectoryToDirectory(project.file(htmlDir), coverageOutputDir) + // If there is no coverage to report, then the htmlDir value will be empty + if ((htmlDir != null) && !htmlDir.isEmpty()) { + FileUtils.copyDirectoryToDirectory(project.file(htmlDir), coverageOutputDir) + } CoverageXmlReporter coverageXmlReport = new CoverageXmlReporter(coverage) coverageReport.text = coverageXmlReport.generateXML()