|
18 | 18 | import java.sql.Connection; |
19 | 19 | import java.sql.SQLException; |
20 | 20 | import java.util.ArrayList; |
| 21 | +import java.util.Arrays; |
21 | 22 | import java.util.List; |
22 | 23 | import java.util.concurrent.ExecutorService; |
23 | 24 | import java.util.concurrent.Executors; |
@@ -83,6 +84,21 @@ public class RunCommand { |
83 | 84 | "most actual. Use this if you use CLI with a development version of utPLSQL-framework") |
84 | 85 | private boolean skipCompatibilityCheck = false; |
85 | 86 |
|
| 87 | + @Parameter( |
| 88 | + names = {"-include"}, |
| 89 | + description = "Comma-separated object list to include in the coverage report. " + |
| 90 | + "Format: [schema.]package[,[schema.]package ...]. See coverage reporting options in framework documentation" |
| 91 | + ) |
| 92 | + private String includeObjects = null; |
| 93 | + |
| 94 | + @Parameter( |
| 95 | + names = {"-exclude"}, |
| 96 | + description = "Comma-separated object list to exclude from the coverage report. " + |
| 97 | + "Format: [schema.]package[,[schema.]package ...]. See coverage reporting options in framework documentation" |
| 98 | + ) |
| 99 | + private String excludeObjects = null; |
| 100 | + |
| 101 | + |
86 | 102 | private CompatibilityProxy compatibilityProxy; |
87 | 103 |
|
88 | 104 | public ConnectionInfo getConnectionInfo() { |
@@ -112,6 +128,24 @@ public int run() throws Exception { |
112 | 128 | sourceMappingOptions[0] = getFileMapperOptionsByParamListItem(this.sourcePathParams, baseDir); |
113 | 129 | testMappingOptions[0] = getFileMapperOptionsByParamListItem(this.testPathParams, baseDir); |
114 | 130 |
|
| 131 | + ArrayList<String> includeObjectsList; |
| 132 | + ArrayList<String> excludeObjectsList; |
| 133 | + |
| 134 | + if (includeObjects != null && !includeObjects.isEmpty()) { |
| 135 | + includeObjectsList = new ArrayList<>(Arrays.asList(includeObjects.split(","))); |
| 136 | + } else { |
| 137 | + includeObjectsList = new ArrayList<>(); |
| 138 | + } |
| 139 | + |
| 140 | + if (excludeObjects != null && !excludeObjects.isEmpty()) { |
| 141 | + excludeObjectsList = new ArrayList<>(Arrays.asList(excludeObjects.split(","))); |
| 142 | + } else { |
| 143 | + excludeObjectsList = new ArrayList<>(); |
| 144 | + } |
| 145 | + |
| 146 | + final ArrayList<String> finalIncludeObjectsList = includeObjectsList; |
| 147 | + final ArrayList<String> finalExcludeObjectsList = excludeObjectsList; |
| 148 | + |
115 | 149 | // Do the reporters initialization, so we can use the id to run and gather results. |
116 | 150 | try (Connection conn = ci.getConnection()) { |
117 | 151 |
|
@@ -143,15 +177,23 @@ public int run() throws Exception { |
143 | 177 | // Run tests. |
144 | 178 | executorService.submit(() -> { |
145 | 179 | try (Connection conn = ci.getConnection()) { |
146 | | - new TestRunner() |
| 180 | + TestRunner testRunner = new TestRunner() |
147 | 181 | .addPathList(testPaths) |
148 | 182 | .addReporterList(reporterList) |
149 | 183 | .sourceMappingOptions(sourceMappingOptions[0]) |
150 | 184 | .testMappingOptions(testMappingOptions[0]) |
151 | 185 | .colorConsole(this.colorConsole) |
152 | 186 | .failOnErrors(true) |
153 | | - .skipCompatibilityCheck(skipCompatibilityCheck) |
154 | | - .run(conn); |
| 187 | + .skipCompatibilityCheck(skipCompatibilityCheck); |
| 188 | + |
| 189 | + for (String includeObject: finalIncludeObjectsList){ |
| 190 | + testRunner.includeObject(includeObject); |
| 191 | + } |
| 192 | + for (String excludeObject: finalExcludeObjectsList){ |
| 193 | + testRunner.excludeObject(excludeObject); |
| 194 | + } |
| 195 | + |
| 196 | + testRunner.run(conn); |
155 | 197 | } catch (SomeTestsFailedException e) { |
156 | 198 | returnCode[0] = this.failureExitCode; |
157 | 199 | } catch (SQLException e) { |
|
0 commit comments