Skip to content

Commit 32b02dc

Browse files
committed
Fix #3664: Make testAll part of commonSettings
`testAll` is used to run the tests in the CI. However it was defined in `commonDottyCompilerSettings` and therefore not defined for all the projects. This commit also, clean the sbt build
1 parent 9de3905 commit 32b02dc

File tree

1 file changed

+87
-92
lines changed

1 file changed

+87
-92
lines changed

project/Build.scala

Lines changed: 87 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,17 @@ object Build {
121121
// Change this to true if you want to bootstrap using a published non-bootstrapped compiler
122122
bootstrapFromPublishedJars := false,
123123

124+
// enable improved incremental compilation algorithm
125+
incOptions := incOptions.value.withNameHashing(true),
126+
124127
// Override `runCode` from sbt-dotty to use the language-server and
125128
// vscode extension from the source repository of dotty instead of a
126129
// published version.
127-
runCode := (run in `dotty-language-server`).toTask("").value
130+
runCode := (run in `dotty-language-server`).toTask("").value,
131+
132+
// include sources in eclipse (downloads source code for all dependencies)
133+
//http://stackoverflow.com/questions/10472840/how-to-attach-sources-to-sbt-managed-dependencies-in-scala-ide#answer-11683728
134+
EclipseKeys.withSource := true
128135
)
129136

130137
// Settings shared globally (scoped in Global). Used in build.sbt
@@ -180,7 +187,22 @@ object Build {
180187
resourceDirectory in Test := baseDirectory.value / "test-resources",
181188

182189
// Prevent sbt from rewriting our dependencies
183-
ivyScala ~= (_ map (_ copy (overrideScalaVersion = false)))
190+
ivyScala ~= (_ map (_ copy (overrideScalaVersion = false))),
191+
192+
test in Test := {
193+
// Exclude legacy tests by default
194+
(testOnly in Test).toTask(" -- --exclude-categories=dotty.LegacyTests,dotty.SlowTests").value
195+
},
196+
197+
testAll in Test := {
198+
// Exclude legacy tests by default
199+
(testOnly in Test).toTask(" -- --exclude-categories=dotty.LegacyTests").value
200+
},
201+
202+
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test,
203+
204+
// enable verbose exception messages for JUnit
205+
testOptions in Test += Tests.Argument(TestFrameworks.JUnit, "-a", "-v")
184206
)
185207

186208
// Settings used for projects compiled only with Scala 2
@@ -345,9 +367,6 @@ object Build {
345367
connectInput in run := true,
346368
outputStrategy := Some(StdoutOutput),
347369

348-
// enable verbose exception messages for JUnit
349-
testOptions in Test += Tests.Argument(TestFrameworks.JUnit, "-a", "-v"),
350-
351370
javaOptions ++= (javaOptions in `dotty-compiler`).value,
352371
fork in run := true,
353372
fork in Test := true,
@@ -387,7 +406,6 @@ object Build {
387406
}.evaluated,
388407

389408
libraryDependencies ++= Seq(
390-
"com.novocode" % "junit-interface" % "0.11" % "test",
391409
"com.vladsch.flexmark" % "flexmark" % "0.11.1",
392410
"com.vladsch.flexmark" % "flexmark-ext-gfm-tasklist" % "0.11.1",
393411
"com.vladsch.flexmark" % "flexmark-ext-gfm-tables" % "0.11.1",
@@ -455,9 +473,6 @@ object Build {
455473
pairs.map(_._2)
456474
}.taskValue,
457475

458-
// Used by the backend
459-
libraryDependencies += "org.scala-lang.modules" % "scala-asm" % "6.0.0-scala-1",
460-
461476
// set system in/out for repl
462477
connectInput in run := true,
463478
outputStrategy := Some(StdoutOutput),
@@ -483,32 +498,73 @@ object Build {
483498
Seq(file)
484499
}.taskValue,
485500

486-
// include sources in eclipse (downloads source code for all dependencies)
487-
//http://stackoverflow.com/questions/10472840/how-to-attach-sources-to-sbt-managed-dependencies-in-scala-ide#answer-11683728
488-
com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys.withSource := true,
489-
490501
// get libraries onboard
491-
libraryDependencies ++= Seq("com.typesafe.sbt" % "sbt-interface" % sbtVersion.value,
492-
("org.scala-lang.modules" %% "scala-xml" % "1.0.6").withDottyCompat(),
493-
"com.novocode" % "junit-interface" % "0.11" % "test",
494-
"org.scala-lang" % "scala-library" % scalacVersion % "test"),
495-
496-
// enable improved incremental compilation algorithm
497-
incOptions := incOptions.value.withNameHashing(true),
502+
libraryDependencies ++= Seq(
503+
"org.scala-lang.modules" % "scala-asm" % "6.0.0-scala-1", // used by the backend
504+
"com.typesafe.sbt" % "sbt-interface" % sbtVersion.value,
505+
("org.scala-lang.modules" %% "scala-xml" % "1.0.6").withDottyCompat(),
506+
"org.scala-lang" % "scala-library" % scalacVersion % "test"
507+
),
498508

499509
// For convenience, change the baseDirectory when running the compiler
500510
baseDirectory in (Compile, run) := baseDirectory.value / "..",
501511
// .. but not when running test
502512
baseDirectory in (Test, run) := baseDirectory.value,
503513

504-
test in Test := {
505-
// Exclude legacy tests by default
506-
(testOnly in Test).toTask(" -- --exclude-categories=dotty.LegacyTests,dotty.SlowTests").value
507-
},
514+
testOptions in Test += Tests.Argument(
515+
TestFrameworks.JUnit, "--run-listener=dotty.tools.ContextEscapeDetector"
516+
),
517+
518+
// Spawn new JVM in run and test
519+
fork in run := true,
520+
fork in Test := true,
521+
parallelExecution in Test := false,
522+
523+
// Add git-hash used to package the distribution to the manifest to know it in runtime and report it in REPL
524+
packageOptions += ManifestAttributes(("Git-Hash", VersionUtil.gitHash)),
525+
526+
// http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala
527+
// packageAll should always be run before tests
528+
javaOptions ++= {
529+
val attList = (dependencyClasspath in Runtime).value
530+
val pA = packageAll.value
531+
532+
// put needed dependencies on classpath:
533+
val path = for {
534+
file <- attList.map(_.data)
535+
path = file.getAbsolutePath
536+
// FIXME: when we snip the cord, this should go bye-bye
537+
if path.contains("scala-library") ||
538+
// FIXME: currently needed for tests referencing scalac internals
539+
path.contains("scala-reflect") ||
540+
// FIXME: should go away when xml literal parsing is removed
541+
path.contains("scala-xml") ||
542+
// used for tests that compile dotty
543+
path.contains("scala-asm") ||
544+
// needed for the xsbti interface
545+
path.contains("sbt-interface")
546+
} yield "-Xbootclasspath/p:" + path
547+
548+
val ci_build = // propagate if this is a ci build
549+
if (sys.props.isDefinedAt(JENKINS_BUILD))
550+
List(s"-D$JENKINS_BUILD=${sys.props(JENKINS_BUILD)}") ::: jenkinsMemLimit
551+
else if (sys.props.isDefinedAt(DRONE_MEM))
552+
List("-Xmx" + sys.props(DRONE_MEM))
553+
else List()
554+
555+
val tuning =
556+
if (sys.props.isDefinedAt("Oshort"))
557+
// Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
558+
List("-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1")
559+
else List()
560+
561+
val jars = List(
562+
"-Ddotty.tests.classes.interfaces=" + pA("dotty-interfaces"),
563+
"-Ddotty.tests.classes.library=" + pA("dotty-library"),
564+
"-Ddotty.tests.classes.compiler=" + pA("dotty-compiler")
565+
)
508566

509-
testAll in Test := {
510-
// Exclude legacy tests by default
511-
(testOnly in Test).toTask(" -- --exclude-categories=dotty.LegacyTests").value
567+
jars ::: tuning ::: agentOptions ::: ci_build ::: path.toList
512568
},
513569

514570
vulpix := Def.inputTaskDyn {
@@ -545,13 +601,7 @@ object Build {
545601
},
546602
run := dotc.evaluated,
547603
dotc := runCompilerMain().evaluated,
548-
repl := runCompilerMain(repl = true).evaluated,
549-
550-
// enable verbose exception messages for JUnit
551-
testOptions in Test += Tests.Argument(
552-
TestFrameworks.JUnit, "-a", "-v",
553-
"--run-listener=dotty.tools.ContextEscapeDetector"
554-
),
604+
repl := runCompilerMain(repl = true).evaluated
555605

556606
/* Add the sources of scalajs-ir.
557607
* To guarantee that dotty can bootstrap without depending on a version
@@ -584,59 +634,7 @@ object Build {
584634
// IO.unzip(scalaJSIRSourcesJar, trgDir)
585635
// (trgDir ** "*.scala").get.toSet
586636
// } (Set(scalaJSIRSourcesJar)).toSeq
587-
//}.taskValue,
588-
589-
// Spawn new JVM in run and test
590-
fork in run := true,
591-
fork in Test := true,
592-
parallelExecution in Test := false,
593-
594-
// Add git-hash used to package the distribution to the manifest to know it in runtime and report it in REPL
595-
packageOptions += ManifestAttributes(("Git-Hash", VersionUtil.gitHash)),
596-
597-
// http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala
598-
// packageAll should always be run before tests
599-
javaOptions ++= {
600-
val attList = (dependencyClasspath in Runtime).value
601-
val pA = packageAll.value
602-
603-
// put needed dependencies on classpath:
604-
val path = for {
605-
file <- attList.map(_.data)
606-
path = file.getAbsolutePath
607-
// FIXME: when we snip the cord, this should go bye-bye
608-
if path.contains("scala-library") ||
609-
// FIXME: currently needed for tests referencing scalac internals
610-
path.contains("scala-reflect") ||
611-
// FIXME: should go away when xml literal parsing is removed
612-
path.contains("scala-xml") ||
613-
// used for tests that compile dotty
614-
path.contains("scala-asm") ||
615-
// needed for the xsbti interface
616-
path.contains("sbt-interface")
617-
} yield "-Xbootclasspath/p:" + path
618-
619-
val ci_build = // propagate if this is a ci build
620-
if (sys.props.isDefinedAt(JENKINS_BUILD))
621-
List(s"-D$JENKINS_BUILD=${sys.props(JENKINS_BUILD)}") ::: jenkinsMemLimit
622-
else if (sys.props.isDefinedAt(DRONE_MEM))
623-
List("-Xmx" + sys.props(DRONE_MEM))
624-
else List()
625-
626-
val tuning =
627-
if (sys.props.isDefinedAt("Oshort"))
628-
// Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
629-
List("-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1")
630-
else List()
631-
632-
val jars = List(
633-
"-Ddotty.tests.classes.interfaces=" + pA("dotty-interfaces"),
634-
"-Ddotty.tests.classes.library=" + pA("dotty-library"),
635-
"-Ddotty.tests.classes.compiler=" + pA("dotty-compiler")
636-
)
637-
638-
jars ::: tuning ::: agentOptions ::: ci_build ::: path.toList
639-
}
637+
//}.taskValue
640638
)
641639

642640
def runCompilerMain(repl: Boolean = false) = Def.inputTaskDyn {
@@ -678,7 +676,7 @@ object Build {
678676
"dotty-compiler" -> (packageBin in Compile).value,
679677
"dotty-library" -> (packageBin in (`dotty-library`, Compile)).value,
680678
"dotty-compiler-test" -> (packageBin in Test).value
681-
) map { case (k, v) => (k, v.getAbsolutePath) }
679+
).mapValues(_.getAbsolutePath)
682680
}
683681
)
684682

@@ -706,10 +704,7 @@ object Build {
706704

707705
// Settings shared between dotty-library and dotty-library-bootstrapped
708706
lazy val dottyLibrarySettings = Seq(
709-
libraryDependencies ++= Seq(
710-
"org.scala-lang" % "scala-library" % scalacVersion,
711-
"com.novocode" % "junit-interface" % "0.11" % "test"
712-
)
707+
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion
713708
)
714709

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

0 commit comments

Comments
 (0)