Skip to content

Commit 3e59216

Browse files
authored
Merge pull request scala#7847 from SethTisue/split-junit-sources
split out shared testing code into new subproject
2 parents 879483d + 63d2580 commit 3e59216

File tree

121 files changed

+437
-392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+437
-392
lines changed

build.sbt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ lazy val scalap = configureAsSubproject(project)
536536
.dependsOn(compiler)
537537

538538
lazy val partest = configureAsSubproject(project)
539-
.dependsOn(library, reflect, compiler, scalap, scaladoc, junit % "compile->test")
539+
.dependsOn(library, reflect, compiler, replFrontend, scalap, scaladoc, testkit)
540540
.settings(Osgi.settings)
541541
.settings(AutomaticModuleName.settings("scala.partest"))
542542
.settings(
@@ -614,8 +614,21 @@ lazy val bench = project.in(file("test") / "benchmarks")
614614
).settings(inConfig(JmhPlugin.JmhKeys.Jmh)(scalabuild.JitWatchFilePlugin.jitwatchSettings))
615615

616616

617+
lazy val testkit = project.in(file("src") / "testkit")
618+
.dependsOn(library)
619+
.settings(clearSourceAndResourceDirectories)
620+
.settings(commonSettings)
621+
.settings(disableDocs)
622+
.settings(skip in publish := true)
623+
.settings(
624+
scalacOptions += "-feature",
625+
libraryDependencies ++= Seq(junitDep, asmDep),
626+
unmanagedSourceDirectories in Compile := List(baseDirectory.value),
627+
)
628+
629+
617630
lazy val junit = project.in(file("test") / "junit")
618-
.dependsOn(library, reflect, compiler, replFrontend, scaladoc)
631+
.dependsOn(testkit, compiler, replFrontend, scaladoc)
619632
.settings(clearSourceAndResourceDirectories)
620633
.settings(commonSettings)
621634
//.settings(scalacOptions in Compile += "-Xlint:-nullary-unit,-adapted-args")
@@ -627,7 +640,7 @@ lazy val junit = project.in(file("test") / "junit")
627640
(forkOptions in Test) := (forkOptions in Test).value.withWorkingDirectory((baseDirectory in ThisBuild).value),
628641
(forkOptions in Test in testOnly) := (forkOptions in Test in testOnly).value.withWorkingDirectory((baseDirectory in ThisBuild).value),
629642
scalacOptions += "-feature",
630-
libraryDependencies ++= Seq(junitDep, junitInterfaceDep, jolDep),
643+
libraryDependencies ++= Seq(junitInterfaceDep, jolDep),
631644
testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-v"),
632645
unmanagedSourceDirectories in Compile := Nil,
633646
unmanagedSourceDirectories in Test := List(baseDirectory.value)

src/intellij/compilerOptionsExporter.iml.SAMPLE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<module type="JAVA_MODULE" version="4">
3-
<component name="NewModuleRootManager" inherit-compiler-output="false">
3+
<component name="NewModuleRootManager">
44
<output url="file://$MODULE_DIR$/../../build/quick/classes/compilerOptionsExporter" />
55
<output-test url="file://$MODULE_DIR$/../../out/test/compilerOptionsExporter" />
66
<exclude-output />

src/intellij/junit.iml.SAMPLE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<orderEntry type="module" module-name="interactive" />
1818
<orderEntry type="module" module-name="scaladoc" />
1919
<orderEntry type="module" module-name="partest" />
20+
<orderEntry type="module" module-name="testkit" />
2021
<orderEntry type="library" name="junit-deps" level="project" />
2122
<orderEntry type="library" name="starr" level="project" />
2223
</component>

src/intellij/partest.iml.SAMPLE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<orderEntry type="module" module-name="scaladoc" />
1717
<orderEntry type="module" module-name="repl" />
1818
<orderEntry type="module" module-name="repl-frontend" />
19+
<orderEntry type="module" module-name="testkit" />
1920
<orderEntry type="library" name="partest-deps" level="project" />
2021
<orderEntry type="library" name="starr" level="project" />
2122
</component>

src/intellij/scala.ipr.SAMPLE

Lines changed: 216 additions & 190 deletions
Large diffs are not rendered by default.

src/intellij/testkit.iml.SAMPLE

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager">
4+
<output url="file://$MODULE_DIR$/../../build/quick/classes/testkit" />
5+
<output-test url="file://$MODULE_DIR$/../../out/test/testkit" />
6+
<exclude-output />
7+
<content url="file://$MODULE_DIR$/../testkit">
8+
<sourceFolder url="file://$MODULE_DIR$/../testkit" isTestSource="false" />
9+
</content>
10+
<orderEntry type="inheritedJdk" />
11+
<orderEntry type="sourceFolder" forTests="false" />
12+
<orderEntry type="module" module-name="library" />
13+
<orderEntry type="library" name="testkit-deps" level="project" />
14+
<orderEntry type="library" name="starr" level="project" />
15+
</component>
16+
</module>

src/partest/scala/tools/partest/BytecodeTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import scala.collection.JavaConverters._
1616
import scala.tools.asm.{ClassReader, ClassWriter}
1717
import scala.tools.asm.tree._
1818
import java.io.{InputStream, File => JFile}
19-
import scala.tools.testing.ASMConverters
19+
import scala.tools.testkit.ASMConverters
2020
import AsmNode._
2121
import scala.tools.nsc.CloseableRegistry
2222

test/junit/scala/tools/testing/ASMConverters.scala renamed to src/testkit/scala/tools/testkit/ASMConverters.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* additional information regarding copyright ownership.
1111
*/
1212

13-
package scala.tools.testing
13+
package scala.tools.testkit
1414

1515
import scala.collection.JavaConverters._
1616
import scala.tools.asm

test/junit/scala/util/AllocationTest.scala renamed to src/testkit/scala/tools/testkit/AllocationTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package scala.util
1+
package scala.tools.testkit
22

33
import java.lang.management.ManagementFactory
44

test/junit/scala/tools/testing/AssertUtil.scala renamed to src/testkit/scala/tools/testkit/AssertUtil.scala

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
package scala.tools
2-
package testing
1+
package scala.tools.testkit
32

4-
import org.junit.Assert
5-
import Assert._
3+
import org.junit.Assert, Assert._
64
import scala.reflect.ClassTag
75
import scala.runtime.ScalaRunTime.stringOf
86
import scala.collection.GenIterable
97
import scala.collection.JavaConverters._
108
import scala.collection.mutable
119
import scala.concurrent.{Await, Awaitable, SyncVar, TimeoutException}
12-
import scala.tools.nsc.settings.ScalaVersion
1310
import scala.util.Try
14-
import scala.util.Properties.javaSpecVersion
11+
import scala.util.Properties.isJavaAtLeast
1512
import scala.util.control.NonFatal
1613
import java.lang.ref._
1714
import java.lang.reflect.{Array => _, _}
@@ -21,6 +18,14 @@ import java.util.IdentityHashMap
2118
* that are ultimately based on junit.Assert primitives.
2219
*/
2320
object AssertUtil {
21+
22+
/** Assert on Java 8, but on later versions, just print if assert would fail. */
23+
def assert8(b: => Boolean, msg: => Any) =
24+
if (!isJavaAtLeast("9"))
25+
assert(b, msg)
26+
else if (!b)
27+
println(s"assert not $msg")
28+
2429
private final val timeout = 60 * 1000L // wait a minute
2530

2631
private implicit class `ref helper`[A](val r: Reference[A]) extends AnyVal {
@@ -110,13 +115,6 @@ object AssertUtil {
110115
}
111116
}
112117

113-
private[this] val version8 = ScalaVersion("8")
114-
115-
/** Assert on Java 8, but on later versions, just print if assert would fail. */
116-
def assert8(b: => Boolean, msg: => Any) =
117-
if (ScalaVersion(javaSpecVersion) == version8) assert(b, msg)
118-
else if (!b) println(s"assert not $msg")
119-
120118
/** Assert no new threads, with some margin for arbitrary threads to exit. */
121119
def assertZeroNetThreads(body: => Unit): Unit = {
122120
val result = new SyncVar[Option[Throwable]]

test/junit/scala/tools/testing/TempDir.scala renamed to src/testkit/scala/tools/testkit/TempDir.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package scala.tools.testing
1+
package scala.tools.testkit
22

33
import java.io.{IOException, File}
44

test/files/jvm/javaReflection/Test.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,10 @@ getSimpleName / getCanonicalName / isAnonymousClass / isLocalClass / isSynthetic
5050
will change some day).
5151
*/
5252

53-
import scala.tools.nsc.settings.ScalaVersion
54-
import scala.util.Properties.javaSpecVersion
53+
import scala.tools.testkit.AssertUtil.assert8
5554

5655
object Test {
5756

58-
def assert8(b: => Boolean, msg: => Any) = {
59-
if (ScalaVersion(javaSpecVersion) == ScalaVersion("1.8")) assert(b, msg)
60-
else if (!b) println(s"assert not $msg")
61-
}
62-
6357
def tr[T](m: => T): String = try {
6458
val r = m
6559
if (r == null) "null"

test/files/jvm/t7253/test.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import scala.tools.partest.BytecodeTest
2-
import scala.tools.testing.ASMConverters
2+
import scala.tools.testkit.ASMConverters
33

44
import scala.tools.nsc.util.JavaClassPath
55
import java.io.InputStream

test/files/run/BoxUnboxTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import org.junit.Assert._
2-
import scala.tools.testing.AssertUtil._
2+
import scala.tools.testkit.AssertUtil._
33

44
class VCI(val x: Int) extends AnyVal { override def toString = "" + x }
55

test/files/run/bcodeInlinerMixed/Test_2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import scala.tools.partest.BytecodeTest
2-
import scala.tools.testing.ASMConverters
2+
import scala.tools.testkit.ASMConverters
33
import ASMConverters._
44

55
class D {

test/files/run/t8601-closure-elim.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// scalac: -Ydelambdafy:method -opt:l:inline -opt-inline-from:**
22
//
33
import scala.tools.partest.BytecodeTest
4-
import scala.tools.testing.ASMConverters.instructionsFromMethod
4+
import scala.tools.testkit.ASMConverters.instructionsFromMethod
55
import scala.tools.asm
66
import scala.tools.asm.util._
77
import scala.collection.JavaConverters._

test/files/run/t9403/Test_2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import p.C
22
import scala.tools.asm.Opcodes
33
import scala.tools.partest.BytecodeTest
4-
import scala.tools.testing.ASMConverters._
4+
import scala.tools.testkit.ASMConverters._
55

66

77
object Test extends BytecodeTest {

test/junit/scala/OptionTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package scala
33
import org.junit.Assert._
44
import org.junit.Test
55

6-
import scala.tools.testing.RunTesting
6+
import scala.tools.testkit.RunTesting
77

88
class OptionTest extends RunTesting {
99
@Test def testSomeZipSome: Unit = assertEquals(Some("foo") zip Some("bar"), Some(("foo", "bar")))

test/junit/scala/StringTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package scala
22

33
import scala.tools.reflect.ToolBoxError
4-
import scala.tools.testing.RunTesting
4+
import scala.tools.testkit.RunTesting
55

66
import org.junit.Test
77
import org.junit.runner.RunWith

test/junit/scala/collection/IterableTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.junit.runners.JUnit4
66

77
import scala.collection.immutable.{ArraySeq, List, Range, Vector}
88
import scala.language.higherKinds
9-
import scala.tools.testing.AssertUtil._
9+
import scala.tools.testkit.AssertUtil._
1010
import org.junit.Assert.assertEquals
1111

1212
@RunWith(classOf[JUnit4])

test/junit/scala/collection/IteratorTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.junit.Test
66
import org.junit.runner.RunWith
77
import org.junit.runners.JUnit4
88

9-
import scala.tools.testing.AssertUtil._
9+
import scala.tools.testkit.AssertUtil._
1010

1111
import Seq.empty
1212

test/junit/scala/collection/SetMapConsistencyTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class SetMapConsistencyTest {
535535

536536
@Test
537537
def test_SI8727(): Unit = {
538-
import scala.tools.testing.AssertUtil._
538+
import scala.tools.testkit.AssertUtil._
539539
type NSEE = NoSuchElementException
540540
val map = Map(0 -> "zero", 1 -> "one")
541541
val m = map.view.filterKeys(i => if (map contains i) true else throw new NSEE).toMap

test/junit/scala/collection/StringOpsTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.junit.Test
44
import org.junit.runner.RunWith
55
import org.junit.runners.JUnit4
66
import org.junit.Assert.assertEquals
7-
import scala.tools.testing.AssertUtil.assertThrows
7+
import scala.tools.testkit.AssertUtil.assertThrows
88

99

1010
@RunWith(classOf[JUnit4])

test/junit/scala/collection/StringParsersTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.junit.{Assert, Test}
44
import org.junit.Assert._
55
import org.junit.runner.RunWith
66
import org.junit.runners.JUnit4
7-
import scala.tools.testing.AssertUtil._
7+
import scala.tools.testkit.AssertUtil._
88
import scala.util.Try
99

1010
@RunWith(classOf[JUnit4])

test/junit/scala/collection/concurrent/TrieMapTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.junit.Test
44
import org.junit.Assert.assertEquals
55

66
import scala.util.hashing.Hashing
7-
import scala.tools.testing.AssertUtil.assertThrows
7+
import scala.tools.testkit.AssertUtil.assertThrows
88

99
class TrieMapTest {
1010

test/junit/scala/collection/immutable/HashSetTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.junit.Assert.{assertEquals, assertSame}
44
import org.junit.Test
55
import org.junit.runner.RunWith
66
import org.junit.runners.JUnit4
7-
import scala.tools.testing.AssertUtil._
7+
import scala.tools.testkit.AssertUtil._
88

99
@RunWith(classOf[JUnit4])
1010
class HashSetTest {

test/junit/scala/collection/immutable/IndexedSeqTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import Assert._
55

66
import scala.collection.Seq.empty
77
import scala.language.postfixOps
8-
import scala.tools.testing.AssertUtil._
9-
import scala.util.AllocationTest
8+
import scala.tools.testkit.AssertUtil._
9+
import scala.tools.testkit.AllocationTest
1010

1111
class IndexedSeqTest extends AllocationTest {
1212

test/junit/scala/collection/immutable/LazyListTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.junit.Assert._
88

99
import scala.collection.mutable.{Builder, ListBuffer}
1010
import scala.ref.WeakReference
11-
import scala.tools.testing.AssertUtil
11+
import scala.tools.testkit.AssertUtil
1212
import scala.util.Try
1313

1414
@RunWith(classOf[JUnit4])

test/junit/scala/collection/immutable/RangeTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package scala.collection.immutable
33
import org.junit.{Assert, Test}
44
import org.junit.runner.RunWith
55
import org.junit.runners.JUnit4
6-
import scala.tools.testing.AssertUtil
6+
import scala.tools.testkit.AssertUtil
77

88
@RunWith(classOf[JUnit4])
99
class RangeTest {

test/junit/scala/collection/immutable/StringLikeTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.junit.Test
55
import org.junit.runner.RunWith
66
import org.junit.runners.JUnit4
77

8-
import scala.tools.testing.AssertUtil._
8+
import scala.tools.testkit.AssertUtil._
99
import scala.util.Random
1010

1111
/* Test for scala/bug#8988 */

test/junit/scala/collection/mutable/ArrayBufferTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import org.junit.Test
66
import org.junit.Assert.assertEquals
77

88

9-
import scala.tools.testing.AssertUtil
10-
import scala.tools.testing.AssertUtil.assertThrows
9+
import scala.tools.testkit.AssertUtil
10+
import scala.tools.testkit.AssertUtil.assertThrows
1111

1212
/* Test for scala/bug#9043 */
1313
@RunWith(classOf[JUnit4])

test/junit/scala/collection/mutable/BitSetTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.junit.runner.RunWith
55
import org.junit.runners.JUnit4
66
import org.junit.Assert._
77

8-
import scala.tools.testing.AssertUtil._
8+
import scala.tools.testkit.AssertUtil._
99

1010
@RunWith(classOf[JUnit4])
1111
class BitSetTest {

test/junit/scala/collection/mutable/PriorityQueueTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import org.junit.Test
77
import scala.collection.mutable
88
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, ObjectOutputStream}
99

10-
import scala.tools.testing.AssertUtil.assertThrows
10+
import scala.tools.testkit.AssertUtil.assertThrows
1111

1212
@RunWith(classOf[JUnit4])
1313
/* Test for scala/bug#7568 */

test/junit/scala/collection/mutable/StringBuilderTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.junit.runner.RunWith
55
import org.junit.runners.JUnit4
66
import org.junit.Test
77

8-
import scala.tools.testing.AssertUtil
8+
import scala.tools.testkit.AssertUtil
99

1010
@RunWith(classOf[JUnit4])
1111
class StringBuilderTest {

test/junit/scala/concurrent/FutureTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.junit.Test
66
import org.junit.runner.RunWith
77
import org.junit.runners.JUnit4
88

9-
import scala.tools.testing.AssertUtil._
9+
import scala.tools.testkit.AssertUtil._
1010
import scala.util.Try
1111

1212
import java.util.concurrent.CountDownLatch

test/junit/scala/io/SourceTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.junit.Assert._
66
import org.junit.runner.RunWith
77
import org.junit.runners.JUnit4
88

9-
import scala.tools.testing.AssertUtil._
9+
import scala.tools.testkit.AssertUtil._
1010

1111
import java.io.{ Console => _, _ }
1212

0 commit comments

Comments
 (0)