From 39009885d77044f2135b38abf51082cfb456ba2f Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 7 Nov 2023 17:07:50 +0100 Subject: [PATCH] Run all supported tests with Scala 2 library TASTy --- .github/workflows/ci.yaml | 2 +- .../tools/dotc/semanticdb/SemanticdbTests.scala | 3 +++ .../dotty/tools/scripting/BashScriptsTests.scala | 12 ++++++++++++ .../test/dotty/tools/scripting/ExpressionTest.scala | 5 ++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 27b3dccd4eb7..fd1fe30d3fa9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -186,7 +186,7 @@ jobs: run: cp -vf .github/workflows/repositories /root/.sbt/ ; true - name: Test with Scala 2 library TASTy - run: ./project/scripts/sbt ";set ThisBuild/Build.useScala2LibraryTasty := true ;scala3-bootstrapped/testCompilation" + run: ./project/scripts/sbt ";set ThisBuild/Build.useScala2LibraryTasty := true ;scala3-bootstrapped/test" test_windows_fast: diff --git a/compiler/test/dotty/tools/dotc/semanticdb/SemanticdbTests.scala b/compiler/test/dotty/tools/dotc/semanticdb/SemanticdbTests.scala index 8839a6cd03b1..c6727b5142b0 100644 --- a/compiler/test/dotty/tools/dotc/semanticdb/SemanticdbTests.scala +++ b/compiler/test/dotty/tools/dotc/semanticdb/SemanticdbTests.scala @@ -16,6 +16,7 @@ import scala.jdk.CollectionConverters._ import javax.tools.ToolProvider import org.junit.Assert._ +import org.junit.Assume.assumeFalse import org.junit.Test import org.junit.experimental.categories.Category @@ -23,6 +24,7 @@ import dotty.BootstrappedOnlyTests import dotty.tools.dotc.Main import dotty.tools.dotc.semanticdb.Scala3.given import dotty.tools.dotc.util.SourceFile +import dotty.Properties @main def updateExpect = SemanticdbTests().runExpectTest(updateExpectFiles = true) @@ -65,6 +67,7 @@ class SemanticdbTests: @Test def expectTests: Unit = if (!scala.util.Properties.isWin) runExpectTest(updateExpectFiles = false) def runExpectTest(updateExpectFiles: Boolean): Unit = + assumeFalse("dotty/tests/semanticdb/metac.expect differs when using Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val target = generateSemanticdb() val errors = mutable.ArrayBuffer.empty[Path] val metacSb: StringBuilder = StringBuilder(5000) diff --git a/compiler/test/dotty/tools/scripting/BashScriptsTests.scala b/compiler/test/dotty/tools/scripting/BashScriptsTests.scala index 8a19d0420692..f3f364754e20 100644 --- a/compiler/test/dotty/tools/scripting/BashScriptsTests.scala +++ b/compiler/test/dotty/tools/scripting/BashScriptsTests.scala @@ -7,6 +7,7 @@ import scala.language.unsafeNulls import java.nio.file.Paths import org.junit.{Test, AfterClass} import org.junit.Assert.assertEquals +import org.junit.Assume.assumeFalse import org.junit.experimental.categories.Category import vulpix.TestConfiguration @@ -84,30 +85,35 @@ class BashScriptsTests: /* verify that `dist/bin/scala` correctly passes args to the jvm via -J-D for script envtest.sc */ @Test def verifyScJProperty = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val tag = "World1" val stdout = callScript(tag, envtestSc, s"-J-Dkey") assertEquals( s"Hello $tag", stdout) /* verify that `dist/bin/scala` correctly passes args to the jvm via -J-D for script envtest.scala */ @Test def verifyScalaJProperty = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val tag = "World2" val stdout = callScript(tag, envtestScala, s"-J-Dkey") assertEquals(s"Hello $tag", stdout) /* verify that `dist/bin/scala` can set system properties via -D for envtest.sc */ @Test def verifyScDProperty = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val tag = "World3" val stdout = callScript(tag, envtestSc, s"-Dkey") assertEquals(s"Hello $tag", stdout) /* verify that `dist/bin/scala` can set system properties via -D for envtest.scala */ @Test def verifyScalaDProperty = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val tag = "World4" val stdout = callScript(tag, envtestScala, s"-Dkey") assertEquals(s"Hello $tag", stdout) /* verify that `dist/bin/scala` can set system properties via -D when executing compiled script via -jar envtest.jar */ @Test def saveAndRunWithDProperty = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val commandline = Seq("SCALA_OPTS= ", scalaPath.relpath, "-save", envtestScala.relpath).mkString(" ") val (_, _, _, _) = bashCommand(commandline) // compile jar, discard output val testJar = testFile("envtest.jar") // jar is created by the previous bashCommand() @@ -125,6 +131,7 @@ class BashScriptsTests: /* verify `dist/bin/scalac` non-interference with command line args following script name */ @Test def verifyScalacArgs = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val commandline = (Seq("SCALA_OPTS= ", scalacPath, "-script", showArgsScript) ++ testScriptArgs).mkString(" ") val (validTest, exitCode, stdout, stderr) = bashCommand(commandline) if verifyValid(validTest) then @@ -140,6 +147,7 @@ class BashScriptsTests: /* verify `dist/bin/scala` non-interference with command line args following script name */ @Test def verifyScalaArgs = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val commandline = (Seq("SCALA_OPTS= ", scalaPath, showArgsScript) ++ testScriptArgs).mkString(" ") val (validTest, exitCode, stdout, stderr) = bashCommand(commandline) if verifyValid(validTest) then @@ -159,6 +167,7 @@ class BashScriptsTests: */ @Category(Array(classOf[BootstrappedOnlyTests])) @Test def verifyScriptPathProperty = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val scriptFile = testFiles.find(_.getName == "scriptPath.sc").get val expected = s"${scriptFile.getName}" printf("===> verify valid system property script.path is reported by script [%s]\n", scriptFile.getName) @@ -175,6 +184,7 @@ class BashScriptsTests: * verify SCALA_OPTS can specify an @argsfile when launching a scala script in `dist/bin/scala`. */ @Test def verifyScalaOpts = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val scriptFile = testFiles.find(_.getName == "classpathReport.sc").get printf("===> verify SCALA_OPTS='@argsfile' is properly handled by `dist/bin/scala`\n") val envPairs = List(("SCALA_OPTS", s"@$argsfile")) @@ -197,6 +207,7 @@ class BashScriptsTests: * verify that individual scripts can override -save with -nosave (needed to address #13760). */ @Test def sqlDateTest = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val scriptBase = "sqlDateError" val scriptFile = testFiles.find(_.getName == s"$scriptBase.sc").get val testJar = testFile(s"$scriptBase.jar") // jar should not be created when scriptFile runs @@ -221,6 +232,7 @@ class BashScriptsTests: * verify -e println("yo!") works. */ @Test def verifyCommandLineExpression = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) printf("===> verify -e is properly handled by `dist/bin/scala`\n") val expected = "9" val expression = s"println(3*3)" diff --git a/compiler/test/dotty/tools/scripting/ExpressionTest.scala b/compiler/test/dotty/tools/scripting/ExpressionTest.scala index a464d15a8fab..6b5248e67f08 100755 --- a/compiler/test/dotty/tools/scripting/ExpressionTest.scala +++ b/compiler/test/dotty/tools/scripting/ExpressionTest.scala @@ -7,6 +7,7 @@ import scala.language.unsafeNulls import java.nio.file.Paths import org.junit.{Test, AfterClass} import org.junit.Assert.assertEquals +import org.junit.Assume.assumeFalse import org.junit.experimental.categories.Category import vulpix.TestConfiguration @@ -22,13 +23,15 @@ class ExpressionTest: * verify -e works. */ @Test def verifyCommandLineExpression = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) printf("===> verify -e is properly handled by `dist/bin/scala`\n") val expected = "9" val expression = s"println(3*3)" val result = getResult(expression) - assert(result.contains(expected), s"expression [$expression] did not send [$expected] to stdout") + assert(result.contains(expected), s"expression [$expression] did not send [$expected] to stdout. It send [$result].") @Test def verifyImports: Unit = + assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty) val expressionLines = List( "import java.nio.file.Paths", "import scala.util.Properties.userDir",