Skip to content

Commit 5cd90af

Browse files
author
mgricken
committed
The build.xml file now allows you to specify which configuration file
is to be used using the "test-drjava-config" property (e.g. on the command line by passing "-Dtest-drjava-config=some.file"). If this property is not set, then the build.xml file will use an empty configuration file, testFiles/drjava.basic.config, which I have added to the repository. This is an important change: Testing from now on does NOT use the .drjava file in the user's home directory anymore, unless explicitly told to do so. By default, the unit tests are now run with default settings, regardless of the user's settings --This line, and those below, will be ignored AM testFiles/drjava.basic.config M src/edu/rice/cs/drjava/DrJavaTestCase.java M build.xml git-svn-id: file:///tmp/test-svn/trunk@4147 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent 0dc9a35 commit 5cd90af

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

drjava/build.xml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@
8989
<echo message=" a plain text file with 'name=value' pairs, one per" />
9090
<echo message=" line. They work the same was as the properties" />
9191
<echo message=" specified on the command line using '-Dname=value'." />
92+
<echo message="test-drjava-config: Specifies which DrJava configuration file is used" />
93+
<echo message=" during tests (by setting the 'test.drjava.config'" />
94+
<echo message=" property. This is effective only during unit tests" />
95+
<echo message=" and is the equivalent to the '-config' command" />
96+
<echo message=" line option. If this option is not used, then the" />
97+
<echo message=" testFiles/drjava.basic.config file is used." />
9298
<echo message="test-spec: A matching string to filter the tests to be run; may" />
9399
<echo message=" be comma-delimited to run multiple test sets." />
94100
<echo message=" (Default: empty string)" />
@@ -1098,11 +1104,26 @@
10981104
</target>
10991105

11001106
<target name="resolve-jvm-args">
1101-
<condition property="jvm-args" value="-server">
1107+
<!-- First create individual parts of the 'jvm-args' line; note that the space at
1108+
the end of the strings is necessary to separate the values. -->
1109+
1110+
<!-- 'force-server' property -->
1111+
<condition property="jvm-args-force-server" value="-server ">
11021112
<istrue value="${force-server}" />
11031113
</condition>
11041114
<!-- else... -->
1105-
<property name="jvm-args" value="" />
1115+
<property name="jvm-args-force-server" value="" />
1116+
1117+
<!-- 'test-drjava-config' property -->
1118+
<condition property="jvm-args-test-drjava-config" value="-Dtest.drjava.config=${test-drjava-config} ">
1119+
<isset property="test-drjava-config" />
1120+
</condition>
1121+
<!-- else... -->
1122+
<property name="jvm-args-test-drjava-config" value="-Dtest.drjava.config=${basedir}/testFiles/drjava.basic.config " />
1123+
1124+
<!-- Now assemble all arguments; no spaces between the individual arguments so
1125+
arguments not set disappear completely (without multiple spaces inbetween). -->
1126+
<property name="jvm-args" value="${jvm-args-force-server}${jvm-args-test-drjava-config}" />
11061127
</target>
11071128

11081129
<target name="resolve-test-formatter-class">

drjava/src/edu/rice/cs/drjava/DrJavaTestCase.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
* system is correctly initialized for every test.
4242
*/
4343
public class DrJavaTestCase extends TestCase {
44-
44+
/** System property with the name of an alternative DrJava configuration file used during testing. */
45+
public static final String TEST_DRJAVA_CONFIG_PROPERTY = "test.drjava.config";
46+
4547
/** Create a new DrJava test case. */
4648
public DrJavaTestCase() { super(); }
4749

@@ -56,6 +58,11 @@ public class DrJavaTestCase extends TestCase {
5658
protected void setUp() throws Exception {
5759
super.setUp();
5860
Utilities.TEST_MODE = true;
61+
final String newName = System.getProperty(TEST_DRJAVA_CONFIG_PROPERTY);
62+
if (newName!=null) {
63+
DrJava.setPropertiesFile(newName);
64+
DrJava._initConfig();
65+
}
5966
}
6067

6168
/** Clean up for every test case.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#DrJava configuration file
2+
#Sat Feb 10 22:12:47 CST 2007

0 commit comments

Comments
 (0)