Skip to content

Commit

Permalink
Migrate slow tests from JUnit 4 to JUnit 5
Browse files Browse the repository at this point in the history
These tests were all migrated by hand, including updating the Gradle
logic for conditionally excluding them.
  • Loading branch information
liblit committed Jul 26, 2023
1 parent b4806b9 commit 63f3303
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ tasks.named<Test>("test") {

if (project.hasProperty("excludeSlowTests")) {
dependencies { testImplementation(testFixtures(project(":core"))) }
tasks.named<Test>("test") { useJUnit { excludeCategories("com.ibm.wala.tests.util.SlowTests") } }
tasks.named<Test>("test") { useJUnitPlatform { excludeTags("slow") } }
}

val ecjCompileTaskProviders =
Expand Down
1 change: 0 additions & 1 deletion cast/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ dependencies {
castJsPackageListDirectory(
project(mapOf("path" to ":cast:js", "configuration" to "packageListDirectory")))
javadocClasspath(projects.cast.js)
testRuntimeOnly(testFixtures(projects.core))
xlatorTestSharedLibrary(project("xlator_test"))
}

Expand Down
1 change: 0 additions & 1 deletion cast/java/ecj/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ dependencies {
project(
mapOf("path" to ":cast:java:test:data", "configuration" to "testJavaSourceDirectory")))
testImplementation(testFixtures(projects.cast.java))
testRuntimeOnly(testFixtures(projects.core))
}

application.mainClass = "com.ibm.wala.cast.java.ecj.util.SourceDirCallGraph"
Expand Down
1 change: 0 additions & 1 deletion cast/js/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dependencies {
implementation(projects.util)
javadocClasspath(projects.cast.js.rhino)
testFixturesImplementation(testFixtures(projects.cast))
testFixturesImplementation(testFixtures(projects.core))
testImplementation(testFixtures(projects.cast))
testImplementation(testFixtures(projects.core))
}
Expand Down
1 change: 0 additions & 1 deletion cast/js/nodejs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies {
implementation(projects.cast.js.rhino)
implementation(projects.core)
implementation(projects.util)
testRuntimeOnly(testFixtures(projects.core))
}

val downloadNodeJS by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
*/
package com.ibm.wala.cast.js.test;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.ibm.wala.cast.ipa.callgraph.CAstCallGraphUtil;
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder;
Expand All @@ -23,17 +24,16 @@
import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder;
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder;
import com.ibm.wala.tests.util.SlowTests;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
import com.ibm.wala.util.NullProgressMonitor;
import com.ibm.wala.util.WalaException;
import com.ibm.wala.util.collections.Iterator2Collection;
import java.io.IOException;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {

Expand Down Expand Up @@ -474,8 +474,8 @@ public void testProtoypeContamination()
verifyNoEdges(CG, "suffix:test2", "suffix:foo_of_A");
}

@Tag("slow")
@Test
@Category(SlowTests.class)
public void testStackOverflowOnSsaConversionBug()
throws IOException, IllegalArgumentException, CancelException, WalaException {
JSCallGraphBuilderUtil.makeScriptCG("tests", "stack_overflow_on_ssa_conversion.js");
Expand Down Expand Up @@ -917,18 +917,21 @@ public void testTryFinallyCrash()
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
}

@Test(expected = CallGraphBuilderCancelException.class)
@Category(SlowTests.class)
public void testManyStrings()
throws IllegalArgumentException, IOException, CancelException, WalaException {
@Tag("slow")
@Test
public void testManyStrings() throws IllegalArgumentException, IOException, WalaException {
SSAPropagationCallGraphBuilder B =
JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "many-strings.js");
B.getOptions().setTraceStringConstants(true);
IProgressMonitor monitor = ProgressMaster.make(new NullProgressMonitor(), 10000, false);
monitor.beginTask("build CG", 1);
CallGraph CG = B.makeCallGraph(B.getOptions(), monitor);
monitor.done();
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
assertThrows(
CallGraphBuilderCancelException.class,
() -> {
monitor.beginTask("build CG", 1);
CallGraph CG = B.makeCallGraph(B.getOptions(), monitor);
monitor.done();
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
});
}

@Test
Expand All @@ -947,7 +950,7 @@ public void testTutorialExample()
new Object[] {"loops.js", new String[] {"loops.js/three", "loops.js/four"}}
};

@Ignore("need to fix this. bug from Sukyoung's group")
@Disabled("need to fix this. bug from Sukyoung's group")
@Test
public void testLoops()
throws IllegalArgumentException, IOException, CancelException, WalaException {
Expand All @@ -973,7 +976,7 @@ public void testLoops()
},
};

@Ignore("need to fix this. bug from Sukyoung's group")
@Disabled("need to fix this. bug from Sukyoung's group")
@Test
public void testPrimitiveStrings()
throws IllegalArgumentException, IOException, CancelException, WalaException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,17 @@
import com.ibm.wala.ipa.cha.ClassHierarchy;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.ipa.cha.ClassHierarchyFactory;
import com.ibm.wala.tests.util.SlowTests;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.types.Descriptor;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
import java.io.IOException;
import java.util.Set;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Category(SlowTests.class)
@Tag("slow")
public class KawaCallGraphTest extends DynamicCallGraphTestBase {

@Test
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion util/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies {
compileOnly(libs.jspecify)
javadocClasspath(projects.core)
testImplementation(libs.hamcrest)
testRuntimeOnly(testFixtures(projects.core))
}

tasks.named<Javadoc>("javadoc") {
Expand Down

0 comments on commit 63f3303

Please # to comment.