From e8293c4344abe9f12892817ec4253a46db5569b7 Mon Sep 17 00:00:00 2001 From: Eduard Vlasov Date: Thu, 21 Dec 2017 13:19:17 +0500 Subject: [PATCH 1/2] Added include and exclude params for coverage reports (issue #6) --- src/main/java/org/utplsql/cli/RunCommand.java | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/utplsql/cli/RunCommand.java b/src/main/java/org/utplsql/cli/RunCommand.java index 690a453..525a334 100644 --- a/src/main/java/org/utplsql/cli/RunCommand.java +++ b/src/main/java/org/utplsql/cli/RunCommand.java @@ -18,6 +18,7 @@ import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -83,6 +84,21 @@ public class RunCommand { "most actual. Use this if you use CLI with a development version of utPLSQL-framework") private boolean skipCompatibilityCheck = false; + @Parameter( + names = {"-include"}, + description = "Comma-separated object list to include in the coverage report. " + + "Format: [schema.]package[,[schema.]package ...]. See coverage reporting options in framework documentation" + ) + private String includeObjects = null; + + @Parameter( + names = {"-exclude"}, + description = "Comma-separated object list to exclude from the coverage report. " + + "Format: [schema.]package[,[schema.]package ...]. See coverage reporting options in framework documentation" + ) + private String excludeObjects = null; + + private CompatibilityProxy compatibilityProxy; public ConnectionInfo getConnectionInfo() { @@ -112,6 +128,24 @@ public int run() throws Exception { sourceMappingOptions[0] = getFileMapperOptionsByParamListItem(this.sourcePathParams, baseDir); testMappingOptions[0] = getFileMapperOptionsByParamListItem(this.testPathParams, baseDir); + ArrayList includeObjectsList; + ArrayList excludeObjectsList; + + if (includeObjects != null && !includeObjects.isEmpty()) { + includeObjectsList = new ArrayList<>(Arrays.asList(includeObjects.split(","))); + } else { + includeObjectsList = new ArrayList<>(); + } + + if (excludeObjects != null && !excludeObjects.isEmpty()) { + excludeObjectsList = new ArrayList<>(Arrays.asList(excludeObjects.split(","))); + } else { + excludeObjectsList = new ArrayList<>(); + } + + final ArrayList finalIncludeObjectsList = includeObjectsList; + final ArrayList finalExcludeObjectsList = excludeObjectsList; + // Do the reporters initialization, so we can use the id to run and gather results. try (Connection conn = ci.getConnection()) { @@ -143,15 +177,23 @@ public int run() throws Exception { // Run tests. executorService.submit(() -> { try (Connection conn = ci.getConnection()) { - new TestRunner() + TestRunner testRunner = new TestRunner() .addPathList(testPaths) .addReporterList(reporterList) .sourceMappingOptions(sourceMappingOptions[0]) .testMappingOptions(testMappingOptions[0]) .colorConsole(this.colorConsole) .failOnErrors(true) - .skipCompatibilityCheck(skipCompatibilityCheck) - .run(conn); + .skipCompatibilityCheck(skipCompatibilityCheck); + + for (String includeObject: finalIncludeObjectsList){ + testRunner.includeObject(includeObject); + } + for (String excludeObject: finalExcludeObjectsList){ + testRunner.excludeObject(excludeObject); + } + + testRunner.run(conn); } catch (SomeTestsFailedException e) { returnCode[0] = this.failureExitCode; } catch (SQLException e) { From daf939bdd1f67db72395665226a72d626d85821b Mon Sep 17 00:00:00 2001 From: Eduard Vlasov Date: Thu, 21 Dec 2017 13:50:54 +0500 Subject: [PATCH 2/2] Fixed readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index fd88eed..9c2a288 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,12 @@ For example CLI-3.0.4 is compatible with database framework 3.0.0-3.0.4 but not --failure-exit-code - Override the exit code on failure, defaults to 1. You can set it to 0 to always exit with a success status. -scc - If specified, skips the compatibility-check with the version of the database framework. If you skip compatibility-check, CLI will expect the most actual framework version +-include=package_list - Comma-separated object list to include in the coverage report. + Format: [schema.]package[,[schema.]package ...]. + See coverage reporting options in framework documentation. +-exclude=package_list - Comma-separated object list to exclude from the coverage report. + Format: [schema.]package[,[schema.]package ...]. + See coverage reporting options in framework documentation. ``` Parameters -f, -o, -s are correlated. That is parameters -o and -s are controlling outputs for reporter specified by the preceding -f parameter.