Skip to content

Commit f831830

Browse files
authored
Add nightly compilation tests for Scala 2 library TASTy (#18892)
This adds a new CI test for the Scala 2 library TASTy configuration. We enable all `testCompilation` tests except a few that are blacklisted and need to be fixed at some point. This test only triggers on nightly builds or with the `[test_scala2_library_tasty]` tag. We also keep the current set of tests on every PR. [test_scala2_library_tasty]
2 parents e0a0e30 + 726da0c commit f831830

14 files changed

+121
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,51 @@ jobs:
143143
run: |
144144
./project/scripts/sbt ";sjsSandbox/run ;sjsSandbox/test ;sjsJUnitTests/test ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToESModules ;sjsJUnitTests/test ;sjsCompilerTests/test"
145145
146-
- name: Test with Scala 2 library TASTy
146+
- name: Test with Scala 2 library TASTy (fast)
147147
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
148148

149+
test_scala2_library_tasty:
150+
runs-on: [self-hosted, Linux]
151+
container:
152+
image: lampepfl/dotty:2021-03-22
153+
options: --cpu-shares 4096
154+
volumes:
155+
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
156+
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
157+
- ${{ github.workspace }}/../../cache/general:/root/.cache
158+
if: "github.event_name == 'schedule' && github.repository == 'lampepfl/dotty'
159+
|| (
160+
github.event_name == 'pull_request'
161+
&& contains(github.event.pull_request.body, '[test_scala2_library_tasty]')
162+
)
163+
|| (
164+
github.event_name == 'workflow_dispatch'
165+
&& github.repository == 'lampepfl/dotty'
166+
)"
167+
168+
steps:
169+
- name: Set JDK 16 as default
170+
run: echo "/usr/lib/jvm/java-16-openjdk-amd64/bin" >> $GITHUB_PATH
171+
172+
- name: Reset existing repo
173+
run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true
174+
175+
- name: Checkout cleanup script
176+
uses: actions/checkout@v3
177+
178+
- name: Cleanup
179+
run: .github/workflows/cleanup.sh
180+
181+
- name: Git Checkout
182+
uses: actions/checkout@v3
183+
184+
- name: Add SBT proxy repositories
185+
run: cp -vf .github/workflows/repositories /root/.sbt/ ; true
186+
187+
- name: Test with Scala 2 library TASTy
188+
run: ./project/scripts/sbt ";set ThisBuild/Build.useScala2LibraryTasty := true ;scala3-bootstrapped/testCompilation"
189+
190+
149191
test_windows_fast:
150192
runs-on: [self-hosted, Windows]
151193
if: "(
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## See #18882
2+
patmat.scala
3+
t9312.scala
4+
unapplySeq-implicit-arg.scala
5+
unapplySeq-implicit-arg2.scala
6+
unapplySeq-implicit-arg3.scala
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
i8752.scala
2+
f-interpolator-neg.scala # Additional: A pure expression does nothing in statement position
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
t7746.scala # order of exhaustivity suggestions differs
2+
t4408.scala # order of exhaustivity suggestions differs
3+
patmat-ortype.scala # order of exhaustivity suggestions differs
4+
i13003.scala # order of exhaustivity suggestions differs
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## See #18882
2+
patmat.scala
3+
patmat-interpolator.scala
4+
unapplySeq-implicit-arg-pos.scala
5+
global-cycle11.scala
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Checkfile differences for equivalent type
2+
tasty-extractors-1
3+
tasty-extractors-2
4+
tasty-extractors-types

compiler/test/dotty/Properties.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ object Properties {
8585
/** scala-library TASTy jar */
8686
def scalaLibraryTasty: Option[String] = sys.props.get("dotty.tests.tasties.scalaLibrary")
8787

88+
/** If we are using the scala-library TASTy jar */
89+
def usingScalaLibraryTasty: Boolean = scalaLibraryTasty.isDefined
90+
8891
/** scala-asm jar */
8992
def scalaAsm: String = sys.props("dotty.tests.classes.scalaAsm")
9093

compiler/test/dotty/tools/TestSources.scala

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import java.io.File
66
import java.nio.file._
77

88
import scala.jdk.CollectionConverters._
9+
import dotty.Properties
910

1011
object TestSources {
1112

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

2022
def posFromTastyBlacklisted: List[String] = loadList(posFromTastyBlacklistFile)
2123
def posTestPicklingBlacklisted: List[String] = loadList(posTestPicklingBlacklistFile)
2224
def posTestRecheckExcluded: List[String] = loadList(posTestRecheckExcludesFile)
2325
def posLazyValsAllowlist: List[String] = loadList(posLazyValsAllowlistFile)
2426
def posLintingAllowlist: List[String] = loadList(posLintingAllowlistFile)
27+
def posInitGlobalScala2LibraryTastyBlacklisted: List[String] =
28+
if Properties.usingScalaLibraryTasty then loadList(posInitGlobalScala2LibraryTastyBlacklistFile)
29+
else Nil
2530

2631
// run tests lists
2732

2833
def runFromTastyBlacklistFile: String = "compiler/test/dotc/run-from-tasty.blacklist"
2934
def runTestPicklingBlacklistFile: String = "compiler/test/dotc/run-test-pickling.blacklist"
3035
def runTestRecheckExcludesFile: String = "compiler/test/dotc/run-test-recheck.excludes"
3136
def runLazyValsAllowlistFile: String = "compiler/test/dotc/run-lazy-vals-tests.allowlist"
32-
37+
def runMacrosScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/run-macros-scala2-library-tasty.blacklist"
3338

3439
def runFromTastyBlacklisted: List[String] = loadList(runFromTastyBlacklistFile)
3540
def runTestPicklingBlacklisted: List[String] = loadList(runTestPicklingBlacklistFile)
3641
def runTestRecheckExcluded: List[String] = loadList(runTestRecheckExcludesFile)
3742
def runLazyValsAllowlist: List[String] = loadList(runLazyValsAllowlistFile)
43+
def runMacrosScala2LibraryTastyBlacklisted: List[String] =
44+
if Properties.usingScalaLibraryTasty then loadList(runMacrosScala2LibraryTastyBlacklistFile)
45+
else Nil
46+
47+
// neg tests lists
48+
49+
def negScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/neg-scala2-library-tasty.blacklist"
50+
def negInitGlobalScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/neg-init-global-scala2-library-tasty.blacklist"
51+
52+
def negScala2LibraryTastyBlacklisted: List[String] =
53+
if Properties.usingScalaLibraryTasty then loadList(negScala2LibraryTastyBlacklistFile)
54+
else Nil
55+
def negInitGlobalScala2LibraryTastyBlacklisted: List[String] =
56+
if Properties.usingScalaLibraryTasty then loadList(negInitGlobalScala2LibraryTastyBlacklistFile)
57+
else Nil
58+
59+
// patmat tests lists
60+
61+
def patmatExhaustivityScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/patmat-exhaustivity-scala2-library-tasty.blacklist"
62+
63+
def patmatExhaustivityScala2LibraryTastyBlacklisted: List[String] =
64+
if Properties.usingScalaLibraryTasty then loadList(patmatExhaustivityScala2LibraryTastyBlacklistFile)
65+
else Nil
3866

3967
// load lists
4068

compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class BootstrappedOnlyCompilationTests {
120120

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

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ class CompilationTests {
4444
// Run tests for legacy lazy vals
4545
compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)),
4646
compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")),
47-
compileDir("tests/pos-special/stdlib", allowDeepSubtypes),
47+
) ::: (
48+
// FIXME: This fails due to a bug involving self types and capture checking
49+
if Properties.usingScalaLibraryTasty then Nil
50+
else List(compileDir("tests/pos-special/stdlib", allowDeepSubtypes))
4851
)
4952

5053
if scala.util.Properties.isJavaAtLeast("16") then
@@ -130,7 +133,7 @@ class CompilationTests {
130133
@Test def negAll: Unit = {
131134
implicit val testGroup: TestGroup = TestGroup("compileNeg")
132135
aggregateTests(
133-
compileFilesInDir("tests/neg", defaultOptions),
136+
compileFilesInDir("tests/neg", defaultOptions, FileFilter.exclude(TestSources.negScala2LibraryTastyBlacklisted)),
134137
compileFilesInDir("tests/neg-deep-subtype", allowDeepSubtypes),
135138
compileFilesInDir("tests/neg-custom-args/captures", defaultOptions.and("-language:experimental.captureChecking")),
136139
compileFile("tests/neg-custom-args/sourcepath/outer/nested/Test1.scala", defaultOptions.and("-sourcepath", "tests/neg-custom-args/sourcepath")),
@@ -213,8 +216,8 @@ class CompilationTests {
213216
@Test def checkInitGlobal: Unit = {
214217
implicit val testGroup: TestGroup = TestGroup("checkInitGlobal")
215218
val options = defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings")
216-
compileFilesInDir("tests/init-global/neg", options).checkExpectedErrors()
217-
compileFilesInDir("tests/init-global/pos", options).checkCompile()
219+
compileFilesInDir("tests/init-global/neg", options, FileFilter.exclude(TestSources.negInitGlobalScala2LibraryTastyBlacklisted)).checkExpectedErrors()
220+
compileFilesInDir("tests/init-global/pos", options, FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyBlacklisted)).checkCompile()
218221
}
219222

220223
// initialization tests

compiler/test/dotty/tools/dotc/coverage/CoverageTests.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dotty.tools.dotc.coverage
33
import org.junit.Test
44
import org.junit.AfterClass
55
import org.junit.Assert.*
6+
import org.junit.Assume.*
67
import org.junit.experimental.categories.Category
78
import dotty.{BootstrappedOnlyTests, Properties}
89
import dotty.tools.vulpix.*
@@ -28,10 +29,18 @@ class CoverageTests:
2829

2930
@Test
3031
def checkCoverageStatements(): Unit =
32+
assumeFalse(
33+
"FIXME: test output differs when using Scala 2 library TASTy",
34+
Properties.usingScalaLibraryTasty
35+
)
3136
checkCoverageIn(rootSrc.resolve("pos"), false)
3237

3338
@Test
3439
def checkInstrumentedRuns(): Unit =
40+
assumeFalse(
41+
"FIXME: test output differs when using Scala 2 library TASTy",
42+
Properties.usingScalaLibraryTasty
43+
)
3544
checkCoverageIn(rootSrc.resolve("run"), true)
3645

3746
def checkCoverageIn(dir: Path, run: Boolean)(using TestGroup): Unit =

compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ class PatmatExhaustivityTest {
6363

6464
@Test
6565
def patmatExhaustivity: Unit = {
66+
val blacklisted = TestSources.patmatExhaustivityScala2LibraryTastyBlacklisted.toSet
6667
val res = Directory(testsDir).list.toList
6768
.filter(f => f.extension == "scala" || f.isDirectory)
6869
.filter { f =>
6970
val path = if f.isDirectory then f.path + "/" else f.path
7071
Properties.testsFilter.isEmpty || Properties.testsFilter.exists(path.contains)
7172
}
73+
.filterNot(f => blacklisted.contains(f.name))
7274
.map(f => if f.isDirectory then compileDir(f.jpath) else compileFile(f.jpath))
7375

7476
val failed = res.filter(!_)

docs/_docs/contributing/sending-in-a-pr.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,11 @@ Below are commonly used ones:
125125
Depending on what your PR is addressing, sometimes it doesn't make sense to run
126126
parts of the CI that usually ony runs on nightly builds.
127127

128-
|---------------------------|----------------------------------------------------|
129-
| `[test_java8]` | Execute unit tests on Java 8 |
130-
| `[test_windows_full]` | Execute unit tests on Windows |
131-
| `[test_non_bootstrapped]` | Execute unit tests using non-bootstrapped compiler |
128+
|-------------------------------|---------------------------------------------------------------------------|
129+
| `[test_java8]` | Execute unit tests on Java 8 |
130+
| `[test_windows_full]` | Execute unit tests on Windows |
131+
| `[test_non_bootstrapped]` | Execute unit tests using non-bootstrapped compiler |
132+
| `[test_scala2_library_tasty]` | Execute unit tests using bootstrapped-compiler with Scala 2 library TASTy |
132133

133134
### 7: Create your PR!
134135

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ object Build {
176176
// Use the TASTy jar from `scala2-library-tasty` in the classpath
177177
// This only works with `scala3-bootstrapped/scalac` and tests in `scala3-bootstrapped`
178178
//
179-
// Enable in SBT with: set ThisBuild/Build.useScala2LibraryTasty := true
179+
// Enable in SBT with: `set ThisBuild/Build.useScala2LibraryTasty := true`
180180
val useScala2LibraryTasty = settingKey[Boolean]("Use the TASTy jar from `scala2-library-tasty` in the classpath")
181181

182182
// Used to compile files similar to ./bin/scalac script

0 commit comments

Comments
 (0)