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

Clean up

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