diff --git a/.drone.yml b/.drone.yml index 1e21a57d5b88..a31e0ee59bdf 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,7 +25,7 @@ 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: @@ -33,7 +33,7 @@ pipeline: 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: @@ -41,7 +41,7 @@ pipeline: 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 diff --git a/library/src/dotty/Show.scala b/library/src/dotty/Show.scala index 64bb39a0346a..0a1bfd89d8a0 100644 --- a/library/src/dotty/Show.scala +++ b/library/src/dotty/Show.scala @@ -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) } @@ -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 (", ") + ")" diff --git a/library/test/dotty/ShowTests.scala b/library/test/dotty/ShowTests.scala index 4ea7eb28faab..d114f62881a2 100644 --- a/library/test/dotty/ShowTests.scala +++ b/library/test/dotty/ShowTests.scala @@ -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) } } diff --git a/project/Build.scala b/project/Build.scala index 033f701d44d7..d7a2e8995f66 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -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 = @@ -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 @@ -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 @@ -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, @@ -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", @@ -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), @@ -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 / "..", @@ -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("").parsed val cmd = " dotty.tools.dotc.CompilationTests -- --exclude-categories=dotty.SlowTests" + { if (args.nonEmpty) " -Ddotty.tests.filter=" + args.mkString(" ") @@ -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 @@ -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 { @@ -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) } ) @@ -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)