@@ -7,93 +7,15 @@ import org.junit.{Ignore, Test}
77import org .junit .Assert .{assertEquals , fail }
88import org .junit .experimental .categories .Category
99
10- abstract class CommunityBuildTest :
11- given CommunityBuildTest = this
12-
13- /** Depending on the mode of operation, either
14- * runs the test or updates the project. Updating
15- * means that all the dependencies are fetched but
16- * minimal other extra other work is done. Updating
17- * is necessary since we run tests each time on a fresh
18- * Docker container. We run the update on Docker container
19- * creation time to create the cache of the dependencies
20- * and avoid network overhead. See https://github.com/lampepfl/dotty-drone
21- * for more infrastructural details.
22- */
23- extension (self : CommunityProject ) def run ()(using suite : CommunityBuildTest ): Unit =
24- if self.requiresExperimental && ! compilerSupportExperimental then
25- println(
26- s " Skipping ${self.project} - it needs experimental features unsupported in this build. "
27- )
28- return
29- self.dependencies.foreach(_.publish())
30- self.testOnlyDependencies().foreach(_.publish())
31- suite.test(self)
32-
33- /** Build the given project with the published local compiler and sbt plugin.
34- *
35- * This test reads the compiler version from community-build/dotty-bootstrapped.version
36- * and expects community-build/sbt-dotty-sbt to set the compiler plugin.
37- *
38- * @param project The project name, should be a git submodule in community-build/
39- * @param command The binary file of the program used to test the project – usually
40- * a build tool like SBT or Mill
41- * @param arguments Arguments to pass to the testing program
42- */
43- def test (projectDef : CommunityProject ): Unit = {
44- val project = projectDef.project
45- val command = projectDef.binaryName
46- val arguments = projectDef.buildCommands
47-
48- @ annotation.tailrec
49- def execTimes (task : () => Int , timesToRerun : Int ): Boolean =
50- val exitCode = task()
51- if exitCode == 0
52- then true
53- else if timesToRerun == 0
54- then false
55- else
56- log(s " Rerunning tests in $project because of a previous run failure. " )
57- execTimes(task, timesToRerun - 1 )
58-
59- log(s " Building $project with dotty-bootstrapped $compilerVersion... " )
60-
61- val projectDir = communitybuildDir.resolve(" community-projects" ).resolve(project)
62-
63- if (! Files .exists(projectDir.resolve(" .git" ))) {
64- fail(s """
65- |
66- |Missing $project submodule. You can initialize this module using
67- |
68- | git submodule update --init community-build/community-projects/ $project
69- |
70- | """ .stripMargin)
71- }
72-
73- val testsCompletedSuccessfully = execTimes(projectDef.build, 3 )
74-
75- if (! testsCompletedSuccessfully) {
76- fail(s """
77- |
78- | $command exited with an error code. To reproduce without JUnit, use:
79- |
80- | sbt community-build/prepareCommunityBuild
81- | cd community-build/community-projects/ $project
82- | $command ${arguments.init.mkString(" " )} " ${arguments.last}"
83- |
84- |For a faster feedback loop on SBT projects, one can try to extract a direct call to dotc
85- |using the sbt export command. For instance, for scalacheck, use
86- | sbt export jvm/test:compileIncremental
87- |
88- | """ .stripMargin)
89- }
90- }
91- end CommunityBuildTest
10+ import CommunityBuildRunner .run
9211
9312class TestCategory
9413
14+ given testRunner : CommunityBuildRunner with
15+ override def failWith (msg : String ) = { fail(msg); ??? }
16+
9517@ Category (Array (classOf [TestCategory ]))
96- class CommunityBuildTestA extends CommunityBuildTest :
18+ class CommunityBuildTestA :
9719 @ Test def izumiReflect = projects.izumiReflect.run()
9820 @ Test def scalaSTM = projects.scalaSTM.run()
9921 @ Test def scalatest = projects.scalatest.run()
@@ -112,7 +34,7 @@ class CommunityBuildTestA extends CommunityBuildTest:
11234end CommunityBuildTestA
11335
11436@ Category (Array (classOf [TestCategory ]))
115- class CommunityBuildTestB extends CommunityBuildTest :
37+ class CommunityBuildTestB :
11638 @ Test def cats = projects.cats.run()
11739 @ Test def catsEffect3 = projects.catsEffect3.run()
11840 @ Test def catsMtl = projects.catsMtl.run()
@@ -132,7 +54,7 @@ class CommunityBuildTestB extends CommunityBuildTest:
13254end CommunityBuildTestB
13355
13456@ Category (Array (classOf [TestCategory ]))
135- class CommunityBuildTestC extends CommunityBuildTest :
57+ class CommunityBuildTestC :
13658 @ Test def akka = projects.akka.run()
13759 @ Test def algebra = projects.algebra.run()
13860 @ Test def betterfiles = projects.betterfiles.run()
0 commit comments