Skip to content

Commit

Permalink
Run all tests with Scala 2 library TASTy
Browse files Browse the repository at this point in the history
Run all tests with Scala 2 library TASTy with some failing tests blacklisted.
  • Loading branch information
nicolasstucki committed Nov 17, 2023
1 parent 50498d8 commit 0cbee8f
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 12 deletions.
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
30 changes: 30 additions & 0 deletions compiler/test/dotc/scala2-library-tasty.blacklist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## tests/run-macros
tasty-extractors-1
tasty-extractors-2
tasty-extractors-types

## tests/neg
i8752.scala
f-interpolator-neg.scala # Additional: A pure expression does nothing in statement position

## (#18882) tests/init-global/neg
t9312.scala
unapplySeq-implicit-arg.scala
unapplySeq-implicit-arg2.scala
unapplySeq-implicit-arg3.scala

## (#18882) tests/init-global/pos
patmat.scala
patmat-interpolator.scala
unapplySeq-implicit-arg-pos.scala
global-cycle11.scala

## tests/patmat
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

## Other issues
# - CompilationTests.pos: tests/pos-special/stdlib
# - CoverageTests.checkInstrumentedRuns
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
9 changes: 9 additions & 0 deletions 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 Down Expand Up @@ -36,6 +37,14 @@ object TestSources {
def runTestRecheckExcluded: List[String] = loadList(runTestRecheckExcludesFile)
def runLazyValsAllowlist: List[String] = loadList(runLazyValsAllowlistFile)

// other lists

def scala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/scala2-library-tasty.blacklist"

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

// load lists

private def loadList(path: String): List[String] = {
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.scala2LibraryTastyBlacklisted))
.checkRuns()
}

Expand Down
13 changes: 8 additions & 5 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.scala2LibraryTastyBlacklisted)),
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 All @@ -153,7 +156,7 @@ class CompilationTests {
@Test def runAll: Unit = {
implicit val testGroup: TestGroup = TestGroup("runAll")
aggregateTests(
compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init")),
compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init"), FileFilter.exclude(TestSources.scala2LibraryTastyBlacklisted)),
compileFilesInDir("tests/run-deep-subtype", allowDeepSubtypes),
compileFilesInDir("tests/run-custom-args/captures", allowDeepSubtypes.and("-language:experimental.captureChecking")),
// Run tests for legacy lazy vals.
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.scala2LibraryTastyBlacklisted)).checkExpectedErrors()
compileFilesInDir("tests/init-global/pos", options, FileFilter.exclude(TestSources.scala2LibraryTastyBlacklisted)).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.scala2LibraryTastyBlacklisted.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

0 comments on commit 0cbee8f

Please sign in to comment.