Skip to content

Add ability to run test in DrJava in parallel and run test in ant in parallel. #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 103 additions & 7 deletions drjava/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@
</taskdef>
<property name="coverage-report-dir" value="coverage_report"/>
<property name="coverage-exec" value="jacoco.exec"/>

<!--property name="TestParallel" value="${arg0}"/>
<property name="ThreadCount" value="${arg1}"/-->
<condition property="Thread" value="${ThreadCount}" else="4">
<isset property="ThreadCount"/>
</condition>
<fileset id="libs" dir="lib" includes="*.jar" /> <!-- Only include jars that are at the top level (not in buildlib) -->
<fileset id="jrelibs" dir="${java.home}/lib" includes="*.jar" />
<echo message="libs = ${toString:libs}" />
<echo message="jrelibs = ${toString:jrelibs}" />
<echo message="libs = ${toString:libs}" level="verbose" />
<echo message="jrelibs = ${toString:jrelibs}" level="verbose"/>
<fileset id="extlibs" dir="${java.home}/lib/ext" includes="*.jar" />
<echo message="extlibs = ${toString:extlibs}" />
<echo message="extlibs = ${toString:extlibs}" level="verbose"/>
<!-- ************
Help Targets
************ -->
Expand Down Expand Up @@ -345,7 +349,19 @@
<target name="iterate-tests" depends="resolve-test-formatter-class">
<!-- Calls do-test, unless that is overridden by the caller -->
<echo message="Executing iterate-tests" />
<property name="do-test-target" value="do-test" />
<if>
<equals arg1="${TestParallel}" arg2="true" />
<then>
<echo message="Test in Parallel with ${Thread} threads" />
<property name="do-test-target" value="do-test-for" />
</then>
<else>
<echo message="Test in Sequential" />
<property name="do-test-target" value="do-test" />
</else>
</if>


<condition property="test-iteration-message">
<not>
<equals arg1="${test-repeat}" arg2="1" />
Expand Down Expand Up @@ -425,8 +441,50 @@
</if>

</target>




<target name="do-test-for" depends="resolve-jvm-args">
<echo message="Running all tests matching '${test-filter-string}' with command '${test-jvm}', using '${junit-jar}' and '${test-tools}'" />
<for param="fileFullName" parallel= "true" threadCount="${Thread}">
<path>
<fileset dir="classes/test">
<!--include name="**/*${test-filter-string}*/**" /-->
<include name="**/*Test.class" />
</fileset>
</path>
<sequential>
<echo message="file= @{fileFullName}" level="verbose"/>
<antcall target="execute-one-test" inheritRefs="true" inheritall="true">
<param name="fileFullName" value="@{fileFullName}"/>
</antcall>
</sequential>
</for>
<antcall target="generate-cover" />
</target>

<target name="do-test-foreach" depends="resolve-jvm-args">
<echo message="Running all tests matching '${test-filter-string}' with command '${test-jvm}', using '${junit-jar}' and '${test-tools}'" />
<foreach
target="execute-one-test"
maxthreads="16"
inheritall="true"
inheritrefs="true"
parallel="true"
param="fileFullName">
<path>
<fileset dir="classes/test">
<!--include name="**/*${test-filter-string}*/**" /-->
<include name="**/*Test.class" />
</fileset>
</path>
</foreach>
<antcall target="generate-cover" />
</target>



<target name="do-test" depends="resolve-jvm-args">
<echo message="Running all tests matching '${test-filter-string}' with command '${test-jvm}', using '${junit-jar}' and '${test-tools}'" />
<jacoco:coverage xmlns:jacoco="antlib:org.jacoco.ant">
Expand Down Expand Up @@ -454,7 +512,7 @@
<batchtest fork="true">
<fileset dir="classes/test">
<filename name="**/*${test-filter-string}*/**" />
<filename name="**/*Test.class" />
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
Expand All @@ -463,6 +521,44 @@
<antcall target="generate-cover" />
</target>

<target name="execute-one-test">
<sequential>
<basename property="filename" file="${fileFullName}"/>
<echo message="In execute-one-test, we are running '${fileFullName}' with testname ${filename}" level="verbose" />
<jacoco:coverage xmlns:jacoco="antlib:org.jacoco.ant">
<junit haltonfailure="${test-halt}" failureproperty="test-failed"
fork="yes" forkmode="perTest" maxmemory="2G" jvm="${test-jvm}" dir="${basedir}">
<classpath>
<pathelement location="${test-tools}" />
<pathelement location="${junit-jar}" />
<pathelement location="lib/buildlib/plt-ant.jar" /> <!-- required for custom formatter -->
<pathelement location="lib/buildlib/netbeans-memory-leak-utils.jar" />
<pathelement location="classes/test" />
<pathelement location="classes/base" />
<pathelement location="classes/lib" />
</classpath>
<assertions>
<enable />
</assertions>
<syspropertyset>
<propertyref prefix="plt." />
<propertyref prefix="drjava." />
<!-- Add any properties that should be passed on -->
</syspropertyset>
<jvmarg line="${jvm-args}" />
<formatter classname="${test-formatter-class}" usefile="${test-output-to-file}" />
<!--test name="${test.source.absolute}"/-->
<batchtest fork="true">
<fileset dir="classes/test">
<include name="**/${filename}*" />
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
<fail if="test-failed" message="One unit test failed."/>
</sequential>
</target>

<target name = "generate-cover" xmlns:jacoco="antlib:org.jacoco.ant">
<jacoco:report>

Expand Down
2 changes: 1 addition & 1 deletion drjava/src/edu/rice/cs/drjava/CommandLineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,4 @@ private void checkFile(File relativeFile, String funnyName)
// Close this doc to clean up after ourselves for the next check.
_mf.getModel().closeFile(doc);
}
}
}
2 changes: 1 addition & 1 deletion drjava/src/edu/rice/cs/drjava/DrJavaTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ public void run() {
});
Utilities.clearEventQueue(); // ensure that all listener actions triggered by this document update have completed
}
}
}
16 changes: 16 additions & 0 deletions drjava/src/edu/rice/cs/drjava/config/OptionConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,16 @@ public static Vector<KeyStroke> vector(KeyStroke... ks) {
public static final VectorOption<KeyStroke> KEY_COMPILE_PROJECT =
new VectorOption<KeyStroke>("key.compile.project", new KeyStrokeOption("",null), to.vector());

/** The key binding for testing a project in parallel. */
public static final VectorOption<KeyStroke> KEY_JUNIT_PROJECT_PARALLEL =
new VectorOption<KeyStroke>("key.junit.project", new KeyStrokeOption("",null), to.vector());


/** The key binding for testing a project. */
public static final VectorOption<KeyStroke> KEY_JUNIT_PROJECT =
new VectorOption<KeyStroke>("key.junit.project", new KeyStrokeOption("",null), to.vector());


/** The key binding for running a project. */
public static final VectorOption<KeyStroke> KEY_RUN_PROJECT =
new VectorOption<KeyStroke>("key.run.project", new KeyStrokeOption("",null), to.vector());
Expand Down Expand Up @@ -764,12 +770,20 @@ public static Vector<KeyStroke> vector(KeyStroke... ks) {
new VectorOption<KeyStroke>("key.test",
new KeyStrokeOption("",null),
to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_T, MASK|SHIFT_MASK)));
/** The key binding for testing the current document in parallel. */
public static final VectorOption<KeyStroke> KEY_TEST_PARALLEL =
new VectorOption<KeyStroke>("key.reset.interactions", new KeyStrokeOption("",null), to.vector());


/** The key binding for testing all open JUnit test cases. */
public static final VectorOption<KeyStroke> KEY_TEST_ALL =
new VectorOption<KeyStroke>("key.test.all",
new KeyStrokeOption("",null),
to.vector(KeyStroke.getKeyStroke(KeyEvent.VK_T, MASK)));
/** The key binding for testing all open JUnit test cases in parallel. */
public static final VectorOption<KeyStroke> KEY_TEST_ALL_PARALLEL =
new VectorOption<KeyStroke>("key.reset.interactions", new KeyStrokeOption("",null), to.vector());


/** The key binding for generating javadoc for all documents */
public static final VectorOption<KeyStroke> KEY_JAVADOC_ALL =
Expand Down Expand Up @@ -807,6 +821,8 @@ public static Vector<KeyStroke> vector(KeyStroke... ks) {
public static final VectorOption<KeyStroke> KEY_RESET_INTERACTIONS =
new VectorOption<KeyStroke>("key.reset.interactions", new KeyStrokeOption("",null), to.vector());



/** The key binding for viewing the interactions classpath. */
public static final VectorOption<KeyStroke> KEY_VIEW_INTERACTIONS_CLASSPATH =
new VectorOption<KeyStroke>("key.view.interactions.classpath", new KeyStrokeOption("",null), to.vector());
Expand Down
14 changes: 13 additions & 1 deletion drjava/src/edu/rice/cs/drjava/model/DJError.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.io.Serializable;

import edu.rice.cs.util.FileOps;
import edu.rice.cs.util.Log;
import edu.rice.cs.util.UnexpectedException;


Expand All @@ -48,6 +49,10 @@
* @version $Id$
*/
public class DJError implements Comparable<DJError>, Serializable {

/** Debugging log. */
public static Log _log = new Log("DJError.txt", false);

private volatile File _file;

/** zero-based line number. */
Expand Down Expand Up @@ -78,6 +83,9 @@ public DJError(File file, int lineNumber, int startColumn, String message, boole
_startColumn = startColumn;
_message = message;
_isWarning = isWarning;
//TODO
_log.log("_lineNumber= "+_lineNumber);
_log.log("_file= "+_file);
if (lineNumber < 0) _noLocation = true;
}

Expand Down Expand Up @@ -127,7 +135,11 @@ public String fileName() {
/** Sets the line number.
* @param ln line number
*/
public void setLineNumber(int ln) { _lineNumber = ln; }
public void setLineNumber(int ln) {
//TODO
_log.log("in setLineNumber _lineNumber= "+_lineNumber);
_lineNumber = ln;
}

/** Gets the column where the error begins.
* @return the starting column
Expand Down
Loading