diff options
-rw-r--r-- | build.xml | 60 | ||||
-rw-r--r-- | test/junit/scala/tools/nsc/SampleTest.scala | 17 |
2 files changed, 75 insertions, 2 deletions
@@ -137,6 +137,7 @@ TODO: <property name="build-quick.dir" value="${build.dir}/quick"/> <property name="build-pack.dir" value="${build.dir}/pack"/> <property name="build-osgi.dir" value="${build.dir}/osgi"/> + <property name="build-junit.dir" value="${build.dir}/junit"/> <property name="build-strap.dir" value="${build.dir}/strap"/> <property name="build-docs.dir" value="${build.dir}/scaladoc"/> <property name="build-sbt.dir" value="${build.dir}/sbt-interface"/> @@ -144,6 +145,9 @@ TODO: <property name="test.osgi.src" value="${partest.dir}/osgi/src"/> <property name="test.osgi.classes" value="${build-osgi.dir}/classes"/> + <property name="test.junit.src" value="${partest.dir}/junit"/> + <property name="test.junit.classes" value="${build-junit.dir}/classes"/> + <property name="dists.dir" value="${basedir}/dists"/> <property name="copyright.string" value="Copyright 2002-2013, LAMP/EPFL"/> @@ -208,6 +212,12 @@ TODO: <dependency groupId="biz.aQute" artifactId="bnd" version="1.50.0"/> </artifact:dependencies> + <!-- JUnit --> + <property name="junit.version" value="4.10"/> + <artifact:dependencies pathId="junit.classpath" filesetId="junit.fileset"> + <dependency groupId="junit" artifactId="junit" version="${junit.version}"/> + </artifact:dependencies> + <!-- Pax runner --> <property name="pax.exam.version" value="2.5.0"/> <artifact:dependencies pathId="pax.exam.classpath" filesetId="pax.exam.fileset"> @@ -218,10 +228,11 @@ TODO: <dependency groupId="org.ops4j.pax.swissbox" artifactId="pax-swissbox-framework" version="1.5.1"/> <dependency groupId="ch.qos.logback" artifactId="logback-core" version="0.9.20"/> <dependency groupId="ch.qos.logback" artifactId="logback-classic" version="0.9.20"/> - <dependency groupId="junit" artifactId="junit" version="4.10"/> + <dependency groupId="junit" artifactId="junit" version="${junit.version}"/> <dependency groupId="org.apache.felix" artifactId="org.apache.felix.framework" version="3.2.2"/> </artifact:dependencies> + <artifact:dependencies pathId="partest.extras.classpath" filesetId="partest.extras.fileset" versionsId="partest.extras.versions"> <dependency groupId="com.googlecode.java-diff-utils" artifactId="diffutils" version="1.3.0"/> </artifact:dependencies> @@ -680,6 +691,12 @@ TODO: <pathelement location="${pack.dir}/lib/scala-swing.jar"/> <!-- TODO - segregate swing tests (there can't be many) --> </path> + <path id="test.junit.compiler.build.path"> + <pathelement location="${test.junit.classes}"/> + <path refid="quick.compiler.build.path"/> + <path refid="junit.classpath"/> + </path> + <path id="test.osgi.compiler.build.path"> <pathelement location="${test.osgi.classes}"/> <pathelement location="${build-osgi.dir}/org.scala-lang.scala-library.jar"/> @@ -1445,6 +1462,45 @@ TODO: <stopwatch name="quick.sbt-interface.timer" action="total"/> </target> + <target name="test.junit.init" depends="quick.done"> + <uptodate property="test.junit.available" targetfile="${build-junit.dir}/test-compile.complete"> + <srcfiles dir="${test.junit.src}"> + <include name="**/*.scala"/> + </srcfiles> + </uptodate> + </target> + + <target name="test.junit.comp" depends="test.junit.init, quick.done" unless="test.junit.available"> + <stopwatch name="test.junit.compiler.timer"/> + <mkdir dir="${test.junit.classes}"/> + <scalacfork + destdir="${test.junit.classes}" + compilerpathref="quick.compiler.path" + params="${scalac.args.quick}" + srcdir="${test.junit.src}" + jvmargs="${scalacfork.jvmargs}"> + <include name="**/*.scala"/> + <compilationpath refid="test.junit.compiler.build.path"/> + </scalacfork> + <touch file="${build-junit.dir}/test-compile.complete" verbose="no"/> + <stopwatch name="test.junit.compiler.timer" action="total"/> + </target> + + <target name="test.junit" depends="test.junit.comp"> + <stopwatch name="test.junit.timer"/> + <mkdir dir="${test.junit.classes}"/> + <junit fork="yes" haltonfailure="yes" showoutput="yes" printsummary="on"> + <classpath refid="test.junit.compiler.build.path"/> + <batchtest fork="yes" todir="${build-junit.dir}"> + <fileset dir="${test.junit.classes}"> + <include name="**/*Test.class"/> + </fileset> + </batchtest> + <formatter type="plain"/> + </junit> + <stopwatch name="test.junit.timer" action="total"/> + </target> + <property name="partest.srcdir" value="files" /> <!-- TODO: make targets for `pending` and other subdirs --> <target name="test.run" depends="pack.done"> @@ -1516,7 +1572,7 @@ TODO: <!-- for use in PR validation, where stability is rarely broken, so we're going to use starr for locker, and skip test.stability (which requires locker == quick) --> - <target name="test.core" depends="test.osgi, test.sbt, test.bc, test.interactive, test.continuations.suite, test.scaladoc, test.suite"/> + <target name="test.core" depends="test.osgi, test.sbt, test.bc, test.junit, test.interactive, test.continuations.suite, test.scaladoc, test.suite"/> <target name="test.done" depends="test.core, test.stability"/> diff --git a/test/junit/scala/tools/nsc/SampleTest.scala b/test/junit/scala/tools/nsc/SampleTest.scala new file mode 100644 index 0000000000..8e026da1ea --- /dev/null +++ b/test/junit/scala/tools/nsc/SampleTest.scala @@ -0,0 +1,17 @@ +package scala.tools.nsc +package test + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +/** Sample JUnit test that shows that all pieces + of JUnit infrastructure work correctly */ +@RunWith(classOf[JUnit4]) +class SampleTest { + @Test + def testMath: Unit = { + assert(2+2 == 4, "you didn't get the math right fellow") + } +} |