Skip to content

Simplify macro tests with custom args #18369

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
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ class BootstrappedOnlyCompilationTests {
aggregateTests(
compileFilesInDir("tests/bench", defaultOptions.without("-Yno-deep-subtypes")),
compileFilesInDir("tests/pos-macros", defaultOptions.and("-Xcheck-macros")),
compileFilesInDir("tests/pos-custom-args/semanticdb", defaultOptions.and("-Xsemanticdb")),
compileDir("tests/pos-special/i7592", defaultOptions.and("-Yretain-trees")),
compileDir("tests/pos-special/i11331.1", defaultOptions),
compileDir("tests/pos-custom-args/i13405", defaultOptions.and("-Xfatal-warnings")),
).checkCompile()
}

Expand Down Expand Up @@ -107,13 +103,8 @@ class BootstrappedOnlyCompilationTests {

@Test def negMacros: Unit = {
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
aggregateTests(
compileFilesInDir("tests/neg-macros", defaultOptions.and("-Xcheck-macros")),
compileFilesInDir("tests/neg-inlines-strict", defaultOptions.and("-source", "future")),
compileFile("tests/pos-macros/i9570.scala", defaultOptions.and("-Xfatal-warnings")),
compileFile("tests/pos-macros/macro-deprecation.scala", defaultOptions.and("-Xfatal-warnings", "-deprecation")),
compileFile("tests/pos-macros/macro-experimental.scala", defaultOptions.and("-Yno-experimental")),
).checkExpectedErrors()
compileFilesInDir("tests/neg-macros", defaultOptions.and("-Xcheck-macros"))
.checkExpectedErrors()
}

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

@Test def runMacros: Unit = {
implicit val testGroup: TestGroup = TestGroup("runMacros")
aggregateTests(
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros")),
compileFilesInDir("tests/run-custom-args/Yretain-trees", defaultOptions and "-Yretain-trees"),
compileFilesInDir("tests/run-custom-args/Yread-comments", defaultOptions and "-Yread-docs"),
compileFilesInDir("tests/run-custom-args/run-macros-erased", defaultOptions.and("-language:experimental.erasedDefinitions").and("-Xcheck-macros")),
compileDir("tests/run-custom-args/Xmacro-settings/simple", defaultOptions.and("-Xmacro-settings:one,two,three")),
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")),
)
}.checkRuns()
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros"))
.checkRuns()
}

@Test def runWithCompiler: Unit = {
implicit val testGroup: TestGroup = TestGroup("runWithCompiler")
val basicTests = List(
compileFilesInDir("tests/run-with-compiler", withCompilerOptions),
compileFilesInDir("tests/run-staging", withStagingOptions),
compileFilesInDir("tests/run-custom-args/tasty-inspector", withTastyInspectorOptions)
compileFilesInDir("tests/run-tasty-inspector", withTastyInspectorOptions)
)
val tests =
if scala.util.Properties.isWin then basicTests
else compileDir("tests/run-custom-args/tasty-interpreter", withTastyInspectorOptions) :: basicTests
else compileDir("tests/old-tasty-interpreter-prototype", withTastyInspectorOptions) :: basicTests

aggregateTests(tests: _*).checkRuns()
}
Expand Down
2 changes: 2 additions & 0 deletions tests/pos-macros/i9570.scala → tests/neg-macros/i9570.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Xfatal-warnings

import scala.quoted.*

object Macros {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Xfatal-warnings -deprecation

import scala.quoted.*

inline def f = ${ impl } // error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Yno-experimental

import scala.quoted.*
import scala.annotation.experimental

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- [E008] Not Found Error: tests/neg-inlines-strict/i9685bis.scala:23:4 ------------------------------------------------
23 | 1.asdf // error
-- [E008] Not Found Error: tests/neg/i9685bis.scala:25:4 ---------------------------------------------------------------
25 | 1.asdf // error
| ^^^^^^
| value asdf is not a member of Int, but could be made available as an extension method.
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -source future

package foo

import scala.language.implicitConversions
Expand Down
1 change: 0 additions & 1 deletion tests/pos-custom-args/i13405/Test.scala

This file was deleted.

3 changes: 3 additions & 0 deletions tests/pos-macros/i13405/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// scalac: -Xfatal-warnings

@main def main: Unit = hh()
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Yretain-trees

def return1 = 1

def testReturn1 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// scalac: -Xsemanticdb

object Test {
def main(args: Array[String]): Unit = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Xsemanticdb

import scala.quoted.*

object Succ:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Xsemanticdb

import quoted.*

object CodeImpl {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Xsemanticdb

import quoted.*

object TestImpl {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Xsemanticdb

object Test {

def test = TestImpl.fun("")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Xmacro-settings:a,b=1,c.b.a=x.y.z=1,myLogger.level=INFO

import scala.compiletime.*

object Test {
Expand All @@ -16,10 +18,10 @@ object Test {
}

def runBasic(): Unit = {
printEnv("a")
printEnv("b")
printEnv("c.b.a")
printEnv("wat")
printEnv("a")
printEnv("b")
printEnv("c.b.a")
printEnv("wat")
}

inline def printEnv(inline k: String): Unit =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Xmacro-settings:one,two,three

import x.*

object Test {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Yread-docs

@main def Test(): Unit = {
println(getDocString[Data])
assert(getDocString[Data].nonEmpty)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Yread-docs

@main def Test(): Unit = {
val res = getDocString[scala.quoted.Quotes]
println(res)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import scala.language.experimental.erasedDefinitions

import scala.quoted.*

inline def testExpr(inline body: Any) = ${ testExprImpl('body) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import scala.language.experimental.erasedDefinitions

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

import scala.quoted.*

object Macro {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import scala.language.experimental.erasedDefinitions

trait Box {
type T
}
Expand Down
1 change: 1 addition & 0 deletions tests/run-macros/tasty-definitions-1/quoted_2.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// scalac: -Yretain-trees

object Test {
def main(args: Array[String]): Unit = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Yretain-trees

object Test {
def main(args: Array[String]): Unit = {
println(Foo.inspectBody(Foo.foo))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Yretain-trees

object Test {

def main(args: Array[String]): Unit = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// scalac: -Yretain-trees

import Macros.*

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// scalac: -Yretain-trees

object Test {
def main(args: Array[String]): Unit = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// scalac: -Yretain-trees

object Test {
def main(args: Array[String]): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ val experimentalDefinitionInLibrary = Set(
|Found @experimental definition in library not listed:
|${missingFromList.toSeq.sorted.mkString("\n")}
|
|If added new experimental definitions to the library, add them to the list in tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala
|If added new experimental definitions to the library, add them to the list in tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala
|
|Test only: sbt "scala3-bootstrapped/testCompilation tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala"
|Test only: sbt "scala3-bootstrapped/testCompilation tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala"
|""".stripMargin
)
assert(missingInLibrary.isEmpty,
Expand All @@ -137,9 +137,9 @@ val experimentalDefinitionInLibrary = Set(
|Listed @experimental definition was not found in the library
|${missingInLibrary.toSeq.sorted.mkString("\n")}
|
|If experimental definition was removed or stabilized, remove from the list in tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala
|If experimental definition was removed or stabilized, remove from the list in tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala
|
|Test only: sbt "scala3-bootstrapped/testCompilation tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala"
|Test only: sbt "scala3-bootstrapped/testCompilation tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala"
|""".stripMargin
)
}
Expand Down