Skip to content

Commit f7b2264

Browse files
authored
Simplify macro tests with custom args (#18369)
2 parents 0730334 + 96f5802 commit f7b2264

File tree

77 files changed

+63
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+63
-33
lines changed

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

+7-22
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ class BootstrappedOnlyCompilationTests {
2929
aggregateTests(
3030
compileFilesInDir("tests/bench", defaultOptions.without("-Yno-deep-subtypes")),
3131
compileFilesInDir("tests/pos-macros", defaultOptions.and("-Xcheck-macros")),
32-
compileFilesInDir("tests/pos-custom-args/semanticdb", defaultOptions.and("-Xsemanticdb")),
33-
compileDir("tests/pos-special/i7592", defaultOptions.and("-Yretain-trees")),
34-
compileDir("tests/pos-special/i11331.1", defaultOptions),
35-
compileDir("tests/pos-custom-args/i13405", defaultOptions.and("-Xfatal-warnings")),
3632
).checkCompile()
3733
}
3834

@@ -107,13 +103,8 @@ class BootstrappedOnlyCompilationTests {
107103

108104
@Test def negMacros: Unit = {
109105
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
110-
aggregateTests(
111-
compileFilesInDir("tests/neg-macros", defaultOptions.and("-Xcheck-macros")),
112-
compileFilesInDir("tests/neg-inlines-strict", defaultOptions.and("-source", "future")),
113-
compileFile("tests/pos-macros/i9570.scala", defaultOptions.and("-Xfatal-warnings")),
114-
compileFile("tests/pos-macros/macro-deprecation.scala", defaultOptions.and("-Xfatal-warnings", "-deprecation")),
115-
compileFile("tests/pos-macros/macro-experimental.scala", defaultOptions.and("-Yno-experimental")),
116-
).checkExpectedErrors()
106+
compileFilesInDir("tests/neg-macros", defaultOptions.and("-Xcheck-macros"))
107+
.checkExpectedErrors()
117108
}
118109

119110
@Test def negWithCompiler: Unit = {
@@ -128,26 +119,20 @@ class BootstrappedOnlyCompilationTests {
128119

129120
@Test def runMacros: Unit = {
130121
implicit val testGroup: TestGroup = TestGroup("runMacros")
131-
aggregateTests(
132-
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros")),
133-
compileFilesInDir("tests/run-custom-args/Yretain-trees", defaultOptions and "-Yretain-trees"),
134-
compileFilesInDir("tests/run-custom-args/Yread-comments", defaultOptions and "-Yread-docs"),
135-
compileFilesInDir("tests/run-custom-args/run-macros-erased", defaultOptions.and("-language:experimental.erasedDefinitions").and("-Xcheck-macros")),
136-
compileDir("tests/run-custom-args/Xmacro-settings/simple", defaultOptions.and("-Xmacro-settings:one,two,three")),
137-
compileDir("tests/run-custom-args/Xmacro-settings/compileTimeEnv", defaultOptions.and("-Xmacro-settings:a,b=1,c.b.a=x.y.z=1,myLogger.level=INFO")),
138-
)
139-
}.checkRuns()
122+
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros"))
123+
.checkRuns()
124+
}
140125

141126
@Test def runWithCompiler: Unit = {
142127
implicit val testGroup: TestGroup = TestGroup("runWithCompiler")
143128
val basicTests = List(
144129
compileFilesInDir("tests/run-with-compiler", withCompilerOptions),
145130
compileFilesInDir("tests/run-staging", withStagingOptions),
146-
compileFilesInDir("tests/run-custom-args/tasty-inspector", withTastyInspectorOptions)
131+
compileFilesInDir("tests/run-tasty-inspector", withTastyInspectorOptions)
147132
)
148133
val tests =
149134
if scala.util.Properties.isWin then basicTests
150-
else compileDir("tests/run-custom-args/tasty-interpreter", withTastyInspectorOptions) :: basicTests
135+
else compileDir("tests/old-tasty-interpreter-prototype", withTastyInspectorOptions) :: basicTests
151136

152137
aggregateTests(tests: _*).checkRuns()
153138
}

tests/pos-macros/i9570.scala renamed to tests/neg-macros/i9570.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xfatal-warnings
2+
13
import scala.quoted.*
24

35
object Macros {

tests/pos-macros/macro-deprecation.scala renamed to tests/neg-macros/macro-deprecation.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xfatal-warnings -deprecation
2+
13
import scala.quoted.*
24

35
inline def f = ${ impl } // error

tests/pos-macros/macro-experimental.scala renamed to tests/neg-macros/macro-experimental.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yno-experimental
2+
13
import scala.quoted.*
24
import scala.annotation.experimental
35

tests/neg-inlines-strict/i9685bis.check renamed to tests/neg/i9685bis.check

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-- [E008] Not Found Error: tests/neg-inlines-strict/i9685bis.scala:23:4 ------------------------------------------------
2-
23 | 1.asdf // error
1+
-- [E008] Not Found Error: tests/neg/i9685bis.scala:25:4 ---------------------------------------------------------------
2+
25 | 1.asdf // error
33
| ^^^^^^
44
| value asdf is not a member of Int, but could be made available as an extension method.
55
|

tests/neg-inlines-strict/i9685bis.scala renamed to tests/neg/i9685bis.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -source future
2+
13
package foo
24

35
import scala.language.implicitConversions

tests/pos-custom-args/i13405/Test.scala

-1
This file was deleted.

tests/pos-macros/i13405/Test.scala

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// scalac: -Xfatal-warnings
2+
3+
@main def main: Unit = hh()

tests/pos-special/i7592/Test_2.scala renamed to tests/pos-macros/i7592/Test_2.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yretain-trees
2+
13
def return1 = 1
24

35
def testReturn1 = {

tests/pos-custom-args/semanticdb/inline-unapply/App_2.scala renamed to tests/pos-macros/semanticdb-inline-unapply/App_2.scala

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalac: -Xsemanticdb
12

23
object Test {
34
def main(args: Array[String]): Unit = {

tests/pos-custom-args/semanticdb/inline-unapply/Macro_1.scala renamed to tests/pos-macros/semanticdb-inline-unapply/Macro_1.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xsemanticdb
2+
13
import scala.quoted.*
24

35
object Succ:

tests/pos-custom-args/semanticdb/macro-pos/example_1.scala renamed to tests/pos-macros/semanticdb-macro-pos/example_1.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xsemanticdb
2+
13
import quoted.*
24

35
object CodeImpl {

tests/pos-custom-args/semanticdb/macro-pos/example_2.scala renamed to tests/pos-macros/semanticdb-macro-pos/example_2.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xsemanticdb
2+
13
import quoted.*
24

35
object TestImpl {

tests/pos-custom-args/semanticdb/macro-pos/example_3.scala renamed to tests/pos-macros/semanticdb-macro-pos/example_3.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xsemanticdb
2+
13
object Test {
24

35
def test = TestImpl.fun("")

tests/run-custom-args/Xmacro-settings/compileTimeEnv/Test.scala renamed to tests/run-macros/Xmacro-settings-compileTimeEnv/Test.scala

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xmacro-settings:a,b=1,c.b.a=x.y.z=1,myLogger.level=INFO
2+
13
import scala.compiletime.*
24

35
object Test {
@@ -16,10 +18,10 @@ object Test {
1618
}
1719

1820
def runBasic(): Unit = {
19-
printEnv("a")
20-
printEnv("b")
21-
printEnv("c.b.a")
22-
printEnv("wat")
21+
printEnv("a")
22+
printEnv("b")
23+
printEnv("c.b.a")
24+
printEnv("wat")
2325
}
2426

2527
inline def printEnv(inline k: String): Unit =

tests/run-custom-args/Xmacro-settings/simple/Test.scala renamed to tests/run-macros/Xmacro-settings-simple/Test.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xmacro-settings:one,two,three
2+
13
import x.*
24

35
object Test {

tests/run-custom-args/Yread-comments/i12351/Test_2.scala renamed to tests/run-macros/i12351/Test_2.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yread-docs
2+
13
@main def Test(): Unit = {
24
println(getDocString[Data])
35
assert(getDocString[Data].nonEmpty)

tests/run-custom-args/Yread-comments/i12352/Main.scala renamed to tests/run-macros/i12352/Main.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yread-docs
2+
13
@main def Test(): Unit = {
24
val res = getDocString[scala.quoted.Quotes]
35
println(res)

tests/run-custom-args/run-macros-erased/i17105/Macro_1.scala renamed to tests/run-macros/i17105b/Macro_1.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import scala.language.experimental.erasedDefinitions
2+
13
import scala.quoted.*
24

35
inline def testExpr(inline body: Any) = ${ testExprImpl('body) }

tests/run-custom-args/run-macros-erased/i17105/Test_2.scala renamed to tests/run-macros/i17105b/Test_2.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import scala.language.experimental.erasedDefinitions
2+
13
@main def Test: Unit =
24
println("case erased: " + testExpr { def erasedfn1(erased x: String) = "placeholder"; erasedfn1("arg1")})
35
println("case erased nested: " + testExpr {

tests/run-custom-args/run-macros-erased/macro-erased/1.scala renamed to tests/run-macros/macro-erased/Macro_1.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import scala.language.experimental.erasedDefinitions
2+
13
import scala.quoted.*
24

35
object Macro {

tests/run-custom-args/run-macros-erased/reflect-isFunctionType/test_2.scala renamed to tests/run-macros/reflect-isFunctionType/test_2.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import scala.language.experimental.erasedDefinitions
2+
13
trait Box {
24
type T
35
}

tests/run-macros/tasty-definitions-1/quoted_2.scala

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalac: -Yretain-trees
12

23
object Test {
34
def main(args: Array[String]): Unit = {

tests/run-custom-args/Yretain-trees/tasty-definitions-2/Test_2.scala renamed to tests/run-macros/tasty-definitions-2/Test_2.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yretain-trees
2+
13
object Test {
24
def main(args: Array[String]): Unit = {
35
println(Foo.inspectBody(Foo.foo))

tests/run-custom-args/Yretain-trees/tasty-definitions-3/Test_2.scala renamed to tests/run-macros/tasty-definitions-3/Test_2.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yretain-trees
2+
13
object Test {
24

35
def main(args: Array[String]): Unit = {

tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_2.scala renamed to tests/run-macros/tasty-extractors-owners/quoted_2.scala

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalac: -Yretain-trees
12

23
import Macros.*
34

tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_2.scala renamed to tests/run-macros/tasty-load-tree-1/quoted_2.scala

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalac: -Yretain-trees
12

23
object Test {
34
def main(args: Array[String]): Unit = {

tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_2.scala renamed to tests/run-macros/tasty-load-tree-2/quoted_2.scala

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalac: -Yretain-trees
12

23
object Test {
34
def main(args: Array[String]): Unit = {

tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala renamed to tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ val experimentalDefinitionInLibrary = Set(
126126
|Found @experimental definition in library not listed:
127127
|${missingFromList.toSeq.sorted.mkString("\n")}
128128
|
129-
|If added new experimental definitions to the library, add them to the list in tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala
129+
|If added new experimental definitions to the library, add them to the list in tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala
130130
|
131-
|Test only: sbt "scala3-bootstrapped/testCompilation tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala"
131+
|Test only: sbt "scala3-bootstrapped/testCompilation tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala"
132132
|""".stripMargin
133133
)
134134
assert(missingInLibrary.isEmpty,
@@ -137,9 +137,9 @@ val experimentalDefinitionInLibrary = Set(
137137
|Listed @experimental definition was not found in the library
138138
|${missingInLibrary.toSeq.sorted.mkString("\n")}
139139
|
140-
|If experimental definition was removed or stabilized, remove from the list in tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala
140+
|If experimental definition was removed or stabilized, remove from the list in tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala
141141
|
142-
|Test only: sbt "scala3-bootstrapped/testCompilation tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala"
142+
|Test only: sbt "scala3-bootstrapped/testCompilation tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala"
143143
|""".stripMargin
144144
)
145145
}

0 commit comments

Comments
 (0)