Commit 13b2f982 authored by Jonathan Shahen's avatar Jonathan Shahen
Browse files

Clean up

parent 5107a615
......@@ -5,6 +5,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Level;
......@@ -55,24 +57,23 @@ public class MohawkInstance {
private SMVSpecHelper SMV_helper = new SMVSpecHelper();
public int run(String[] args) {
// create Options object
Options options = new Options();
try {
Options options = new Options();
CommandLineParser parser = new BasicParser();
setupOptions(options, args);
setupOptions(options);
CommandLineParser parser = new BasicParser();
try {
CommandLine cmd = parser.parse(options, args);
setupLoggerOptions(cmd, options, args);
setupLoggerOptions(cmd, options);
if (setupReturnImmediatelyOptions(cmd, options, args)) { return 0; }
if (setupReturnImmediatelyOptions(cmd, options)) { return 0; }
setupUserPreferenceOptions(cmd, options, args);
setupUserPreferenceOptions(cmd, options);
setupSmvSpecOptions(cmd, options, args);
setupSmvSpecOptions(cmd, options);
setupResultOptions(cmd, options, args);
setupResultOptions(cmd, options);
// Execute the test cases
if (cmd.hasOption("run")) {
......@@ -102,16 +103,16 @@ public class MohawkInstance {
results.done();
}
} catch (ParseException e) {
if (logger.getLevel() == Level.FINEST) {
e.printStackTrace();
}
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
logger.severe(errors.toString());
logger.severe(e.getMessage());
return -2;
} catch (Exception e) {
if (logger.getLevel() == Level.FINEST) {
e.printStackTrace();
}
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
logger.severe(errors.toString());
logger.severe(e.getMessage());
return -1;
......@@ -133,7 +134,7 @@ public class MohawkInstance {
}
@SuppressWarnings("static-access")
private void setupOptions(Options options, String[] args) {
private void setupOptions(Options options) {
// Add Information Options
options.addOption("help", false, "Print this message");
options.addOption("version", false, "Prints the version (" + VERSION + ") information");
......@@ -220,7 +221,7 @@ public class MohawkInstance {
.hasArg().create("run"));
}
private void setupSmvSpecOptions(CommandLine cmd, Options options, String[] args) {
private void setupSmvSpecOptions(CommandLine cmd, Options options) {
// Load in SPEC Files
// SMV File
if (cmd.hasOption("smvfile")) {
......@@ -284,7 +285,7 @@ public class MohawkInstance {
}
}
private void setupUserPreferenceOptions(CommandLine cmd, Options options, String[] args) {
private void setupUserPreferenceOptions(CommandLine cmd, Options options) {
// Set the Console's Max Width
if (cmd.hasOption("maxw")) {
logger.fine("[OPTION] Setting the console's maximum width");
......@@ -309,8 +310,7 @@ public class MohawkInstance {
}
private void setupLoggerOptions(CommandLine cmd, Options options, String[] args) throws SecurityException,
IOException {
private void setupLoggerOptions(CommandLine cmd, Options options) throws SecurityException, IOException {
// Logging Level
logger.setUseParentHandlers(false);
consoleHandler.setFormatter(new MohawkConsoleFormatter());
......@@ -391,8 +391,8 @@ public class MohawkInstance {
}
}
private Boolean setupReturnImmediatelyOptions(CommandLine cmd, Options options, String[] args) {
if (cmd.hasOption("help") == true || args.length < 1) {
private Boolean setupReturnImmediatelyOptions(CommandLine cmd, Options options) {
if (cmd.hasOption("help") == true || cmd.getOptions().length < 1) {
HelpFormatter f = new HelpFormatter();
if (cmd.hasOption("maxw")) {
try {
......@@ -452,7 +452,7 @@ public class MohawkInstance {
return false;
}
private void setupResultOptions(CommandLine cmd, Options options, String[] args) {
private void setupResultOptions(CommandLine cmd, Options options) {
if (cmd.hasOption("results")) {
logger.fine("[OPTION] Changing the results file");
resultsFile = cmd.getOptionValue("results");
......
......@@ -13,7 +13,7 @@ import org.junit.Test;
*
*/
public class RegressionTests {
public class MohawkRegressionTests {
private String defaultParameters = "-loglevel debug -logfile n";
@Test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment