Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
48 changes: 45 additions & 3 deletions src/main/java/org/utplsql/cli/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -112,6 +128,24 @@ public int run() throws Exception {
sourceMappingOptions[0] = getFileMapperOptionsByParamListItem(this.sourcePathParams, baseDir);
testMappingOptions[0] = getFileMapperOptionsByParamListItem(this.testPathParams, baseDir);

ArrayList<String> includeObjectsList;
ArrayList<String> 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<String> finalIncludeObjectsList = includeObjectsList;
final ArrayList<String> finalExcludeObjectsList = excludeObjectsList;

// Do the reporters initialization, so we can use the id to run and gather results.
try (Connection conn = ci.getConnection()) {

Expand Down Expand Up @@ -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){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done in Fluent interface manner to stay within the same pattern. Will need a change in Java API. I will try to do this soon.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your efforts, though! Very appreciated!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean create a function like "includeObjects" or something like that? I also can do that, in general, if you are busy now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, creating a function in the TestRunner class, return the TestRunner instance so we can continue to use fluent interface pattern. The need to create a loop outside just to add objects feels uncomfortable to me :)

testRunner.includeObject(includeObject);
}
for (String excludeObject: finalExcludeObjectsList){
testRunner.excludeObject(excludeObject);
}

testRunner.run(conn);
} catch (SomeTestsFailedException e) {
returnCode[0] = this.failureExitCode;
} catch (SQLException e) {
Expand Down