Permalink
Browse files

- adding feature to run either tests only, scenarios only or both

- fixing bug with feature to start experiment from a particular point
- fixing typo in config files.
  • Loading branch information...
1 parent 4630d96 commit 6d58cd48635902a8d4797495e166581615d27425 @ajosephau committed Apr 8, 2015
@@ -9,7 +9,7 @@
log4j_properties_location=conf/properties/config_gso_test_log4j.properties
# ***************************
-# Superoptpimizer settings
+# Superoptimizer settings
# ***************************
# timeout - the maximum time in milliseconds allowed for a test or scenario to run before it is terminated.
@@ -19,6 +19,12 @@ timeout=60000
console_results_header=statement length | class file size
tab_delimited_file_results_header=statement length class file size
+# starting_program - the program number to start for tests or scenarios
+starting_program=1
+
+# mode - "all" = run tests and scenarios; "tests only" = run tests only; "scenarios only" = run scenarios only;
+mode=all
+
# ***************************
# Grammar settings
# ***************************
@@ -9,7 +9,7 @@
log4j_properties_location=conf/properties/config_gso_test_log4j.properties
# ***************************
-# Superoptpimizer settings
+# Superoptimizer settings
# ***************************
# timeout - the maximum time in milliseconds allowed for a test or scenario to run before it is terminated.
@@ -22,6 +22,9 @@ tab_delimited_file_results_header=program file size
# starting_program - the program number to start for tests or scenarios
starting_program=1
+# mode - "all" = run tests and scenarios; "tests only" = run tests only; "scenarios only" = run scenarios only;
+mode=all
+
# ***************************
# Grammar settings
# ***************************
@@ -9,7 +9,7 @@
log4j_properties_location=conf/properties/config_log4j.properties
# ***************************
-# Superoptpimizer settings
+# Superoptimizer settings
# ***************************
# timeout - the maximum time in milliseconds allowed for a test or scenario to run before it is terminated.
@@ -19,6 +19,12 @@ timeout=60000
console_results_header=program file size
tab_delimited_file_results_header=program file size
+# starting_program - the program number to start for tests or scenarios
+starting_program=1
+
+# mode - "all" = run tests and scenarios; "tests only" = run tests only; "scenarios only" = run scenarios only;
+mode=all
+
# ***************************
# Grammar settings
# ***************************
@@ -9,7 +9,7 @@
log4j_properties_location=conf\\properties\\config_lejos_experiment_log4j.properties
# ***************************
-# Superoptpimizer settings
+# Superoptimizer settings
# ***************************
# timeout - the maximum time in milliseconds allowed for a test or scenario to run before it is terminated.
@@ -22,6 +22,9 @@ tab_delimited_file_results_header=program file size
# starting_program - the program number to start for tests or scenarios
starting_program=1
+# mode - "all" = run tests and scenarios; "tests only" = run tests only; "scenarios only" = run scenarios only;
+mode=all
+
# ***************************
# Grammar settings
# ***************************
@@ -23,6 +23,7 @@
private static String testResultsOutputFilePath;
private static String scenarioResultsOutputFilePath;
private static String tabDelimitedFileResultsHeader;
+ private static String mode;
private static String consoleResultsHeader;
private static String testTemplateFolder;
private static String testTemplateFile;
@@ -36,6 +37,9 @@
private static String scenarioScriptPath;
private static String log4j_properties_location;
+ private static final String TEST_ONLY_MODE = "tests only";
+ private static final String SCENARIO_ONLY_MODE = "scenarios only";
+
private static int startingProgram;
private static int testInstanceCount;
private static int scenarioInstanceCount;
@@ -49,6 +53,7 @@ public static void setupParameters(String pathToConfigFile) throws IOException {
grammar_path = properties.getProperty("grammar_path");
consoleResultsHeader = properties.getProperty("console_results_header");
+ mode = properties.getProperty("mode");
tabDelimitedFileResultsHeader = properties.getProperty("tab_delimited_file_results_header");
startingProgram = Integer.parseInt(properties.getProperty("starting_program"));
recursionLimit = Integer.parseInt(properties.getProperty("program_builder_recursion_limit"));
@@ -86,40 +91,55 @@ public static void runAsSingleProcessStandalone(String inputFile) {
ProgramBuilder.outputListOfProgramsToFile(programs, programListOutputFilePath);
gsoLogger.info(programs.size() + " programs created.");
- gsoLogger.info("Step 2 of 5: Running tests. Current time: " + new java.util.Date());
- ProcessRunnerFactory testRunners = new ProcessRunnerFactory();
- testRunners.createTestRunners(testTemplateFolder, testTemplateFile, testOutputFolder, testOutputFile, testScriptPath, startingRule, timeout, testInstanceCount);
- testRunners.assignProgramsToProcessRunners(programs, startingProgram);
- programs.clear();
- TreeMap<String, String> testResults = new TreeMap<>();
- if(testInstanceCount > 1) {
- testResults = testRunners.runAllProcessesInParallel();
+ ArrayList<String> scenarioPrograms;
+
+ if(!mode.equals(SCENARIO_ONLY_MODE)) {
+ gsoLogger.info("Step 2 of 5: Running tests. Current time: " + new java.util.Date());
+ ProcessRunnerFactory testRunners = new ProcessRunnerFactory();
+ testRunners.createTestRunners(testTemplateFolder, testTemplateFile, testOutputFolder, testOutputFile, testScriptPath, startingRule, timeout, testInstanceCount);
+ testRunners.assignProgramsToProcessRunners(programs, startingProgram);
+ programs.clear();
+ TreeMap<String, String> testResults = new TreeMap<>();
+ if(testInstanceCount > 1) {
+ testResults = testRunners.runAllProcessesInParallel();
+ }
+ else {
+ testResults = testRunners.runAllProcessesInSerial();
+ }
+ testRunners.cleanupProcessOutputFolder();
+ gsoLogger.info("Step 3 of 5: Outputting test results. Current time: " + new java.util.Date());
+ ((TestRunner) testRunners.getFirstProcessRunner()).outputTestResults(testResults, startingRule, testResultsOutputFilePath);
+ scenarioPrograms = new ArrayList<>(testResults.keySet());
}
else {
- testResults = testRunners.runAllProcessesInSerial();
+ gsoLogger.info("Skipping step 2 of 5: Running tests. Current time: " + new java.util.Date());
+ gsoLogger.info("Skipping step 3 of 5: Outputting test results. Current time: " + new java.util.Date());
+ scenarioPrograms = new ArrayList<>(programs);
}
- testRunners.cleanupProcessOutputFolder();
- gsoLogger.info("Step 3 of 5: Outputting test results. Current time: " + new java.util.Date());
- ((TestRunner) testRunners.getFirstProcessRunner()).outputTestResults(testResults, startingRule, testResultsOutputFilePath);
-
- gsoLogger.info("Step 4 of 5: Running scenarios. Current time: " + new java.util.Date());
- ArrayList<String> scenarioPrograms = new ArrayList<>(testResults.keySet());
- ProcessRunnerFactory scenarioRunners = new ProcessRunnerFactory();
- scenarioRunners.createScenarioRunners(scenarioTemplateFolder, scenarioTemplateFile, scenarioOutputFolder, scenarioOutputFile, scenarioScriptPath, startingRule, timeout, scenarioInstanceCount);
- scenarioRunners.assignProgramsToProcessRunners(scenarioPrograms, startingProgram);
- TreeMap<String, String> scenarioResults = new TreeMap<>();
- if(scenarioInstanceCount > 1) {
- scenarioResults = scenarioRunners.runAllProcessesInSerial();
+
+ if(!mode.equals(TEST_ONLY_MODE)) {
+ gsoLogger.info("Step 4 of 5: Running scenarios. Current time: " + new java.util.Date());
+ ProcessRunnerFactory scenarioRunners = new ProcessRunnerFactory();
+ scenarioRunners.createScenarioRunners(scenarioTemplateFolder, scenarioTemplateFile, scenarioOutputFolder, scenarioOutputFile, scenarioScriptPath, startingRule, timeout, scenarioInstanceCount);
+ scenarioRunners.assignProgramsToProcessRunners(scenarioPrograms, startingProgram);
+ TreeMap<String, String> scenarioResults = new TreeMap<>();
+ if (scenarioInstanceCount > 1) {
+ scenarioResults = scenarioRunners.runAllProcessesInSerial();
+ } else {
+ scenarioResults = scenarioRunners.runAllProcessesInSerial();
+ }
+ scenarioRunners.cleanupProcessOutputFolder();
+
+ gsoLogger.info("Step 5 of 5: Outputting scenario results. Current time: " + new java.util.Date());
+ String formattedResults = ScenarioRunner.formatResultsForConsoleOutput(scenarioResults, startingRule, consoleResultsHeader);
+ ((ScenarioRunner) scenarioRunners.getFirstProcessRunner()).outputScenarioResults(scenarioResults, startingRule, tabDelimitedFileResultsHeader, scenarioResultsOutputFilePath);
+ gsoLogger.info(formattedResults);
}
else {
- scenarioResults = scenarioRunners.runAllProcessesInSerial();
+ gsoLogger.info("Skipping step 4 of 5: Running scenarios. Current time: " + new java.util.Date());
+ gsoLogger.info("Skipping step 5 of 5: Outputting scenario results. Current time: " + new java.util.Date());
}
- scenarioRunners.cleanupProcessOutputFolder();
- gsoLogger.info("Step 5 of 5: Outputting scenario results. Current time: " + new java.util.Date());
- String formattedResults = ScenarioRunner.formatResultsForConsoleOutput(scenarioResults, startingRule, consoleResultsHeader);
- ((ScenarioRunner) scenarioRunners.getFirstProcessRunner()).outputScenarioResults(scenarioResults, startingRule, tabDelimitedFileResultsHeader, scenarioResultsOutputFilePath);
- gsoLogger.info(formattedResults);
} catch (IOException e) {
gsoLogger.error(e.getMessage());
}
@@ -48,7 +48,7 @@ public void assignProgramsToProcessRunners(ArrayList<String> programs, int start
}
for(ProcessRunner pr: processRunners) {
- if(startingProgram > pr.getPrograms().size()) {
+ if(startingProgram < pr.getPrograms().size()) {
pr.setPrograms(new ArrayList(pr.getPrograms().subList(startingProgram, pr.getPrograms().size())));
}
}
@@ -20,7 +20,7 @@ public Object runProcesses() {
int count = 1, size = this.getPrograms().size();
scenarioResults = new TreeMap<>();
for (String program : this.getPrograms()) {
- processRunnerLogger.info("Currently running test " + count + " of " + size);
+ processRunnerLogger.info("Currently running scenario " + count + " of " + size);
this.buildProgram(this.getStartingRule(), program);
String processOutput = this.runProgram();
scenarioResults.put(program, processOutput);

0 comments on commit 6d58cd4

Please sign in to comment.