Skip to content

Commit

Permalink
Fix test-incompatibilities on Windows systems
Browse files Browse the repository at this point in the history
Changing hard-coded separators with OS agnostic File.separator/pathSeparator
  • Loading branch information
zaricu22 committed Oct 31, 2022
1 parent 21a1d7d commit 28b01a2
Show file tree
Hide file tree
Showing 23 changed files with 247 additions and 151 deletions.
20 changes: 12 additions & 8 deletions src/test/java/fr/inria/astor/test/D4JWorkflowTestSingle.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ public void testMath2Perfect() throws Exception {
fw.close();

cs.append("-parameters",
"logtestexecution:true:" + "maxmemory" + File.pathSeparator + "-Xmx4G" + File.pathSeparator
+ "fixedLocation:HypergeometricDistribution-321:" + "peOperator:insertbefore:pefile:"
"logtestexecution" + File.pathSeparator + "true" + File.pathSeparator + "" + "maxmemory"
+ File.pathSeparator + "-Xmx4G" + File.pathSeparator + "fixedLocation" + File.pathSeparator
+ "HypergeometricDistribution-321" + File.pathSeparator + "" + "peOperator" + File.pathSeparator
+ "insertbefore" + File.pathSeparator + "pefile" + File.pathSeparator + ""
+ f.getAbsolutePath());

AstorMain main1 = new AstorMain();
Expand Down Expand Up @@ -125,9 +127,10 @@ public void testLang44Perfect() throws Exception {
" if (val.length() == 1 && !Character.isDigit(val.charAt(0))) { throw new NumberFormatException(val + \" is not a valid number.\"); }");
fw.close();

cs.append("-parameters",
"logtestexecution:true:" + "maxmemory" + File.pathSeparator + "-Xmx4G" + File.pathSeparator
+ "fixedLocation:NumberUtils-145:" + "peOperator:insertbefore:pefile:" + f.getAbsolutePath());
cs.append("-parameters", "logtestexecution" + File.pathSeparator + "true" + File.pathSeparator + ""
+ "maxmemory" + File.pathSeparator + "-Xmx4G" + File.pathSeparator + "fixedLocation"
+ File.pathSeparator + "NumberUtils-145" + File.pathSeparator + "" + "peOperator" + File.pathSeparator
+ "insertbefore" + File.pathSeparator + "pefile" + File.pathSeparator + "" + f.getAbsolutePath());

AstorMain main1 = new AstorMain();

Expand Down Expand Up @@ -167,7 +170,7 @@ public void testMath28() throws Exception {
public void testMath40() throws Exception {
CommandSummary cs = new CommandSummary();
cs.command.putIfAbsent("-flthreshold", "0.2");
cs.command.put("-parameters", "logtestexecution:true");
cs.command.put("-parameters", "logtestexecution" + File.pathSeparator + "true");
cs.command.put("-ignoredtestcases",
"org.apache.commons.math.util.FastMathTest" + File.pathSeparator
+ "org.apache.commons.math.ode.nonstiff.ClassicalRungeKuttaIntegratorTest" + File.pathSeparator
Expand Down Expand Up @@ -346,7 +349,7 @@ public void testMath32JKali() throws Exception {
public void testMath40JKali() throws Exception {
CommandSummary cs = new CommandSummary();
cs.command.putIfAbsent("-flthreshold", "0");
cs.command.put("-parameters", "logtestexecution:true");
cs.command.put("-parameters", "logtestexecution" + File.pathSeparator + "true");
cs.command.put("-ignoredtestcases",
"org.apache.commons.math.util.FastMathTest" + File.pathSeparator
+ "org.apache.commons.math.ode.nonstiff.ClassicalRungeKuttaIntegratorTest" + File.pathSeparator
Expand Down Expand Up @@ -703,7 +706,8 @@ public static void createCommand(String bug_id, String approach, int timeout, St
}
System.out.println("\nConfiguration " + cs.command.toString());

cs.append("-parameters", "logtestexecution:true:" + "maxmemory" + File.pathSeparator + "-Xmx4G");
cs.append("-parameters", "logtestexecution" + File.pathSeparator + "true" + File.pathSeparator + ""
+ "maxmemory" + File.pathSeparator + "-Xmx4G");

}

Expand Down
17 changes: 11 additions & 6 deletions src/test/java/fr/inria/astor/test/FaultLocalizationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ private void helperLimitedTestAndClasses(FaultLocalization fl) throws Exception

cs.command.put("-faultlocalization", fl.name());
cs.command.put("-flthreshold", "0.0000");
cs.command.put("-parameters", "includeZeros:false:keepGZoltarFiles:false");
cs.command.put("-parameters", "includeZeros" + File.pathSeparator + "false" + File.pathSeparator
+ "keepGZoltarFiles" + File.pathSeparator + "false");

String oneFailingTestClassToRun = "org.apache.commons.math.analysis.solvers.BisectionSolverTest#testMath369";
String anotherTestClassToRun = "org.apache.commons.math.estimation.LevenbergMarquardtEstimatorTest";
Expand Down Expand Up @@ -191,7 +192,8 @@ private void helperLimitedTestAndClassesFromFile(FaultLocalization fl) throws Ex

cs.command.put("-faultlocalization", fl.name());
cs.command.put("-flthreshold", "0.0000");
cs.command.put("-parameters", "includeZeros:false:keepGZoltarFiles:false");
cs.command.put("-parameters", "includeZeros" + File.pathSeparator + "false" + File.pathSeparator
+ "keepGZoltarFiles" + File.pathSeparator + "false");

String oneFailingTestClassToRun = "org.apache.commons.math.analysis.solvers.BisectionSolverTest#testMath369";
String anotherTestClassToRun = "org.apache.commons.math.estimation.LevenbergMarquardtEstimatorTest";
Expand Down Expand Up @@ -262,7 +264,7 @@ public void testMath70FixedFL() throws Exception {
System.out.println(Arrays.toString(args));
CommandSummary command = new CommandSummary(args);

command.command.put("-parameters", "fixedLocation:BisectionSolver-72");
command.command.put("-parameters", "fixedLocation" + File.pathSeparator + "BisectionSolver-72");
main1.execute(command.flat());

List<ProgramVariant> solutions = main1.getEngine().getSolutions();
Expand All @@ -277,7 +279,8 @@ public void testFLMath70Ngz() throws Exception {
// by default, max generations is zero, that means, it does not evolve
cs.command.put("-faultlocalization", FaultLocalization.GZOLTAR1_7.name());
cs.command.put("-flthreshold", "0.0000");
cs.command.put("-parameters", "includeZeros:false:keepGZoltarFiles:false");
cs.command.put("-parameters", "includeZeros" + File.pathSeparator + "false" + File.pathSeparator
+ "keepGZoltarFiles" + File.pathSeparator + "false");

// We execute astor for creating the model and run FL

Expand Down Expand Up @@ -311,7 +314,8 @@ private void helperLimitedTestClasses(FaultLocalization flocalization) throws Ex

cs.command.put("-faultlocalization", flocalization.name());
cs.command.put("-flthreshold", "0.0000");
cs.command.put("-parameters", "includeZeros:false:keepGZoltarFiles:false");
cs.command.put("-parameters", "includeZeros" + File.pathSeparator + "false" + File.pathSeparator
+ "keepGZoltarFiles" + File.pathSeparator + "false");

String oneFailingTestClassToRun = "org.apache.commons.math.analysis.solvers.BisectionSolverTest";
String anotherTestClassToRun = "org.apache.commons.math.estimation.LevenbergMarquardtEstimatorTest";
Expand Down Expand Up @@ -358,7 +362,8 @@ private void helperLimitedNumberOfTestMethods(FaultLocalization fl) throws Excep

cs.command.put("-faultlocalization", fl.name());
cs.command.put("-flthreshold", "0.0000");
cs.command.put("-parameters", "includeZeros:false:keepGZoltarFiles:false");
cs.command.put("-parameters", "includeZeros" + File.pathSeparator + "false" + File.pathSeparator
+ "keepGZoltarFiles" + File.pathSeparator + "false");

String oneFailingTestClassToRun = "org.apache.commons.math.analysis.solvers.BisectionSolverTest#testMath369";
String anotherTestClassToRun = "org.apache.commons.math.estimation.LevenbergMarquardtEstimatorTest#testTrivial";
Expand Down
21 changes: 12 additions & 9 deletions src/test/java/fr/inria/astor/test/repair/QuixBugsRepairTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ public static CommandSummary getQuixBugsCommand(String name) {
cs.command.put("-flthreshold", "0.0");
cs.command.put("-loglevel", "INFO");
cs.command.put("-stopfirst", "TRUE");
cs.command.put("-parameters", "logtestexecution:TRUE:"
+ "disablelog:FALSE:maxtime:120:autocompile:false:gzoltarpackagetonotinstrument:com.google.gson_engine"
+ GZoltarFaultLocalization.PACKAGE_SEPARATOR + "java_programs_test");
cs.command.put("-parameters",
"logtestexecution" + File.pathSeparator + "TRUE" + File.pathSeparator + "" + "disablelog"
+ File.pathSeparator + "FALSE" + File.pathSeparator + "maxtime" + File.pathSeparator + "120"
+ File.pathSeparator + "autocompile" + File.pathSeparator + "false" + File.pathSeparator
+ "gzoltarpackagetonotinstrument" + File.pathSeparator + "com.google.gson_engine"
+ GZoltarFaultLocalization.PACKAGE_SEPARATOR + "java_programs_test");
cs.command.put("-location", new File("./examples/quixbugscompiled/" + name).getAbsolutePath());

return cs;
Expand Down Expand Up @@ -296,7 +299,7 @@ public void test_get_factorsRepair_cardumen_Debug_mode() throws Exception {
CommandSummary command = (getQuixBugsCommand("get_factors"));
command.command.put("-maxgen", "0");
command.command.put("-mode", "cardumen");
command.append("-parameters", "packageToInstrument:java_programs");
command.append("-parameters", "packageToInstrument" + File.pathSeparator + "java_programs");

main1.execute(command.flat());

Expand Down Expand Up @@ -427,8 +430,8 @@ public void testLISRepair_statement() throws Exception {
command.command.put("-maxgen", "1000");
// The suspicious is a var declaration used in the patch, so, the default
// transformation ignore it
command.append("-parameters", ExtensionPoints.INGREDIENT_TRANSFORM_STRATEGY.identifier + ":"
+ NoIngredientTransformation.class.getName());
command.append("-parameters", ExtensionPoints.INGREDIENT_TRANSFORM_STRATEGY.identifier + "" + File.pathSeparator
+ "" + NoIngredientTransformation.class.getName());
main1.execute(command.flat());

assertTrue("No solution", main1.getEngine().getSolutions().size() > 0);
Expand All @@ -452,8 +455,8 @@ public void testLISRepair_statement_debug() throws Exception {
CommandSummary command = (getQuixBugsCommand("lis"));
command.command.put("-maxgen", "0");
command.command.put("-loglevel", "ERROR");
command.append("-parameters", ExtensionPoints.INGREDIENT_TRANSFORM_STRATEGY.identifier + ":"
+ NoIngredientTransformation.class.getName());
command.append("-parameters", ExtensionPoints.INGREDIENT_TRANSFORM_STRATEGY.identifier + "" + File.pathSeparator
+ "" + NoIngredientTransformation.class.getName());

main1.execute(command.flat());

Expand Down Expand Up @@ -651,4 +654,4 @@ public void ne_test_hanoiRepair_cardumen1h() throws Exception {
assertTrue(main1.getEngine().getSolutions().size() == 0);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void testjGenProgWithEvoSuiteTests() throws Exception {
"-bintestfolder", "/target/test-classes", "-javacompliancelevel", "7", "-flthreshold", "0.5", "-out",
out.getAbsolutePath(), "-scope", "local", "-seed", "10", "-stopfirst", "true", "-population", "1",
"-stopfirst", "true", "-maxtime", "100", "-validation", "evosuite", "-maxgen", "250", "-parameters",
"overridemaxtime:false"
"overridemaxtime" + File.pathSeparator + "false"

};
System.out.println(Arrays.toString(args));
Expand Down Expand Up @@ -345,7 +345,7 @@ public void testMath70WithEvosuiteTests() throws Exception {
out.getAbsolutePath(), "-scope", "package", "-seed", "10", "-maxgen", "2000", "-population", "1",
"-stopfirst", "true", "-maxtime", "20",
// PARAMETER TO TEST
"-validation", "evosuite", "-parameters", "overridemaxtime:false"
"-validation", "evosuite", "-parameters", "overridemaxtime" + File.pathSeparator + "false"

};
System.out.println(Arrays.toString(args));
Expand Down Expand Up @@ -428,9 +428,36 @@ public void testBugProcessDoesNotReturn() throws Exception {
// memory
+ "-Xmx2048m " + "-cp "
// Classpath
+ "/Users/matias/develop/code/astor/target/test-classes:/Users/matias/develop/code/astor/target/classes:/Users/matias/.m2/repository/fr/inria/gforge/spoon/spoon-core/4.4.1/spoon-core-4.4.1.jar:/Users/matias/.m2/repository/org/eclipse/jdt/org.eclipse.jdt.core/3.12.0.v20150913-1717/org.eclipse.jdt.core-3.12.0.v20150913-1717.jar:/Users/matias/.m2/repository/com/martiansoftware/jsap/2.1/jsap-2.1.jar:/Users/matias/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:/Users/matias/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/Users/matias/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar:/Users/matias/.m2/repository/com/gzoltar/gzoltar/0.1.1/gzoltar-0.1.1.jar:/Users/matias/.m2/repository/junit/junit/4.11/junit-4.11.jar:/Users/matias/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/Users/matias/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/Users/matias/develop/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/214/0/.cp/:/Users/matias/develop/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/213/0/.cp/:/Users/matias/develop/code/astor/./examples/libs/junit-4.4.jar:/Users/matias/develop/code/astor/./outputMutation/math_70_spooned/bin/default/:/Users/matias/develop/wsastor/testES/libs/evosuite-1.0.3.jar:"
+ "/Users/matias/develop/code/astor/target/test-classes" + File.pathSeparator
+ "/Users/matias/develop/code/astor/target/classes" + File.pathSeparator
+ "/Users/matias/.m2/repository/fr/inria/gforge/spoon/spoon-core/4.4.1/spoon-core-4.4.1.jar"
+ File.pathSeparator
+ "/Users/matias/.m2/repository/org/eclipse/jdt/org.eclipse.jdt.core/3.12.0.v20150913-1717/org.eclipse.jdt.core-3.12.0.v20150913-1717.jar"
+ File.pathSeparator + "/Users/matias/.m2/repository/com/martiansoftware/jsap/2.1/jsap-2.1.jar"
+ File.pathSeparator + "/Users/matias/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar"
+ File.pathSeparator
+ "/Users/matias/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar"
+ File.pathSeparator
+ "/Users/matias/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar"
+ File.pathSeparator
+ "/Users/matias/.m2/repository/com/gzoltar/gzoltar/0.1.1/gzoltar-0.1.1.jar"
+ File.pathSeparator + "/Users/matias/.m2/repository/junit/junit/4.11/junit-4.11.jar"
+ File.pathSeparator
+ "/Users/matias/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"
+ File.pathSeparator
+ "/Users/matias/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar"
+ File.pathSeparator
+ "/Users/matias/develop/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/214/0/.cp/"
+ File.pathSeparator
+ "/Users/matias/develop/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/213/0/.cp/"
+ File.pathSeparator + "/Users/matias/develop/code/astor/./examples/libs/junit-4.4.jar"
+ File.pathSeparator
+ "/Users/matias/develop/code/astor/./outputMutation/math_70_spooned/bin/default/"
+ File.pathSeparator + "/Users/matias/develop/wsastor/testES/libs/evosuite-1.0.3.jar"
+ File.pathSeparator + ""
// TestGenerated by Evosuite
+ "/Users/matias/develop/code/astor/outputMutation/math_70_spooned/bin/evosuite/evosuite-tests/: "
+ "/Users/matias/develop/code/astor/outputMutation/math_70_spooned/bin/evosuite/evosuite-tests/"
+ File.pathSeparator + " "
// jUnit and arguments
+ "fr.inria.astor.junitexec.JUnitTestExecutor org.apache.commons.math.analysis.solvers.BisectionSolver_ESTest";
System.out.println("Running ");
Expand Down Expand Up @@ -518,7 +545,7 @@ public void testNonDeterministimsMath70WithEvosuiteTests() throws Exception {
"/target/classes", "-bintestfolder", "/target/test-classes", "-javacompliancelevel", "7",
"-flthreshold", "0.5", "-out", out.getAbsolutePath(), "-scope", "package", "-seed", "10", "-maxgen",
"250", "-population", "1", "-stopfirst", "true", "-maxtime", "100", "-validation", "evosuite",
"-parameters", "overridemaxtime:false"
"-parameters", "overridemaxtime" + File.pathSeparator + "false"

};
System.out.println(Arrays.toString(args));
Expand Down Expand Up @@ -556,4 +583,4 @@ public void testNonDeterministimsMath70WithEvosuiteTests() throws Exception {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ public void testExhaustiveTibraMath70LocalSolutionAssertPatch() throws Exception
"-scope", "package", "-seed", "10", "-maxgen", "10000", "-stopfirst", "false", //
"-maxtime", "100", "-loglevel", "INFO",
// For excluding regression
"-excludeRegression", "-parameters", "maxCombinationVariableLimit:true"
// reduced search space
+ ":maxVarCombination:1" + ":ingredienttransformstrategy:"
"-excludeRegression", "-parameters", "maxCombinationVariableLimit" + File.pathSeparator + "true"
// reduced search space
+ "" + File.pathSeparator + "maxVarCombination" + File.pathSeparator + "1" + ""
+ File.pathSeparator + "ingredienttransformstrategy" + File.pathSeparator + ""
+ RandomTransformationStrategy.class.getCanonicalName()

};
Expand Down Expand Up @@ -250,7 +251,9 @@ public void testExhaustiveCloneMath70LocalSolution() throws Exception {
File out = new File(ConfigurationProperties.getProperty("workingDirectory"));
String[] args = new String[] { "-dependencies", dep, "-mode", "custom", "-customengine",
DeepRepairExhausitiveCloneEngine.class.getCanonicalName(), ExtensionPoints.REPAIR_OPERATORS.argument(),
"fr.inria.astor.approaches.jgenprog.operators.InsertAfterOp:fr.inria.astor.approaches.jgenprog.operators.InsertBeforeOp:fr.inria.astor.approaches.jgenprog.operators.ReplaceOp",
"fr.inria.astor.approaches.jgenprog.operators.InsertAfterOp" + File.pathSeparator
+ "fr.inria.astor.approaches.jgenprog.operators.InsertBeforeOp" + File.pathSeparator
+ "fr.inria.astor.approaches.jgenprog.operators.ReplaceOp",

"-failing", "org.apache.commons.math.analysis.solvers.BisectionSolverTest", "-location",
new File("./examples/math_70").getAbsolutePath(), "-package", "org.apache.commons", "-srcjavafolder",
Expand Down Expand Up @@ -294,4 +297,4 @@ public void testExhaustiveCloneMath70LocalSolution() throws Exception {

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public void testMath70PackageSolutionsEvolving() throws Exception {
"-population", "1", "-reintroduce",
PopulationConformation.PARENTS.toString() + File.pathSeparator
+ PopulationConformation.SOLUTIONS.toString(), // Parameters:
"-parameters", "maxnumbersolutions:3:ignoredTestCases:org.apache.commons.math.estimation.MinpackTest"
"-parameters", "maxnumbersolutions" + File.pathSeparator + "3" + File.pathSeparator + "ignoredTestCases"
+ File.pathSeparator + "org.apache.commons.math.estimation.MinpackTest"

};
System.out.println(Arrays.toString(args));
Expand All @@ -60,4 +61,4 @@ public void testMath70PackageSolutionsEvolving() throws Exception {
assertTrue(withMultiple);
}

}
}
Loading

0 comments on commit 28b01a2

Please sign in to comment.