Use launcher scripted tests

This commit is contained in:
Eugene Yokota 2022-10-02 01:58:37 -04:00
parent a9a8ab6341
commit 20420b9f75
6 changed files with 76 additions and 42 deletions

View File

@ -17,15 +17,15 @@ jobs:
distribution: temurin
jobtype: 1
- os: ubuntu-latest
java: 17
java: 11
distribution: temurin
jobtype: 2
- os: ubuntu-latest
java: 17
java: 11
distribution: temurin
jobtype: 3
- os: ubuntu-latest
java: 17
java: 11
distribution: temurin
jobtype: 4
- os: ubuntu-latest
@ -44,7 +44,7 @@ jobs:
java: 8
distribution: adopt
jobtype: 8
- os: windows-latest
- os: windows-2019
java: 8
distribution: adopt
jobtype: 9
@ -93,14 +93,20 @@ jobs:
python-version: 3.7
- name: Coursier cache
uses: coursier/cache-action@v6
- name: Cache sbt
uses: actions/cache@v3
with:
path: ~/.sbt
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
# - name: Cache sbt
# uses: actions/cache@v3
# with:
# path: ~/.sbt
# key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
- name: Setup Windows C++ toolchain
uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.os == 'windows-latest' }}
if: ${{ matrix.os == 'windows-2019' }}
- name: Pre-test cleanup
shell: bash
run: |
rm -rf "$HOME/.sbt/scripted/" || true
rm -rf "$HOME/.ivy2/local" || true
rm -r $(find $HOME/.sbt/boot -name "*-SNAPSHOT") || true
- name: Build and test (1)
if: ${{ matrix.jobtype == 1 }}
shell: bash
@ -131,29 +137,31 @@ jobs:
if: ${{ matrix.jobtype == 3 }}
shell: bash
run: |
./sbt -v "dependencyTreeProj/publishLocal; scripted dependency-graph/* dependency-management/* plugins/* project-load/* java/* run/* nio/*"
# ./sbt -v "dependencyTreeProj/publishLocal; scripted dependency-graph/*"
./sbt -v --client "scripted dependency-management/* plugins/* project-load/* java/* run/* nio/*"
- name: Build and test (4)
if: ${{ matrix.jobtype == 4 }}
shell: bash
run: |
./sbt -v "repoOverrideTest:scripted dependency-management/*; scripted source-dependencies/* project/*"
- name: Build and test (5)
if: ${{ matrix.jobtype == 5 }}
shell: bash
run: |
./sbt -v "++$SCALA_213!; test; ++$SCALA_3!; all utilControl/test utilRelation/test utilPosition/test"
- name: Build and test (6)
if: ${{ matrix.jobtype == 6 }}
shell: bash
run: |
# build from fresh IO, LM, and Zinc
BUILD_VERSION="1.5.0-SNAPSHOT"
cd io
sbt -v -Dsbt.build.version=${BUILD_VERSION} +publishLocal
cd ../
sbt -Dsbtlm.path=$HOME/work/sbt/sbt/librarymanagement -Dsbtzinc.path=$HOME/work/sbt/sbt/zinc -Dsbt.build.version=$BUILD_VERSION -Dsbt.build.fatal=false "+lowerUtils/publishLocal; {librarymanagement}/publishLocal; {zinc}/publishLocal; upperModules/publishLocal"
rm -r $(find $HOME/.sbt/boot -name "*-SNAPSHOT") || true
sbt -v -Dsbt.version=$BUILD_VERSION "++$SCALA_213; all $UTIL_TESTS; ++$SCALA_212; all $UTIL_TESTS; scripted actions/* source-dependencies/*1of3 dependency-management/*1of4 java/*"
# ./sbt -v "repoOverrideTest:scripted dependency-management/*"
./sbt -v "scripted source-dependencies/* project/*"
# - name: Build and test (5)
# if: ${{ matrix.jobtype == 5 }}
# shell: bash
# run: |
# ./sbt -v "++$SCALA_213!; test; ++$SCALA_3!; all utilControl/test utilRelation/test utilPosition/test"
# - name: Build and test (6)
# if: ${{ matrix.jobtype == 6 }}
# shell: bash
# run: |
# # build from fresh IO, LM, and Zinc
# BUILD_VERSION="1.5.0-SNAPSHOT"
# cd io
# sbt -v -Dsbt.build.version=${BUILD_VERSION} +publishLocal
# cd ../
# sbt -Dsbtlm.path=$HOME/work/sbt/sbt/librarymanagement -Dsbtzinc.path=$HOME/work/sbt/sbt/zinc -Dsbt.build.version=$BUILD_VERSION -Dsbt.build.fatal=false "+lowerUtils/publishLocal; {librarymanagement}/publishLocal; {zinc}/publishLocal; upperModules/publishLocal"
# rm -r $(find $HOME/.sbt/boot -name "*-SNAPSHOT") || true
# sbt -v -Dsbt.version=$BUILD_VERSION "++$SCALA_213; all $UTIL_TESTS; ++$SCALA_212; all $UTIL_TESTS; scripted actions/* source-dependencies/*1of3 dependency-management/*1of4 java/*"
- name: Build and test (7)
if: ${{ matrix.jobtype == 7 }}
shell: bash

View File

@ -1224,6 +1224,7 @@ def scriptedTask(launch: Boolean): Def.Initialize[InputTask[Unit]] = Def.inputTa
(scriptedSbtReduxProj / Test / fullClasspathAsJars).value
.map(_.data)
.filterNot(_.getName.contains("scala-compiler")),
(bundledLauncherProj / Compile / packageBin).value,
streams.value.log
)
}
@ -1277,8 +1278,8 @@ ThisBuild / scriptedPrescripted := { _ => }
def otherRootSettings =
Seq(
scripted := scriptedTask(false).evaluated,
scriptedUnpublished := scriptedTask(false).evaluated,
scripted := scriptedTask(true).evaluated,
scriptedUnpublished := scriptedTask(true).evaluated,
scriptedSource := (sbtProj / sourceDirectory).value / "sbt-test",
scripted / watchTriggers += scriptedSource.value.toGlob / **,
scriptedUnpublished / watchTriggers := (scripted / watchTriggers).value,

View File

@ -99,6 +99,7 @@ object Scripted {
scalaVersion: String,
sbtVersion: String,
classpath: Seq[File],
launcherJar: File,
logger: Logger
): Unit = {
logger.info(s"About to run tests: ${args.mkString("\n * ", "\n * ", "\n")}")
@ -113,16 +114,27 @@ object Scripted {
// Interface to cross class loader
type SbtScriptedRunner = {
// def runInParallel(
// resourceBaseDirectory: File,
// bufferLog: Boolean,
// tests: Array[String],
// launchOpts: Array[String],
// prescripted: java.util.List[File],
// scalaVersion: String,
// sbtVersion: String,
// classpath: Array[File],
// instances: Int
// ): Unit
def runInParallel(
resourceBaseDirectory: File,
bufferLog: Boolean,
tests: Array[String],
launcherJar: File,
javaCommand: String,
launchOpts: Array[String],
prescripted: java.util.List[File],
scalaVersion: String,
sbtVersion: String,
classpath: Array[File],
instances: Int
instance: Int,
): Unit
}
@ -146,15 +158,26 @@ object Scripted {
case _ => 1
}
import scala.language.reflectiveCalls
// bridge.runInParallel(
// sourcePath,
// bufferLog,
// args.toArray,
// launchOpts.toArray,
// callback,
// scalaVersion,
// sbtVersion,
// classpath.toArray,
// instances
// )
bridge.runInParallel(
sourcePath,
bufferLog,
args.toArray,
launcherJar,
"java",
launchOpts.toArray,
callback,
scalaVersion,
sbtVersion,
classpath.toArray,
instances
)
} catch { case ite: InvocationTargetException => throw ite.getCause }

View File

@ -158,7 +158,7 @@ object RunFromSourceMain {
}
val Name = """(.*)(?:\-[\d.]+)\.jar""".r
val BinPre = """(.*)(?:\-[\d.]+)-(?:bin|pre)-.*\.jar""".r
val module = "org.scala-lang" % "scala-compiler" % scalaVersion
val module = "org.scala-lang" % "scala3-compiler_3" % scalaVersion
lm.retrieve(module, scalaModuleInfo = None, scalaHome1Temp, log) match {
case Left(w) => throw w.resolveException
case Right(_) =>

View File

@ -45,8 +45,10 @@ final class LauncherBasedRemoteSbtCreator(
val cmd =
javaCommand :: launchOpts.toList ::: globalBase :: scripted :: "-jar" :: launcherJar :: args ::: Nil
val io = BasicIO(false, log).withInput(_.close())
val p = Process(cmd, directory) run (io)
val thread = new Thread() { override def run() = { p.exitValue(); server.close() } }
val p = Process(cmd, directory).run(io)
val thread = new Thread() {
override def run(): Unit = { p.exitValue(); server.close() }
}
thread.start()
p
}

View File

@ -144,7 +144,7 @@ final class ScriptedTests(
log.info(
f"Running $size / $totalSize (${size * 100d / totalSize}%3.2f%%) scripted tests with $how"
)
logTests(runFromSourceBasedTests.size, "RunFromSourceMain")
logTests(runFromSourceBasedTests.size, prop.toString)
def createTestRunners(tests: Seq[TestInfo]): Seq[TestRunner] = {
tests