Skip to content

Commit e8293c4

Browse files
author
Eduard Vlasov
committed
Added include and exclude params for coverage reports (issue #6)
1 parent 0ed3a31 commit e8293c4

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

src/main/java/org/utplsql/cli/RunCommand.java

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.sql.Connection;
1919
import java.sql.SQLException;
2020
import java.util.ArrayList;
21+
import java.util.Arrays;
2122
import java.util.List;
2223
import java.util.concurrent.ExecutorService;
2324
import java.util.concurrent.Executors;
@@ -83,6 +84,21 @@ public class RunCommand {
8384
"most actual. Use this if you use CLI with a development version of utPLSQL-framework")
8485
private boolean skipCompatibilityCheck = false;
8586

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+
86102
private CompatibilityProxy compatibilityProxy;
87103

88104
public ConnectionInfo getConnectionInfo() {
@@ -112,6 +128,24 @@ public int run() throws Exception {
112128
sourceMappingOptions[0] = getFileMapperOptionsByParamListItem(this.sourcePathParams, baseDir);
113129
testMappingOptions[0] = getFileMapperOptionsByParamListItem(this.testPathParams, baseDir);
114130

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+
115149
// Do the reporters initialization, so we can use the id to run and gather results.
116150
try (Connection conn = ci.getConnection()) {
117151

@@ -143,15 +177,23 @@ public int run() throws Exception {
143177
// Run tests.
144178
executorService.submit(() -> {
145179
try (Connection conn = ci.getConnection()) {
146-
new TestRunner()
180+
TestRunner testRunner = new TestRunner()
147181
.addPathList(testPaths)
148182
.addReporterList(reporterList)
149183
.sourceMappingOptions(sourceMappingOptions[0])
150184
.testMappingOptions(testMappingOptions[0])
151185
.colorConsole(this.colorConsole)
152186
.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);
155197
} catch (SomeTestsFailedException e) {
156198
returnCode[0] = this.failureExitCode;
157199
} catch (SQLException e) {

0 commit comments

Comments
 (0)