From 2ef4d671d32e1be6621370874dd482087be5df25 Mon Sep 17 00:00:00 2001 From: Olivier Blanvillain Date: Tue, 5 Feb 2019 14:51:14 +0100 Subject: [PATCH 1/3] Remove collection-strawman submodule and tests --- .gitmodules | 4 ---- bench/scripts/collection-strawman-cold.sh | 2 -- bench/scripts/collection-strawman.sh | 2 -- collection-strawman | 1 - community-build/community-projects/ScalaPB | 1 + community-build/community-projects/algebra | 1 + community-build/community-projects/betterfiles | 1 + community-build/community-projects/fastparse | 1 + community-build/community-projects/minitest | 1 + community-build/community-projects/pdbp | 1 + community-build/community-projects/scalacheck | 1 + community-build/community-projects/scalap | 1 + community-build/community-projects/scalatest | 1 + community-build/community-projects/scopt | 1 + community-build/community-projects/sourcecode | 1 + community-build/community-projects/squants | 1 + community-build/community-projects/stdLib213 | 1 + community-build/dotty-bootstrapped.version | 1 + community-build/sbt-dotty.sbt | 1 + .../test/dotty/tools/dotc/CompilationTests.scala | 1 - .../test/dotty/tools/dotc/IdempotencyTests.scala | 12 ------------ project/Build.scala | 2 +- 22 files changed, 16 insertions(+), 23 deletions(-) delete mode 100755 bench/scripts/collection-strawman-cold.sh delete mode 100755 bench/scripts/collection-strawman.sh delete mode 160000 collection-strawman create mode 160000 community-build/community-projects/ScalaPB create mode 160000 community-build/community-projects/algebra create mode 160000 community-build/community-projects/betterfiles create mode 160000 community-build/community-projects/fastparse create mode 160000 community-build/community-projects/minitest create mode 160000 community-build/community-projects/pdbp create mode 160000 community-build/community-projects/scalacheck create mode 160000 community-build/community-projects/scalap create mode 160000 community-build/community-projects/scalatest create mode 160000 community-build/community-projects/scopt create mode 160000 community-build/community-projects/sourcecode create mode 160000 community-build/community-projects/squants create mode 160000 community-build/community-projects/stdLib213 create mode 100644 community-build/dotty-bootstrapped.version create mode 100644 community-build/sbt-dotty.sbt diff --git a/.gitmodules b/.gitmodules index fcc2a9370cbb..bc3566f36ba0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,3 @@ path = scala2-library url = https://github.com/lampepfl/scala.git branch = dotty-library2.12 -[submodule "collection-strawman"] - path = collection-strawman - url = https://github.com/dotty-staging/collection-strawman.git - branch = dotty diff --git a/bench/scripts/collection-strawman-cold.sh b/bench/scripts/collection-strawman-cold.sh deleted file mode 100755 index 0f96cb807cd1..000000000000 --- a/bench/scripts/collection-strawman-cold.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -find collection-strawman/collections/src/main/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench-bootstrapped/jmh:run 0 1 10" {} + | sbt diff --git a/bench/scripts/collection-strawman.sh b/bench/scripts/collection-strawman.sh deleted file mode 100755 index df33a8ce3598..000000000000 --- a/bench/scripts/collection-strawman.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -find collection-strawman/collections/src/main/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench-bootstrapped/jmh:run" {} + | sbt diff --git a/collection-strawman b/collection-strawman deleted file mode 160000 index 58fd6b002889..000000000000 --- a/collection-strawman +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 58fd6b002889d071e12223c403cdf8d82b43c298 diff --git a/community-build/community-projects/ScalaPB b/community-build/community-projects/ScalaPB new file mode 160000 index 000000000000..7b2d8ac0487d --- /dev/null +++ b/community-build/community-projects/ScalaPB @@ -0,0 +1 @@ +Subproject commit 7b2d8ac0487d52b076b751d6a590a879d71fc7c3 diff --git a/community-build/community-projects/algebra b/community-build/community-projects/algebra new file mode 160000 index 000000000000..812caf029214 --- /dev/null +++ b/community-build/community-projects/algebra @@ -0,0 +1 @@ +Subproject commit 812caf0292144ae0e3a00723e235b2563c351d7d diff --git a/community-build/community-projects/betterfiles b/community-build/community-projects/betterfiles new file mode 160000 index 000000000000..9f14d4727684 --- /dev/null +++ b/community-build/community-projects/betterfiles @@ -0,0 +1 @@ +Subproject commit 9f14d47276848997d97780987d0320509f8b368d diff --git a/community-build/community-projects/fastparse b/community-build/community-projects/fastparse new file mode 160000 index 000000000000..2a72cbec7d8c --- /dev/null +++ b/community-build/community-projects/fastparse @@ -0,0 +1 @@ +Subproject commit 2a72cbec7d8cad5da8cd2d22418a5551fc921a1f diff --git a/community-build/community-projects/minitest b/community-build/community-projects/minitest new file mode 160000 index 000000000000..d2b8b630ad44 --- /dev/null +++ b/community-build/community-projects/minitest @@ -0,0 +1 @@ +Subproject commit d2b8b630ad448300673dc97cbea01ce56ffaec38 diff --git a/community-build/community-projects/pdbp b/community-build/community-projects/pdbp new file mode 160000 index 000000000000..0c1fe0a5fd68 --- /dev/null +++ b/community-build/community-projects/pdbp @@ -0,0 +1 @@ +Subproject commit 0c1fe0a5fd681ff4d94a58dc6f73e019982e9d78 diff --git a/community-build/community-projects/scalacheck b/community-build/community-projects/scalacheck new file mode 160000 index 000000000000..6b3fe5165ccc --- /dev/null +++ b/community-build/community-projects/scalacheck @@ -0,0 +1 @@ +Subproject commit 6b3fe5165ccc46db460be051ef042d002a9b996a diff --git a/community-build/community-projects/scalap b/community-build/community-projects/scalap new file mode 160000 index 000000000000..b66556a551fe --- /dev/null +++ b/community-build/community-projects/scalap @@ -0,0 +1 @@ +Subproject commit b66556a551fe3cec24d0fea6841401d99557b1e0 diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest new file mode 160000 index 000000000000..cfc40267d9fb --- /dev/null +++ b/community-build/community-projects/scalatest @@ -0,0 +1 @@ +Subproject commit cfc40267d9fbc6bc501f73554c7aeb1abefea3cd diff --git a/community-build/community-projects/scopt b/community-build/community-projects/scopt new file mode 160000 index 000000000000..fedd604caa17 --- /dev/null +++ b/community-build/community-projects/scopt @@ -0,0 +1 @@ +Subproject commit fedd604caa175bd0791cb21179b700ca9fcf5698 diff --git a/community-build/community-projects/sourcecode b/community-build/community-projects/sourcecode new file mode 160000 index 000000000000..bed617b04c06 --- /dev/null +++ b/community-build/community-projects/sourcecode @@ -0,0 +1 @@ +Subproject commit bed617b04c066517fddd235c73f8b5db3bdc0950 diff --git a/community-build/community-projects/squants b/community-build/community-projects/squants new file mode 160000 index 000000000000..bfa61a92947b --- /dev/null +++ b/community-build/community-projects/squants @@ -0,0 +1 @@ +Subproject commit bfa61a92947b6ac1eab384fd5e46f2fbfe696c4a diff --git a/community-build/community-projects/stdLib213 b/community-build/community-projects/stdLib213 new file mode 160000 index 000000000000..655bca8ee5b8 --- /dev/null +++ b/community-build/community-projects/stdLib213 @@ -0,0 +1 @@ +Subproject commit 655bca8ee5b842e7ceba9709c307701cf36c10bf diff --git a/community-build/dotty-bootstrapped.version b/community-build/dotty-bootstrapped.version new file mode 100644 index 000000000000..ac36af3c02fb --- /dev/null +++ b/community-build/dotty-bootstrapped.version @@ -0,0 +1 @@ +0.13.0-bin-SNAPSHOT \ No newline at end of file diff --git a/community-build/sbt-dotty.sbt b/community-build/sbt-dotty.sbt new file mode 100644 index 000000000000..557a03e88d2f --- /dev/null +++ b/community-build/sbt-dotty.sbt @@ -0,0 +1 @@ +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.7-SNAPSHOT") \ No newline at end of file diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 59ad00ada53a..c8976dd7cd26 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -63,7 +63,6 @@ class CompilationTests extends ParallelTesting { ), scala2Mode ) + - compileDir("collection-strawman/collections/src/main", defaultOptions.and("-Yno-imports")) + compileFilesInDir("tests/pos-special/spec-t5545", defaultOptions) + compileFilesInDir("tests/pos-special/strawman-collections", defaultOptions) + compileFilesInDir("tests/pos-special/isInstanceOf", allowDeepSubtypes.and("-Xfatal-warnings")) + diff --git a/compiler/test/dotty/tools/dotc/IdempotencyTests.scala b/compiler/test/dotty/tools/dotc/IdempotencyTests.scala index e17045882f20..7a43700e7bce 100644 --- a/compiler/test/dotty/tools/dotc/IdempotencyTests.scala +++ b/compiler/test/dotty/tools/dotc/IdempotencyTests.scala @@ -32,9 +32,6 @@ class IdempotencyTests extends ParallelTesting { def sourcesFrom(dir: Path) = CompilationTests.sources(Files.walk(dir)) - val strawmanSources = sourcesFrom(Paths.get("collection-strawman/collections/src/main")) - val strawmanSourcesSorted = strawmanSources.sorted - val strawmanSourcesRevSorted = strawmanSourcesSorted.reverse val posIdempotency = { compileFilesInDir("tests/pos", opt)(TestGroup("idempotency/posIdempotency1")) + @@ -51,13 +48,6 @@ class IdempotencyTests extends ParallelTesting { }).reduce(_ + _) } - val strawmanIdempotency = { - compileList("strawman0", strawmanSources, opt) + - compileList("strawman1", strawmanSources, opt) + - compileList("strawman2", strawmanSourcesSorted, opt) + - compileList("strawman3", strawmanSourcesRevSorted, opt) - } - def check(name: String) = { val files = List(s"tests/idempotency/$name.scala", "tests/idempotency/IdempotencyCheck.scala") compileList(name, files, defaultOptions)(TestGroup("idempotency/check")) @@ -70,8 +60,6 @@ class IdempotencyTests extends ParallelTesting { } val allTests = { - // Disabled until strawman is fixed - // strawmanIdempotency + orderIdempotency + posIdempotency } diff --git a/project/Build.scala b/project/Build.scala index 7bbc21f1f01c..c9a39d6bbeae 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -162,7 +162,7 @@ object Build { } // Make sure all submodules are properly cloned - val submodules = List("scala-backend", "scala2-library", "collection-strawman") + val submodules = List("scala-backend", "scala2-library") if (!submodules.forall(exists)) { sLog.value.log(Level.Error, s"""Missing some of the submodules From 5bec02310aacda39168f1fb4291f7ed8534849f6 Mon Sep 17 00:00:00 2001 From: Olivier Blanvillain Date: Tue, 5 Feb 2019 14:53:34 +0100 Subject: [PATCH 2/3] Make all taskKeys non lazy --- project/Build.scala | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index c9a39d6bbeae..cfd4bbfdbf99 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -80,42 +80,38 @@ object Build { ) // Packages all subprojects to their jars - lazy val packageAll = - taskKey[Map[String, String]]("Package everything needed to run tests") + val packageAll = taskKey[Map[String, String]]("Package everything needed to run tests") // Run tests with filter through vulpix test suite - lazy val testCompilation = inputKey[Unit]("runs integration test with the supplied filter") + val testCompilation = inputKey[Unit]("runs integration test with the supplied filter") // Run TASTY tests with filter through vulpix test suite - lazy val testFromTasty = inputKey[Unit]("runs tasty integration test with the supplied filter") + val testFromTasty = inputKey[Unit]("runs tasty integration test with the supplied filter") // Spawns a repl with the correct classpath - lazy val repl = inputKey[Unit]("run the REPL with correct classpath") + val repl = inputKey[Unit]("run the REPL with correct classpath") // Used to compile files similar to ./bin/dotc script - lazy val dotc = - inputKey[Unit]("run the compiler using the correct classpath, or the user supplied classpath") + val dotc = inputKey[Unit]("run the compiler using the correct classpath, or the user supplied classpath") // Used to run binaries similar to ./bin/dotr script - lazy val dotr = - inputKey[Unit]("run compiled binary using the correct classpath, or the user supplied classpath") - + val dotr = inputKey[Unit]("run compiled binary using the correct classpath, or the user supplied classpath") // Compiles the documentation and static site - lazy val genDocs = taskKey[Unit]("run dottydoc to generate static documentation site") + val genDocs = taskKey[Unit]("run dottydoc to generate static documentation site") // Shorthand for compiling a docs site - lazy val dottydoc = inputKey[Unit]("run dottydoc") + val dottydoc = inputKey[Unit]("run dottydoc") - lazy val bootstrapFromPublishedJars = settingKey[Boolean]("If true, bootstrap dotty from published non-bootstrapped dotty") + val bootstrapFromPublishedJars = settingKey[Boolean]("If true, bootstrap dotty from published non-bootstrapped dotty") // Only available in vscode-dotty - lazy val unpublish = taskKey[Unit]("Unpublish a package") + val unpublish = taskKey[Unit]("Unpublish a package") // Settings used to configure the test language server - lazy val ideTestsCompilerVersion = taskKey[String]("Compiler version to use in IDE tests") - lazy val ideTestsCompilerArguments = taskKey[Seq[String]]("Compiler arguments to use in IDE tests") - lazy val ideTestsDependencyClasspath = taskKey[Seq[File]]("Dependency classpath to use in IDE tests") + val ideTestsCompilerVersion = taskKey[String]("Compiler version to use in IDE tests") + val ideTestsCompilerArguments = taskKey[Seq[String]]("Compiler arguments to use in IDE tests") + val ideTestsDependencyClasspath = taskKey[Seq[File]]("Dependency classpath to use in IDE tests") lazy val SourceDeps = config("sourcedeps") From 5967bffa283f4ff0d9e0c5d530901780e22f6a28 Mon Sep 17 00:00:00 2001 From: Olivier Blanvillain Date: Tue, 5 Feb 2019 15:06:49 +0100 Subject: [PATCH 3/3] Fix #5809: Run the community-build on every PR This commit is meant to replace the infrastructure previously setup in https://github.com/lampepfl/dotty-community-build. A new sbt project, community-build, is added to dotty's Build.scala and contains all the integration tests for the community build. In case of failure the tests will output instructions on how to reproduce the error without JUnit. Hopefully these instructions are sufficient to have everyone fix regressions as they are introduced, or as a very last resort, update the code for the community build. This should be the main improvement over the previous approach, where the community build maintenance was centralized (Allan did all the work) and asynchronous (it's now broken for more than a month...). Another improvement is that a published local version of the sbt plugin is used when running the integration test, so breakage to sbt-dotty should be caught earlier than before. --- .drone.yml | 22 ++- .gitignore | 2 + .gitmodules | 39 +++++ .vscode-template/settings.json | 1 + build.sbt | 1 + community-build/community-projects/squants | 2 +- community-build/project/build.properties | 1 + .../communitybuild/CommunityBuildTest.scala | 149 ++++++++++++++++++ .../test/scala/dotty/communitybuild/readme.md | 16 ++ project/Build.scala | 22 +++ 10 files changed, 247 insertions(+), 8 deletions(-) create mode 100644 community-build/project/build.properties create mode 100644 community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala create mode 100644 community-build/test/scala/dotty/communitybuild/readme.md diff --git a/.drone.yml b/.drone.yml index 1f9398844568..238b95831cf0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,7 +23,7 @@ pipeline: # We run tests in parallel. Tests run in a copy of the working directory to avoid conflict test: group: test - image: lampepfl/dotty:2018-12-12 + image: lampepfl/dotty:2019-02-06 commands: - cp -R . /tmp/1/ && cd /tmp/1/ - ./project/scripts/sbt ";compile ;test" @@ -31,15 +31,23 @@ pipeline: test_bootstrapped: group: test - image: lampepfl/dotty:2018-12-12 + image: lampepfl/dotty:2019-02-06 commands: - cp -R . /tmp/2/ && cd /tmp/2/ - ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test ;sjsSandbox/run" - ./project/scripts/bootstrapCmdTests + community_build: + group: test + image: lampepfl/dotty:2019-02-06 + commands: + - cp -R . /tmp/3/ && cd /tmp/3/ + - export PATH=/tmp/4/project/scripts:$PATH + - sbt community-build/test + test_sbt: group: test - image: lampepfl/dotty:2018-12-12 + image: lampepfl/dotty:2019-02-06 commands: - cp -R . /tmp/4/ && cd /tmp/4/ - ./project/scripts/sbt sbt-dotty/scripted @@ -49,7 +57,7 @@ pipeline: # DOCUMENTATION: documentation: - image: lampepfl/dotty:2018-12-12 + image: lampepfl/dotty:2019-02-06 commands: - ./project/scripts/genDocs secrets: [ bot_token ] @@ -61,7 +69,7 @@ pipeline: # PUBLISHING: # Publishing expect NIGHTLYBUILD or RELEASEBUILD to be set. See dottyVersion in Build.scala publish_nightly: - image: lampepfl/dotty:2018-12-12 + image: lampepfl/dotty:2019-02-06 environment: - NIGHTLYBUILD=yes commands: @@ -72,7 +80,7 @@ pipeline: environment: nightly publish_release: - image: lampepfl/dotty:2018-12-12 + image: lampepfl/dotty:2019-02-06 environment: - RELEASEBUILD=yes commands: @@ -96,7 +104,7 @@ pipeline: event: tag publish_sbt_release: - image: lampepfl/dotty:2018-12-12 + image: lampepfl/dotty:2019-02-06 environment: - RELEASEBUILD=yes commands: diff --git a/.gitignore b/.gitignore index 7b03166f12e5..234c7485c5d3 100644 --- a/.gitignore +++ b/.gitignore @@ -79,3 +79,5 @@ bench/compile.txt # The vscode app for testing vscode-dotty/.vscode-test +dotty-bootstrapped.version +sbt-dotty.sbt diff --git a/.gitmodules b/.gitmodules index bc3566f36ba0..006fb1a24f49 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,3 +6,42 @@ path = scala2-library url = https://github.com/lampepfl/scala.git branch = dotty-library2.12 +[submodule "community-build/community-projects/algebra"] + path = community-build/community-projects/algebra + url = https://github.com/dotty-staging/algebra +[submodule "community-build/community-projects/betterfiles"] + path = community-build/community-projects/betterfiles + url = https://github.com/dotty-staging/better-files +[submodule "community-build/community-projects/scalacheck"] + path = community-build/community-projects/scalacheck + url = https://github.com/dotty-staging/scalacheck +[submodule "community-build/community-projects/ScalaPB"] + path = community-build/community-projects/ScalaPB + url = https://github.com/dotty-staging/ScalaPB +[submodule "community-build/community-projects/scalatest"] + path = community-build/community-projects/scalatest + url = https://github.com/dotty-staging/scalatest +[submodule "community-build/community-projects/scopt"] + path = community-build/community-projects/scopt + url = https://github.com/dotty-staging/scopt +[submodule "community-build/community-projects/squants"] + path = community-build/community-projects/squants + url = https://github.com/dotty-staging/squants +[submodule "community-build/community-projects/scalap"] + path = community-build/community-projects/scalap + url = https://github.com/dotty-staging/scala +[submodule "community-build/community-projects/minitest"] + path = community-build/community-projects/minitest + url = https://github.com/dotty-staging/minitest +[submodule "community-build/community-projects/fastparse"] + path = community-build/community-projects/fastparse + url = https://github.com/dotty-staging/fastparse +[submodule "community-build/community-projects/stdLib213"] + path = community-build/community-projects/stdLib213 + url = https://github.com/dotty-staging/scala +[submodule "community-build/community-projects/pdbp"] + path = community-build/community-projects/pdbp + url = https://github.com/dotty-staging/pdbp +[submodule "community-build/community-projects/sourcecode"] + path = community-build/community-projects/sourcecode + url = https://github.com/dotty-staging/sourcecode diff --git a/.vscode-template/settings.json b/.vscode-template/settings.json index 725c6df5ca48..2181b29f33b5 100644 --- a/.vscode-template/settings.json +++ b/.vscode-template/settings.json @@ -9,6 +9,7 @@ "**/*.class": true, "**/*.hasTasty": true, "**/target/": true, + "community-build/community-projects": true, "scala2-library/{doc,docs,lib,META-INF,scripts,spec,test,tools}/": true, // only allow scala-backend/src "scala2-library/src/[abcefimprs]*": true, // only allow scala-backend/src/library "scala-backend/{doc,docs,lib,META-INF,scripts,spec,test,tools}/": true, // only allow scala-backend/src diff --git a/build.sbt b/build.sbt index ddb2d0273300..2afa25b44bbc 100644 --- a/build.sbt +++ b/build.sbt @@ -19,6 +19,7 @@ val `scala-reflect` = Build.`scala-reflect` val scalap = Build.scalap val dist = Build.dist val `dist-bootstrapped` = Build.`dist-bootstrapped` +val `community-build` = Build.`community-build` val sjsSandbox = Build.sjsSandbox diff --git a/community-build/community-projects/squants b/community-build/community-projects/squants index bfa61a92947b..9cccea9ee5f5 160000 --- a/community-build/community-projects/squants +++ b/community-build/community-projects/squants @@ -1 +1 @@ -Subproject commit bfa61a92947b6ac1eab384fd5e46f2fbfe696c4a +Subproject commit 9cccea9ee5f58217d0c6d12da4de4f6ff2b62566 diff --git a/community-build/project/build.properties b/community-build/project/build.properties new file mode 100644 index 000000000000..72f902892a13 --- /dev/null +++ b/community-build/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.2.7 diff --git a/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala b/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala new file mode 100644 index 000000000000..a702dbc73511 --- /dev/null +++ b/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala @@ -0,0 +1,149 @@ +package dotty.communitybuild + +import java.nio.file._ +import java.io.{PrintWriter, File} +import java.nio.charset.StandardCharsets.UTF_8 +import org.junit.{Ignore, Test} +import org.junit.Assert.{assertEquals, fail} + +class CommunityBuildTest { + lazy val communitybuildDir: Path = Paths.get(sys.props("user.dir") + "/community-build/") + + lazy val compilerVersion: String = { + val file = communitybuildDir.resolve("dotty-bootstrapped.version") + new String(Files.readAllBytes(file), UTF_8) + } + + /** Build the given project with the published local compiler and sbt plugin. + * + * This test reads the compiler version from community-build/dotty-bootstrapped.version + * and expects community-build/sbt-dotty.sbt to set the compiler plugin. + * + * @param project The project name, should be a git submodule in community-build/ + * @param command The sbt command used to build the project + */ + def test(project: String, command: String): Unit = { + def log(msg: String) = println(Console.GREEN + msg + Console.RESET) + + log(s"Building $project with dotty-bootstrapped $compilerVersion...") + + val projectDir = communitybuildDir.resolve("community-projects").resolve(project) + + if (!Files.exists(projectDir.resolve(".git"))) { + fail(s""" + | + |Missing $project submodule. You can initialize this module using + | + | git submodule update --init community-build/community-projects/$project + | + |""".stripMargin) + } + + /** Executes shell command, returns false in case of error. */ + def exec(binary: String, arguments: String*): Int = { + val command = binary +: arguments + log(command.mkString(" ")) + val builder = new ProcessBuilder(command: _*).directory(projectDir.toFile).inheritIO() + val process = builder.start() + val exitCode = process.waitFor() + exitCode + } + + // Workaround for https://github.com/sbt/sbt/issues/4395 + new File(sys.props("user.home") + "/.sbt/1.0/plugins").mkdirs() + val pluginFilePath = communitybuildDir.resolve("sbt-dotty.sbt").toAbsolutePath().toString() + + // Run the sbt command with the compiler version and sbt plugin set in the build + val arguments = Seq( + "-sbt-version", "1.2.7", + s"--addPluginSbtFile=$pluginFilePath", + s";clean ;set updateOptions in Global ~= (_.withLatestSnapshots(false)) ;++$compilerVersion! $command" + ) + + val exitCode = exec("sbt", arguments: _*) + + if (exitCode != 0) { + fail(s""" + | + |sbt exited with an error code. To reproduce without JUnit, use: + | + | sbt community-build/prepareCommunityBuild + | cd community-build/community-projects/$project + | sbt ${arguments.init.mkString(" ")} "${arguments.last}" + | + |For a faster feedback loop, one can try to extract a direct call to dotc from + |usign the sbt export command. For instance, for scalacheck, use + | sbt export jvm/test:compileIncremental + | + |""".stripMargin) + } + } + + @Test def algebra = test( + project = "algebra", + command = "coreJVM/compile" + ) + + @Test def scalacheck = test( + project = "scalacheck", + command = "jvm/test:compile" + ) + + @Test def scalatest = test( + project = "scalatest", + command = "scalatest/compile" + ) + + @Test def scopt = test( + project = "scopt", + command = "scoptJVM/compile" + ) + + @Test def scalap = test( + project = "scalap", + command = "scalap/compile" + ) + + @Test def squants = test( + project = "squants", + command = "squantsJVM/compile" + ) + + @Test def betterfiles = test( + project = "betterfiles", + command = "dottyCompile" + ) + + @Test def ScalaPB = test( + project = "ScalaPB", + command = "dottyCompile" + ) + + @Test def minitest = test( + project = "minitest", + command = "dottyCompile" + ) + + @Test def fastparse = test( + project = "fastparse", + command = "fastparseJVM/compile" + ) + + // TODO: revert to sourcecodeJVM/test + @Test def sourcecode = test( + project = "sourcecode", + command = "sourcecodeJVM/compile" + ) + + // TODO @smarter? + // @Test def stdLib213 = test( + // project = "stdLib213", + // command = "library/compile" + // ) + + // TODO @oderky? It got broken by #5458 + // @Test def pdbp = test( + // project = "pdbp", + // command = "compile" + // ) +} diff --git a/community-build/test/scala/dotty/communitybuild/readme.md b/community-build/test/scala/dotty/communitybuild/readme.md new file mode 100644 index 000000000000..a4337d048b5d --- /dev/null +++ b/community-build/test/scala/dotty/communitybuild/readme.md @@ -0,0 +1,16 @@ +# Dotty Community Build + +This project contains tests to build and test a corpus of open sources Scala projects against the latest version of Dotty. + +To run the community build on a local machine, first fetch all the git submodules with `git submodule update --init` and run `sbt community-build/test` from the root of the dotty repo. + +## Adding your project + +To add your project to the community build you can follow these steps: + +1. Get your project to compile with Dotty. Instructions can be found on the [dotty-example-project](https://github.com/lampepfl/dotty-example-project). + See the submodules in [community-projects](https://github.com/lampepfl/dotty/tree/master/community-build/community-projects/) for examples of projects that compile with Dotty. + +2. Open a PR against this repo that: + - Adds your project as a new git submodule + - Adds a test in [CommunityBuildTest.scala](https://github.com/lampepfl/dotty/blob/master/src/test/scala/dotty/community-build/src/test/scala/dotty/communitybuild/CommunityBuildTest.scala) diff --git a/project/Build.scala b/project/Build.scala index cfd4bbfdbf99..7e9de840b325 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1013,6 +1013,28 @@ object Build { }.dependsOn(compile in Compile).evaluated ) + val prepareCommunityBuild = taskKey[Unit]("Publish local the compiler and the sbt plugin. Also store the versions of the published local artefacts in two files, community-build/{dotty-bootstrapped.version,sbt-dotty.sbt}.") + + lazy val `community-build` = project.in(file("community-build")). + settings(commonNonBootstrappedSettings). + settings( + prepareCommunityBuild := { + (publishLocal in `dotty-sbt-bridge`).value + (publishLocal in `dotty-interfaces`).value + (publishLocal in `scala-library`).value + (publishLocal in `scala-reflect`).value + (publishLocal in `dotty-library-bootstrapped`).value + (publishLocal in `dotty-doc-bootstrapped`).value + (publishLocal in `dotty-compiler-bootstrapped`).value + (publishLocal in `sbt-dotty`).value + (publishLocal in `dotty-bootstrapped`).value + val pluginText = s"""addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "$sbtDottyVersion")""" + IO.write(baseDirectory.value / "sbt-dotty.sbt", pluginText) + IO.write(baseDirectory.value / "dotty-bootstrapped.version", dottyVersion) + }, + (Test / testOnly) := ((Test / testOnly) dependsOn prepareCommunityBuild).evaluated, + (Test / test ) := ((Test / test ) dependsOn prepareCommunityBuild).value + ) lazy val publishSettings = Seq( publishMavenStyle := true,