Skip to content

Commit 7eeb658

Browse files
committed
Merge remote-tracking branch 'scala-2.10.x/junit' into master
2 parents 70a93f5 + 3494397 commit 7eeb658

File tree

5 files changed

+125
-2
lines changed

5 files changed

+125
-2
lines changed

build.xml

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,17 @@ TODO:
137137
<property name="build-quick.dir" value="${build.dir}/quick"/>
138138
<property name="build-pack.dir" value="${build.dir}/pack"/>
139139
<property name="build-osgi.dir" value="${build.dir}/osgi"/>
140+
<property name="build-junit.dir" value="${build.dir}/junit"/>
140141
<property name="build-strap.dir" value="${build.dir}/strap"/>
141142
<property name="build-docs.dir" value="${build.dir}/scaladoc"/>
142143
<property name="build-sbt.dir" value="${build.dir}/sbt-interface"/>
143144

144145
<property name="test.osgi.src" value="${partest.dir}/osgi/src"/>
145146
<property name="test.osgi.classes" value="${build-osgi.dir}/classes"/>
146147

148+
<property name="test.junit.src" value="${partest.dir}/junit"/>
149+
<property name="test.junit.classes" value="${build-junit.dir}/classes"/>
150+
147151
<property name="dists.dir" value="${basedir}/dists"/>
148152

149153
<property name="copyright.string" value="Copyright 2002-2013, LAMP/EPFL"/>
@@ -208,6 +212,12 @@ TODO:
208212
<dependency groupId="biz.aQute" artifactId="bnd" version="1.50.0"/>
209213
</artifact:dependencies>
210214

215+
<!-- JUnit -->
216+
<property name="junit.version" value="4.10"/>
217+
<artifact:dependencies pathId="junit.classpath" filesetId="junit.fileset">
218+
<dependency groupId="junit" artifactId="junit" version="${junit.version}"/>
219+
</artifact:dependencies>
220+
211221
<!-- Pax runner -->
212222
<property name="pax.exam.version" value="2.5.0"/>
213223
<artifact:dependencies pathId="pax.exam.classpath" filesetId="pax.exam.fileset">
@@ -218,10 +228,11 @@ TODO:
218228
<dependency groupId="org.ops4j.pax.swissbox" artifactId="pax-swissbox-framework" version="1.5.1"/>
219229
<dependency groupId="ch.qos.logback" artifactId="logback-core" version="0.9.20"/>
220230
<dependency groupId="ch.qos.logback" artifactId="logback-classic" version="0.9.20"/>
221-
<dependency groupId="junit" artifactId="junit" version="4.10"/>
231+
<dependency groupId="junit" artifactId="junit" version="${junit.version}"/>
222232
<dependency groupId="org.apache.felix" artifactId="org.apache.felix.framework" version="3.2.2"/>
223233
</artifact:dependencies>
224234

235+
225236
<artifact:dependencies pathId="partest.extras.classpath" filesetId="partest.extras.fileset" versionsId="partest.extras.versions">
226237
<dependency groupId="com.googlecode.java-diff-utils" artifactId="diffutils" version="1.3.0"/>
227238
<dependency groupId="org.scala-tools.testing" artifactId="test-interface" version="0.5" />
@@ -673,6 +684,12 @@ TODO:
673684
</path>
674685
-->
675686

687+
<path id="test.junit.compiler.build.path">
688+
<pathelement location="${test.junit.classes}"/>
689+
<path refid="quick.compiler.build.path"/>
690+
<path refid="junit.classpath"/>
691+
</path>
692+
676693
<path id="test.osgi.compiler.build.path">
677694
<pathelement location="${test.osgi.classes}"/>
678695
<pathelement location="${build-osgi.dir}/org.scala-lang.scala-library.jar"/>
@@ -1437,6 +1454,45 @@ TODO:
14371454
<stopwatch name="quick.sbt-interface.timer" action="total"/>
14381455
</target>
14391456

1457+
<target name="test.junit.init" depends="quick.done">
1458+
<uptodate property="test.junit.available" targetfile="${build-junit.dir}/test-compile.complete">
1459+
<srcfiles dir="${test.junit.src}">
1460+
<include name="**/*.scala"/>
1461+
</srcfiles>
1462+
</uptodate>
1463+
</target>
1464+
1465+
<target name="test.junit.comp" depends="test.junit.init, quick.done" unless="test.junit.available">
1466+
<stopwatch name="test.junit.compiler.timer"/>
1467+
<mkdir dir="${test.junit.classes}"/>
1468+
<scalacfork
1469+
destdir="${test.junit.classes}"
1470+
compilerpathref="quick.compiler.path"
1471+
params="${scalac.args.quick}"
1472+
srcdir="${test.junit.src}"
1473+
jvmargs="${scalacfork.jvmargs}">
1474+
<include name="**/*.scala"/>
1475+
<compilationpath refid="test.junit.compiler.build.path"/>
1476+
</scalacfork>
1477+
<touch file="${build-junit.dir}/test-compile.complete" verbose="no"/>
1478+
<stopwatch name="test.junit.compiler.timer" action="total"/>
1479+
</target>
1480+
1481+
<target name="test.junit" depends="test.junit.comp">
1482+
<stopwatch name="test.junit.timer"/>
1483+
<mkdir dir="${test.junit.classes}"/>
1484+
<junit fork="yes" haltonfailure="yes" showoutput="yes" printsummary="on">
1485+
<classpath refid="test.junit.compiler.build.path"/>
1486+
<batchtest fork="yes" todir="${build-junit.dir}">
1487+
<fileset dir="${test.junit.classes}">
1488+
<include name="**/*Test.class"/>
1489+
</fileset>
1490+
</batchtest>
1491+
<formatter type="plain"/>
1492+
</junit>
1493+
<stopwatch name="test.junit.timer" action="total"/>
1494+
</target>
1495+
14401496
<!-- See test/build-partest.xml for the macro(s) being used here. -->
14411497

14421498
<target name="test.suite" depends="pack.done">
@@ -1467,7 +1523,7 @@ TODO:
14671523

14681524
<!-- for use in PR validation, where stability is rarely broken, so we're going to use starr for locker,
14691525
and skip test.stability (which requires locker == quick) -->
1470-
<target name="test.core" depends="test.osgi, test.sbt, test.bc, test.interactive, test.continuations.suite, test.scaladoc, test.suite"/>
1526+
<target name="test.core" depends="test.osgi, test.sbt, test.bc, test.junit, test.interactive, test.continuations.suite, test.scaladoc, test.suite"/>
14711527
<target name="test.done" depends="test.core, test.stability"/>
14721528

14731529
<!-- ===========================================================================

src/eclipse/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ IMPORTANT
1111
Preferences/General/Workspace/Linked Resources. The value should be the absolute
1212
path to your scala checkout. All paths in project files are relative to this one,
1313
so nothing will work before you do so.
14+
Additionally, we start using Maven dependencies (e.g. junit) so you need to define
15+
`classpath variable` inside Eclipse. Define `M2_REPO` in Java/Build Path/Classpath Variables
16+
to point to your local Maven repository (e.g. $HOME/.m2/repository).
1417

1518
2. The Eclipse Java compiler does not allow certain calls to restricted APIs in the
1619
JDK. The Scala library uses such APIs, so you'd see this error:

src/eclipse/test-junit/.classpath

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="test-junit"/>
4+
<classpathentry combineaccessrules="false" kind="src" path="/reflect"/>
5+
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
6+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
7+
<classpathentry kind="lib" path="lib/ant/ant.jar"/>
8+
<classpathentry kind="lib" path="lib/jline.jar"/>
9+
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
10+
<classpathentry kind="var" path="M2_REPO/junit/junit/4.10/junit-4.10.jar"/>
11+
<classpathentry kind="output" path="build-test-junit"/>
12+
</classpath>

src/eclipse/test-junit/.project

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>test-junit</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.scala-ide.sdt.core.scalabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.scala-ide.sdt.core.scalanature</nature>
16+
<nature>org.eclipse.jdt.core.javanature</nature>
17+
</natures>
18+
<linkedResources>
19+
<link>
20+
<name>build-test-junit</name>
21+
<type>2</type>
22+
<locationURI>SCALA_BASEDIR/build/junit/classes</locationURI>
23+
</link>
24+
<link>
25+
<name>lib</name>
26+
<type>2</type>
27+
<locationURI>SCALA_BASEDIR/lib</locationURI>
28+
</link>
29+
<link>
30+
<name>test-junit</name>
31+
<type>2</type>
32+
<locationURI>SCALA_BASEDIR/test/junit</locationURI>
33+
</link>
34+
</linkedResources>
35+
</projectDescription>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package scala.tools.nsc
2+
package test
3+
4+
import org.junit.Assert._
5+
import org.junit.Test
6+
import org.junit.runner.RunWith
7+
import org.junit.runners.JUnit4
8+
9+
/** Sample JUnit test that shows that all pieces
10+
of JUnit infrastructure work correctly */
11+
@RunWith(classOf[JUnit4])
12+
class SampleTest {
13+
@Test
14+
def testMath: Unit = {
15+
assert(2+2 == 4, "you didn't get the math right fellow")
16+
}
17+
}

0 commit comments

Comments
 (0)