Skip to content

Add nightly compilation tests for Scala 2 library TASTy #18892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,51 @@ jobs:
run: |
./project/scripts/sbt ";sjsSandbox/run ;sjsSandbox/test ;sjsJUnitTests/test ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToESModules ;sjsJUnitTests/test ;sjsCompilerTests/test"

- name: Test with Scala 2 library TASTy
- name: Test with Scala 2 library TASTy (fast)
run: ./project/scripts/sbt ";set ThisBuild/Build.useScala2LibraryTasty := true ;scala3-bootstrapped/testCompilation i5; scala3-bootstrapped/testCompilation tests/run/typelevel-peano.scala" # only test a subset of test to avoid doubling the CI execution time

test_scala2_library_tasty:
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
- ${{ github.workspace }}/../../cache/general:/root/.cache
if: "github.event_name == 'schedule' && github.repository == 'lampepfl/dotty'
|| (
github.event_name == 'pull_request'
&& contains(github.event.pull_request.body, '[test_scala2_library_tasty]')
)
|| (
github.event_name == 'workflow_dispatch'
&& github.repository == 'lampepfl/dotty'
)"

steps:
- name: Set JDK 16 as default
run: echo "/usr/lib/jvm/java-16-openjdk-amd64/bin" >> $GITHUB_PATH

- name: Reset existing repo
run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true

- name: Checkout cleanup script
uses: actions/checkout@v3

- name: Cleanup
run: .github/workflows/cleanup.sh

- name: Git Checkout
uses: actions/checkout@v3

- name: Add SBT proxy repositories
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"


test_windows_fast:
runs-on: [self-hosted, Windows]
if: "(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## See #18882
patmat.scala
t9312.scala
unapplySeq-implicit-arg.scala
unapplySeq-implicit-arg2.scala
unapplySeq-implicit-arg3.scala
2 changes: 2 additions & 0 deletions compiler/test/dotc/neg-scala2-library-tasty.blacklist
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
i8752.scala
f-interpolator-neg.scala # Additional: A pure expression does nothing in statement position
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
t7746.scala # order of exhaustivity suggestions differs
t4408.scala # order of exhaustivity suggestions differs
patmat-ortype.scala # order of exhaustivity suggestions differs
i13003.scala # order of exhaustivity suggestions differs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## See #18882
patmat.scala
patmat-interpolator.scala
unapplySeq-implicit-arg-pos.scala
global-cycle11.scala
4 changes: 4 additions & 0 deletions compiler/test/dotc/run-macros-scala2-library-tasty.blacklist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Checkfile differences for equivalent type
tasty-extractors-1
tasty-extractors-2
tasty-extractors-types
3 changes: 3 additions & 0 deletions compiler/test/dotty/Properties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ object Properties {
/** scala-library TASTy jar */
def scalaLibraryTasty: Option[String] = sys.props.get("dotty.tests.tasties.scalaLibrary")

/** If we are using the scala-library TASTy jar */
def usingScalaLibraryTasty: Boolean = scalaLibraryTasty.isDefined

/** scala-asm jar */
def scalaAsm: String = sys.props("dotty.tests.classes.scalaAsm")

Expand Down
30 changes: 29 additions & 1 deletion compiler/test/dotty/tools/TestSources.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import java.io.File
import java.nio.file._

import scala.jdk.CollectionConverters._
import dotty.Properties

object TestSources {

Expand All @@ -16,25 +17,52 @@ object TestSources {
def posTestRecheckExcludesFile: String = "compiler/test/dotc/pos-test-recheck.excludes"
def posLazyValsAllowlistFile: String = "compiler/test/dotc/pos-lazy-vals-tests.allowlist"
def posLintingAllowlistFile: String = "compiler/test/dotc/pos-linting.allowlist"
def posInitGlobalScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/pos-init-global-scala2-library-tasty.blacklist"

def posFromTastyBlacklisted: List[String] = loadList(posFromTastyBlacklistFile)
def posTestPicklingBlacklisted: List[String] = loadList(posTestPicklingBlacklistFile)
def posTestRecheckExcluded: List[String] = loadList(posTestRecheckExcludesFile)
def posLazyValsAllowlist: List[String] = loadList(posLazyValsAllowlistFile)
def posLintingAllowlist: List[String] = loadList(posLintingAllowlistFile)
def posInitGlobalScala2LibraryTastyBlacklisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(posInitGlobalScala2LibraryTastyBlacklistFile)
else Nil

// run tests lists

def runFromTastyBlacklistFile: String = "compiler/test/dotc/run-from-tasty.blacklist"
def runTestPicklingBlacklistFile: String = "compiler/test/dotc/run-test-pickling.blacklist"
def runTestRecheckExcludesFile: String = "compiler/test/dotc/run-test-recheck.excludes"
def runLazyValsAllowlistFile: String = "compiler/test/dotc/run-lazy-vals-tests.allowlist"

def runMacrosScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/run-macros-scala2-library-tasty.blacklist"

def runFromTastyBlacklisted: List[String] = loadList(runFromTastyBlacklistFile)
def runTestPicklingBlacklisted: List[String] = loadList(runTestPicklingBlacklistFile)
def runTestRecheckExcluded: List[String] = loadList(runTestRecheckExcludesFile)
def runLazyValsAllowlist: List[String] = loadList(runLazyValsAllowlistFile)
def runMacrosScala2LibraryTastyBlacklisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(runMacrosScala2LibraryTastyBlacklistFile)
else Nil

// neg tests lists

def negScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/neg-scala2-library-tasty.blacklist"
def negInitGlobalScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/neg-init-global-scala2-library-tasty.blacklist"

def negScala2LibraryTastyBlacklisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(negScala2LibraryTastyBlacklistFile)
else Nil
def negInitGlobalScala2LibraryTastyBlacklisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(negInitGlobalScala2LibraryTastyBlacklistFile)
else Nil

// patmat tests lists

def patmatExhaustivityScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/patmat-exhaustivity-scala2-library-tasty.blacklist"

def patmatExhaustivityScala2LibraryTastyBlacklisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(patmatExhaustivityScala2LibraryTastyBlacklistFile)
else Nil

// load lists

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class BootstrappedOnlyCompilationTests {

@Test def runMacros: Unit = {
implicit val testGroup: TestGroup = TestGroup("runMacros")
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros"))
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros"), FileFilter.exclude(TestSources.runMacrosScala2LibraryTastyBlacklisted))
.checkRuns()
}

Expand Down
11 changes: 7 additions & 4 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class CompilationTests {
// Run tests for legacy lazy vals
compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)),
compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")),
compileDir("tests/pos-special/stdlib", allowDeepSubtypes),
) ::: (
// FIXME: This fails due to a bug involving self types and capture checking
if Properties.usingScalaLibraryTasty then Nil
else List(compileDir("tests/pos-special/stdlib", allowDeepSubtypes))
)

if scala.util.Properties.isJavaAtLeast("16") then
Expand Down Expand Up @@ -130,7 +133,7 @@ class CompilationTests {
@Test def negAll: Unit = {
implicit val testGroup: TestGroup = TestGroup("compileNeg")
aggregateTests(
compileFilesInDir("tests/neg", defaultOptions),
compileFilesInDir("tests/neg", defaultOptions, FileFilter.exclude(TestSources.negScala2LibraryTastyBlacklisted)),
compileFilesInDir("tests/neg-deep-subtype", allowDeepSubtypes),
compileFilesInDir("tests/neg-custom-args/captures", defaultOptions.and("-language:experimental.captureChecking")),
compileFile("tests/neg-custom-args/sourcepath/outer/nested/Test1.scala", defaultOptions.and("-sourcepath", "tests/neg-custom-args/sourcepath")),
Expand Down Expand Up @@ -213,8 +216,8 @@ class CompilationTests {
@Test def checkInitGlobal: Unit = {
implicit val testGroup: TestGroup = TestGroup("checkInitGlobal")
val options = defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings")
compileFilesInDir("tests/init-global/neg", options).checkExpectedErrors()
compileFilesInDir("tests/init-global/pos", options).checkCompile()
compileFilesInDir("tests/init-global/neg", options, FileFilter.exclude(TestSources.negInitGlobalScala2LibraryTastyBlacklisted)).checkExpectedErrors()
compileFilesInDir("tests/init-global/pos", options, FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyBlacklisted)).checkCompile()
}

// initialization tests
Expand Down
9 changes: 9 additions & 0 deletions compiler/test/dotty/tools/dotc/coverage/CoverageTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dotty.tools.dotc.coverage
import org.junit.Test
import org.junit.AfterClass
import org.junit.Assert.*
import org.junit.Assume.*
import org.junit.experimental.categories.Category
import dotty.{BootstrappedOnlyTests, Properties}
import dotty.tools.vulpix.*
Expand All @@ -28,10 +29,18 @@ class CoverageTests:

@Test
def checkCoverageStatements(): Unit =
assumeFalse(
"FIXME: test output differs when using Scala 2 library TASTy",
Properties.usingScalaLibraryTasty
)
checkCoverageIn(rootSrc.resolve("pos"), false)

@Test
def checkInstrumentedRuns(): Unit =
assumeFalse(
"FIXME: test output differs when using Scala 2 library TASTy",
Properties.usingScalaLibraryTasty
)
checkCoverageIn(rootSrc.resolve("run"), true)

def checkCoverageIn(dir: Path, run: Boolean)(using TestGroup): Unit =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ class PatmatExhaustivityTest {

@Test
def patmatExhaustivity: Unit = {
val blacklisted = TestSources.patmatExhaustivityScala2LibraryTastyBlacklisted.toSet
val res = Directory(testsDir).list.toList
.filter(f => f.extension == "scala" || f.isDirectory)
.filter { f =>
val path = if f.isDirectory then f.path + "/" else f.path
Properties.testsFilter.isEmpty || Properties.testsFilter.exists(path.contains)
}
.filterNot(f => blacklisted.contains(f.name))
.map(f => if f.isDirectory then compileDir(f.jpath) else compileFile(f.jpath))

val failed = res.filter(!_)
Expand Down
9 changes: 5 additions & 4 deletions docs/_docs/contributing/sending-in-a-pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ Below are commonly used ones:
Depending on what your PR is addressing, sometimes it doesn't make sense to run
parts of the CI that usually ony runs on nightly builds.

|---------------------------|----------------------------------------------------|
| `[test_java8]` | Execute unit tests on Java 8 |
| `[test_windows_full]` | Execute unit tests on Windows |
| `[test_non_bootstrapped]` | Execute unit tests using non-bootstrapped compiler |
|-------------------------------|---------------------------------------------------------------------------|
| `[test_java8]` | Execute unit tests on Java 8 |
| `[test_windows_full]` | Execute unit tests on Windows |
| `[test_non_bootstrapped]` | Execute unit tests using non-bootstrapped compiler |
| `[test_scala2_library_tasty]` | Execute unit tests using bootstrapped-compiler with Scala 2 library TASTy |

### 7: Create your PR!

Expand Down
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ object Build {
// Use the TASTy jar from `scala2-library-tasty` in the classpath
// This only works with `scala3-bootstrapped/scalac` and tests in `scala3-bootstrapped`
//
// Enable in SBT with: set ThisBuild/Build.useScala2LibraryTasty := true
// Enable in SBT with: `set ThisBuild/Build.useScala2LibraryTasty := true`
val useScala2LibraryTasty = settingKey[Boolean]("Use the TASTy jar from `scala2-library-tasty` in the classpath")

// Used to compile files similar to ./bin/scalac script
Expand Down