Skip to content

Fix #3664: Run test in CI instead of testAll #3665

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

Merged
merged 3 commits into from
Dec 18, 2017
Merged
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
6 changes: 3 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ pipeline:
image: lampepfl/dotty:2017-11-17
commands:
- cp -R . /tmp/1/ && cd /tmp/1/
- ./project/scripts/sbt ";compile ;testAll"
- ./project/scripts/sbt ";compile ;test"
- ./project/scripts/sbtTests

test_bootstrapped:
group: test
image: lampepfl/dotty:2017-11-17
commands:
- cp -R . /tmp/2/ && cd /tmp/2/
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/testAll"
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test"
- ./project/scripts/sbtBootstrappedTests

test_optimised:
group: test
image: lampepfl/dotty:2017-11-17
commands:
- cp -R . /tmp/3/ && cd /tmp/3/
- ./project/scripts/sbt dotty-optimised/testAll
- ./project/scripts/sbt dotty-optimised/test

test_sbt:
group: test
Expand Down
6 changes: 5 additions & 1 deletion library/src/dotty/Show.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object Show extends LowPrioShow {
* any `T`, we default to `T#toString`.
*/
implicit class ShowValue[V](val v: V) extends AnyVal {
def show(implicit ev: Show[V] = defaultShow): String =
def show(implicit ev: Show[V]): String =
ev.show(v)
}

Expand Down Expand Up @@ -71,6 +71,10 @@ object Show extends LowPrioShow {
}
}

implicit def showSome[T](implicit st: Show[T]): Show[Some[T]] = new Show[Some[T]] {
def show(ot: Some[T]): String = "Some("+ st.show(ot.get) + ")"
}

implicit def showMap[K,V](implicit sk: Show[K], sv: Show[V]): Show[Map[K,V]] = new Show[Map[K,V]] {
def show(m: Map[K, V]) =
"Map(" + m.map { case (k, v) => sk.show(k) + " -> " + sv.show(v) } .mkString (", ") + ")"
Expand Down
3 changes: 1 addition & 2 deletions library/test/dotty/ShowTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ class ShowTests {

@Test def withoutShow = {
case class Car(model: String, manufacturer: String, year: Int)

assertEquals("Car(Mustang,Ford,1967)", Car("Mustang", "Ford", 1967).show)
assertEquals("Map()", Map[Nothing, Nothing]().show)
assertEquals("List()", List().show)
}

@Test def partialShow = {
case object Foo

assertEquals("Map(Foo -> \"Hello\")", Map(Foo -> "Hello").show)
}
}
176 changes: 80 additions & 96 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,11 @@ object Build {
lazy val packageAll =
taskKey[Map[String, String]]("Package everything needed to run tests")

// Spawns a repl with the correct classpath
lazy val repl = inputKey[Unit]("run the REPL with correct classpath")

// Run tests with filter through vulpix test suite
lazy val vulpix = inputKey[Unit]("runs integration test with the supplied filter")
lazy val testCompilation = inputKey[Unit]("runs integration test with the supplied filter")

// Run all tests including tests marked with SlowTests
lazy val testAll = inputKey[Unit]("runs all tests including SlowTests")
// Spawns a repl with the correct classpath
lazy val repl = inputKey[Unit]("run the REPL with correct classpath")

// Used to compile files similar to ./bin/dotc script
lazy val dotc =
Expand Down Expand Up @@ -124,7 +121,11 @@ object Build {
// Override `runCode` from sbt-dotty to use the language-server and
// vscode extension from the source repository of dotty instead of a
// published version.
runCode := (run in `dotty-language-server`).toTask("").value
runCode := (run in `dotty-language-server`).toTask("").value,

// include sources in eclipse (downloads source code for all dependencies)
//http://stackoverflow.com/questions/10472840/how-to-attach-sources-to-sbt-managed-dependencies-in-scala-ide#answer-11683728
EclipseKeys.withSource := true
)

// Settings shared globally (scoped in Global). Used in build.sbt
Expand Down Expand Up @@ -180,7 +181,12 @@ object Build {
resourceDirectory in Test := baseDirectory.value / "test-resources",

// Prevent sbt from rewriting our dependencies
ivyScala ~= (_ map (_ copy (overrideScalaVersion = false)))
ivyScala ~= (_ map (_ copy (overrideScalaVersion = false))),

libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test,

// enable verbose exception messages for JUnit
testOptions in Test += Tests.Argument(TestFrameworks.JUnit, "-a", "-v")
)

// Settings used for projects compiled only with Scala 2
Expand Down Expand Up @@ -345,9 +351,6 @@ object Build {
connectInput in run := true,
outputStrategy := Some(StdoutOutput),

// enable verbose exception messages for JUnit
testOptions in Test += Tests.Argument(TestFrameworks.JUnit, "-a", "-v"),

javaOptions ++= (javaOptions in `dotty-compiler`).value,
fork in run := true,
fork in Test := true,
Expand Down Expand Up @@ -387,7 +390,6 @@ object Build {
}.evaluated,

libraryDependencies ++= Seq(
"com.novocode" % "junit-interface" % "0.11" % "test",
"com.vladsch.flexmark" % "flexmark" % "0.11.1",
"com.vladsch.flexmark" % "flexmark-ext-gfm-tasklist" % "0.11.1",
"com.vladsch.flexmark" % "flexmark-ext-gfm-tables" % "0.11.1",
Expand Down Expand Up @@ -455,9 +457,6 @@ object Build {
pairs.map(_._2)
}.taskValue,

// Used by the backend
libraryDependencies += "org.scala-lang.modules" % "scala-asm" % "6.0.0-scala-1",

// set system in/out for repl
connectInput in run := true,
outputStrategy := Some(StdoutOutput),
Expand All @@ -483,18 +482,13 @@ object Build {
Seq(file)
}.taskValue,

// include sources in eclipse (downloads source code for all dependencies)
//http://stackoverflow.com/questions/10472840/how-to-attach-sources-to-sbt-managed-dependencies-in-scala-ide#answer-11683728
com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys.withSource := true,

// get libraries onboard
libraryDependencies ++= Seq("com.typesafe.sbt" % "sbt-interface" % sbtVersion.value,
("org.scala-lang.modules" %% "scala-xml" % "1.0.6").withDottyCompat(),
"com.novocode" % "junit-interface" % "0.11" % "test",
"org.scala-lang" % "scala-library" % scalacVersion % "test"),

// enable improved incremental compilation algorithm
incOptions := incOptions.value.withNameHashing(true),
libraryDependencies ++= Seq(
"org.scala-lang.modules" % "scala-asm" % "6.0.0-scala-1", // used by the backend
"com.typesafe.sbt" % "sbt-interface" % sbtVersion.value,
("org.scala-lang.modules" %% "scala-xml" % "1.0.6").withDottyCompat(),
"org.scala-lang" % "scala-library" % scalacVersion % "test"
),

// For convenience, change the baseDirectory when running the compiler
baseDirectory in (Compile, run) := baseDirectory.value / "..",
Expand All @@ -503,15 +497,66 @@ object Build {

test in Test := {
// Exclude legacy tests by default
(testOnly in Test).toTask(" -- --exclude-categories=dotty.LegacyTests,dotty.SlowTests").value
(testOnly in Test).toTask(" -- --exclude-categories=dotty.LegacyTests").value
},

testAll in Test := {
// Exclude legacy tests by default
(testOnly in Test).toTask(" -- --exclude-categories=dotty.LegacyTests").value
testOptions in Test += Tests.Argument(
TestFrameworks.JUnit, "--run-listener=dotty.tools.ContextEscapeDetector"
),

// Spawn new JVM in run and test
fork in run := true,
fork in Test := true,
parallelExecution in Test := false,

// Add git-hash used to package the distribution to the manifest to know it in runtime and report it in REPL
packageOptions += ManifestAttributes(("Git-Hash", VersionUtil.gitHash)),

// http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala
// packageAll should always be run before tests
javaOptions ++= {
val attList = (dependencyClasspath in Runtime).value
val pA = packageAll.value

// put needed dependencies on classpath:
val path = for {
file <- attList.map(_.data)
path = file.getAbsolutePath
// FIXME: when we snip the cord, this should go bye-bye
if path.contains("scala-library") ||
// FIXME: currently needed for tests referencing scalac internals
path.contains("scala-reflect") ||
// FIXME: should go away when xml literal parsing is removed
path.contains("scala-xml") ||
// used for tests that compile dotty
path.contains("scala-asm") ||
// needed for the xsbti interface
path.contains("sbt-interface")
} yield "-Xbootclasspath/p:" + path

val ci_build = // propagate if this is a ci build
if (sys.props.isDefinedAt(JENKINS_BUILD))
List(s"-D$JENKINS_BUILD=${sys.props(JENKINS_BUILD)}") ::: jenkinsMemLimit
else if (sys.props.isDefinedAt(DRONE_MEM))
List("-Xmx" + sys.props(DRONE_MEM))
else List()

val tuning =
if (sys.props.isDefinedAt("Oshort"))
// Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
List("-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1")
else List()

val jars = List(
"-Ddotty.tests.classes.interfaces=" + pA("dotty-interfaces"),
"-Ddotty.tests.classes.library=" + pA("dotty-library"),
"-Ddotty.tests.classes.compiler=" + pA("dotty-compiler")
)

jars ::: tuning ::: agentOptions ::: ci_build ::: path.toList
},

vulpix := Def.inputTaskDyn {
testCompilation := Def.inputTaskDyn {
val args: Seq[String] = spaceDelimited("<arg>").parsed
val cmd = " dotty.tools.dotc.CompilationTests -- --exclude-categories=dotty.SlowTests" + {
if (args.nonEmpty) " -Ddotty.tests.filter=" + args.mkString(" ")
Expand Down Expand Up @@ -545,13 +590,7 @@ object Build {
},
run := dotc.evaluated,
dotc := runCompilerMain().evaluated,
repl := runCompilerMain(repl = true).evaluated,

// enable verbose exception messages for JUnit
testOptions in Test += Tests.Argument(
TestFrameworks.JUnit, "-a", "-v",
"--run-listener=dotty.tools.ContextEscapeDetector"
),
repl := runCompilerMain(repl = true).evaluated

/* Add the sources of scalajs-ir.
* To guarantee that dotty can bootstrap without depending on a version
Expand Down Expand Up @@ -584,59 +623,7 @@ object Build {
// IO.unzip(scalaJSIRSourcesJar, trgDir)
// (trgDir ** "*.scala").get.toSet
// } (Set(scalaJSIRSourcesJar)).toSeq
//}.taskValue,

// Spawn new JVM in run and test
fork in run := true,
fork in Test := true,
parallelExecution in Test := false,

// Add git-hash used to package the distribution to the manifest to know it in runtime and report it in REPL
packageOptions += ManifestAttributes(("Git-Hash", VersionUtil.gitHash)),

// http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala
// packageAll should always be run before tests
javaOptions ++= {
val attList = (dependencyClasspath in Runtime).value
val pA = packageAll.value

// put needed dependencies on classpath:
val path = for {
file <- attList.map(_.data)
path = file.getAbsolutePath
// FIXME: when we snip the cord, this should go bye-bye
if path.contains("scala-library") ||
// FIXME: currently needed for tests referencing scalac internals
path.contains("scala-reflect") ||
// FIXME: should go away when xml literal parsing is removed
path.contains("scala-xml") ||
// used for tests that compile dotty
path.contains("scala-asm") ||
// needed for the xsbti interface
path.contains("sbt-interface")
} yield "-Xbootclasspath/p:" + path

val ci_build = // propagate if this is a ci build
if (sys.props.isDefinedAt(JENKINS_BUILD))
List(s"-D$JENKINS_BUILD=${sys.props(JENKINS_BUILD)}") ::: jenkinsMemLimit
else if (sys.props.isDefinedAt(DRONE_MEM))
List("-Xmx" + sys.props(DRONE_MEM))
else List()

val tuning =
if (sys.props.isDefinedAt("Oshort"))
// Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
List("-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1")
else List()

val jars = List(
"-Ddotty.tests.classes.interfaces=" + pA("dotty-interfaces"),
"-Ddotty.tests.classes.library=" + pA("dotty-library"),
"-Ddotty.tests.classes.compiler=" + pA("dotty-compiler")
)

jars ::: tuning ::: agentOptions ::: ci_build ::: path.toList
}
//}.taskValue
)

def runCompilerMain(repl: Boolean = false) = Def.inputTaskDyn {
Expand Down Expand Up @@ -678,7 +665,7 @@ object Build {
"dotty-compiler" -> (packageBin in Compile).value,
"dotty-library" -> (packageBin in (`dotty-library`, Compile)).value,
"dotty-compiler-test" -> (packageBin in Test).value
) map { case (k, v) => (k, v.getAbsolutePath) }
).mapValues(_.getAbsolutePath)
}
)

Expand Down Expand Up @@ -706,10 +693,7 @@ object Build {

// Settings shared between dotty-library and dotty-library-bootstrapped
lazy val dottyLibrarySettings = Seq(
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-library" % scalacVersion,
"com.novocode" % "junit-interface" % "0.11" % "test"
)
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion
)

lazy val `dotty-library` = project.in(file("library")).asDottyLibrary(NonBootstrapped)
Expand Down