Skip to content

Commit d9eb0a7

Browse files
committed
Added compatibility warning in case Random Execution Order was specified
Also refactored it all into one function
1 parent 144adf0 commit d9eb0a7

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.slf4j.LoggerFactory;
88
import org.utplsql.api.*;
99
import org.utplsql.api.compatibility.CompatibilityProxy;
10+
import org.utplsql.api.compatibility.OptionalFeatures;
1011
import org.utplsql.api.db.DefaultDatabaseInformation;
1112
import org.utplsql.api.exception.DatabaseNotCompatibleException;
1213
import org.utplsql.api.exception.OracleCreateStatmenetStuckException;
@@ -174,11 +175,7 @@ public int doRun() throws OracleCreateStatmenetStuckException {
174175
initDatabase(dataSource);
175176
reporterList = initReporters(dataSource);
176177

177-
// Output a message if --failureExitCode is set but database framework is not capable of
178-
String msg = RunCommandChecker.getCheckFailOnErrorMessage(failureExitCode, compatibilityProxy.getUtPlsqlVersion());
179-
if (msg != null) {
180-
System.out.println(msg);
181-
}
178+
checkForCompatibility(compatibilityProxy.getUtPlsqlVersion());
182179

183180
ExecutorService executorService = Executors.newFixedThreadPool(1 + reporterList.size());
184181

@@ -240,6 +237,27 @@ public int run() {
240237
return Cli.DEFAULT_ERROR_CODE;
241238
}
242239

240+
private void checkForCompatibility( Version utPlSqlVersion ) {
241+
if (!OptionalFeatures.FAIL_ON_ERROR.isAvailableFor(utPlSqlVersion) && failureExitCode != 1 ) {
242+
System.out.println("You specified option `--failure-exit-code` but your database framework version (" +
243+
utPlSqlVersion.getNormalizedString() + ") is not able to " +
244+
"redirect failureCodes. Please upgrade to a newer version if you want to use that feature.");
245+
}
246+
247+
if ( !OptionalFeatures.RANDOM_EXECUTION_ORDER.isAvailableFor(utPlSqlVersion) && randomTestOrder ) {
248+
System.out.println("You specified option `-random` but your database framework version (" +
249+
utPlSqlVersion.getNormalizedString() + ") is not able to " +
250+
"redirect failureCodes. Please upgrade to a newer version if you want to use that feature.");
251+
}
252+
253+
if ( !OptionalFeatures.RANDOM_EXECUTION_ORDER.isAvailableFor(utPlSqlVersion) && randomTestOrderSeed != null ) {
254+
System.out.println("You specified option `-seed` but your database framework version (" +
255+
utPlSqlVersion.getNormalizedString() + ") is not able to " +
256+
"redirect failureCodes. Please upgrade to a newer version if you want to use that feature.");
257+
}
258+
259+
}
260+
243261
TestRunner newTestRunner( List<Reporter> reporterList) {
244262

245263
final File baseDir = new File("").getAbsoluteFile();

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,4 @@ static void checkOracleI18nExists(Connection con) throws SQLException {
2727
System.out.println("Download from http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html");
2828
}
2929
}
30-
31-
/** Returns a warning message if failureExitCode is specified but database version is too low
32-
*
33-
* @param failureExitCode
34-
* @param databaseVersion
35-
*/
36-
static String getCheckFailOnErrorMessage(int failureExitCode, Version databaseVersion) {
37-
if ( failureExitCode != 1 && !OptionalFeatures.FAIL_ON_ERROR.isAvailableFor(databaseVersion)) {
38-
return "Your database framework version (" + databaseVersion.getNormalizedString() + ") is not able to " +
39-
"redirect failureCodes. Please upgrade to a newer version if you want to use that feature.";
40-
}
41-
42-
return null;
43-
}
4430
}

0 commit comments

Comments
 (0)