From 4ff7bac051d7aa167a7f29bf8ecb12bc1964ffb0 Mon Sep 17 00:00:00 2001 From: Eugene Platonov Date: Tue, 12 Nov 2024 18:55:08 -0500 Subject: [PATCH] Clarify skip message and add an it-test for `skip` --- .../test_skip_configured/invoker.properties | 1 + src/it/test_skip_configured/pom.xml | 43 +++++++++++++++++++ .../src/main/scala/HelloServiceScala.scala | 6 +++ .../test/scala/HelloServiceScalaTest.scala | 12 ++++++ src/it/test_skip_configured/validate.groovy | 13 ++++++ .../plugin/SCoveragePreCompileMojo.java | 2 +- 6 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/it/test_skip_configured/invoker.properties create mode 100644 src/it/test_skip_configured/pom.xml create mode 100644 src/it/test_skip_configured/src/main/scala/HelloServiceScala.scala create mode 100644 src/it/test_skip_configured/src/test/scala/HelloServiceScalaTest.scala create mode 100644 src/it/test_skip_configured/validate.groovy diff --git a/src/it/test_skip_configured/invoker.properties b/src/it/test_skip_configured/invoker.properties new file mode 100644 index 00000000..3e51a5a6 --- /dev/null +++ b/src/it/test_skip_configured/invoker.properties @@ -0,0 +1 @@ +invoker.goals=clean verify site -e -ntp \ No newline at end of file diff --git a/src/it/test_skip_configured/pom.xml b/src/it/test_skip_configured/pom.xml new file mode 100644 index 00000000..4479ce31 --- /dev/null +++ b/src/it/test_skip_configured/pom.xml @@ -0,0 +1,43 @@ + + + + 4.0.0 + + + it.scoverage-maven-plugin + integration_tests_parent + 1.0-SNAPSHOT + ../integration_tests_parent/pom.xml + + + test_skip_configured + 1.0-SNAPSHOT + jar + Test Scoverage is Skipped when configured + Test Scoverage is Skipped when configured + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + net.alchim31.maven + scala-maven-plugin + + + org.scalatest + scalatest-maven-plugin + + + @project.groupId@ + @project.artifactId@ + + true + + + + + diff --git a/src/it/test_skip_configured/src/main/scala/HelloServiceScala.scala b/src/it/test_skip_configured/src/main/scala/HelloServiceScala.scala new file mode 100644 index 00000000..f946ee95 --- /dev/null +++ b/src/it/test_skip_configured/src/main/scala/HelloServiceScala.scala @@ -0,0 +1,6 @@ +package service + +object HelloServiceScala { + def hello = { "Hello" } + +} diff --git a/src/it/test_skip_configured/src/test/scala/HelloServiceScalaTest.scala b/src/it/test_skip_configured/src/test/scala/HelloServiceScalaTest.scala new file mode 100644 index 00000000..cf1636c0 --- /dev/null +++ b/src/it/test_skip_configured/src/test/scala/HelloServiceScalaTest.scala @@ -0,0 +1,12 @@ +package service + +import org.scalatest.wordspec.AnyWordSpec + +class HelloServiceScalaTest extends AnyWordSpec { + + "HelloService" should { + "say hello" in { + assert(HelloServiceScala.hello == "Hello") + } + } +} diff --git a/src/it/test_skip_configured/validate.groovy b/src/it/test_skip_configured/validate.groovy new file mode 100644 index 00000000..9c671cdb --- /dev/null +++ b/src/it/test_skip_configured/validate.groovy @@ -0,0 +1,13 @@ +try { + + def logFile = new File(basedir, "build.log") + def lines = logFile.readLines() + assert lines.contains("[INFO] Skipping Scoverage execution as configured") + assert !lines.contains("Generating \"SCoverage\" report") + + return true + +} catch (Throwable e) { + e.printStackTrace() + return false +} diff --git a/src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java b/src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java index de2dccca..1a3e2f24 100644 --- a/src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java +++ b/src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java @@ -198,7 +198,7 @@ public void execute() throws MojoExecutionException if ( skip ) { - getLog().info( "Skipping Scoverage execution" ); + getLog().info( "Skipping Scoverage execution as configured" ); Properties projectProperties = project.getProperties();