-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove scala2-library-tasty-tests
project
#19379
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import scala.quoted._ | ||
import scala.tasty.inspector._ | ||
|
||
import dotty.tools.io.Directory | ||
|
||
import java.io.File.pathSeparator | ||
import java.io.File.separator | ||
|
||
@main def Test: Unit = | ||
blacklistsOnlyContainsClassesThatExist() | ||
testTastyInspector() | ||
|
||
/** Test that we can load trees from TASTy */ | ||
def testTastyInspector(): Unit = | ||
loadWithTastyInspector(loadBlacklisted) | ||
|
||
def blacklistsOnlyContainsClassesThatExist() = | ||
val scalaLibTastyPathsSet = scalaLibTastyPaths.toSet | ||
assert(loadBlacklisted.diff(scalaLibTastyPathsSet).isEmpty, | ||
loadBlacklisted.diff(scalaLibTastyPathsSet).mkString( | ||
"`loadBlacklisted` contains names that are not in `scalaLibTastyPaths`: \n ", "\n ", "\n\n")) | ||
|
||
def dottyVersion = | ||
System.getProperty("java.class.path").nn.split(pathSeparator).collectFirst { | ||
case path if path.endsWith(".jar") && path.contains("scala3-library_3-") => | ||
path.split("scala3-library_3-").last.stripSuffix(".jar") | ||
}.get | ||
|
||
def scalaLibClassesPath = | ||
java.nio.file.Paths.get( | ||
s"out/bootstrap/scala2-library-bootstrapped/scala-$dottyVersion-nonbootstrapped/classes".replace("/", separator)) | ||
|
||
lazy val scalaLibTastyPaths = | ||
new Directory(scalaLibClassesPath).deepFiles | ||
.filter(_.`extension` == "tasty") | ||
.map(_.normalize.path.stripPrefix(scalaLibClassesPath.toString + separator)) | ||
.toList | ||
|
||
def loadWithTastyInspector(blacklisted: Set[String]): Unit = | ||
val inspector = new scala.tasty.inspector.Inspector { | ||
def inspect(using Quotes)(tastys: List[Tasty[quotes.type]]): Unit = | ||
for tasty <- tastys do | ||
tasty.ast.show(using quotes.reflect.Printer.TreeStructure) // Check that we can traverse the full tree | ||
() | ||
} | ||
val tastyFiles = scalaLibTastyPaths.filterNot(blacklisted) | ||
val isSuccess = TastyInspector.inspectTastyFiles(tastyFiles.map(x => scalaLibClassesPath.resolve(x).toString))(inspector) | ||
assert(isSuccess, "Errors reported while loading from TASTy") | ||
|
||
/** Set of tasty files that cannot be loaded from TASTy */ | ||
def loadBlacklisted = Set[String]( | ||
// No issues :) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import dotty.tools.io.Directory | ||
import dotty.tools.dotc.util.ClasspathFromClassloader | ||
|
||
import java.io.File.pathSeparator | ||
import java.io.File.separator | ||
|
||
@main def Test: Unit = | ||
blacklistsOnlyContainsClassesThatExist() | ||
// FIXME this test does not work on JDK8 | ||
// Caused by: dotty.tools.dotc.core.TypeError$$anon$1: package scala.quoted.runtime.Expr does not have a member method quote | ||
if System.getProperty("java.specification.version") != "1.8" then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a possible bug when running the from-TASTy compiler on JDK8 or with the test itself. I will open an issue to investigate this further. Note that the Windows tests found a bug in |
||
compileFromTastyInJar(compileBlacklisted) | ||
|
||
def blacklistsOnlyContainsClassesThatExist() = | ||
val scalaLibTastyPathsSet = scalaLibTastyPaths.toSet | ||
assert(compileBlacklisted.diff(scalaLibTastyPathsSet).isEmpty, | ||
compileBlacklisted.diff(scalaLibTastyPathsSet).mkString( | ||
"`loadBlacklisted` contains names that are not in `scalaLibTastyPaths`: \n ", "\n ", "\n\n")) | ||
|
||
def dottyVersion = | ||
System.getProperty("java.class.path").nn.split(pathSeparator).collectFirst { | ||
case path if path.endsWith(".jar") && path.contains("scala3-library_3-") => | ||
path.split("scala3-library_3-").last.stripSuffix(".jar") | ||
}.get | ||
|
||
def scalaLibJarPath = | ||
s"out${separator}bootstrap${separator}scala2-library-tasty${separator}scala-$dottyVersion-nonbootstrapped${separator}scala2-library-tasty-experimental_3-$dottyVersion.jar" | ||
|
||
def scalaLibClassesPath = | ||
java.nio.file.Paths.get( | ||
s"out${separator}bootstrap${separator}scala2-library-bootstrapped${separator}scala-$dottyVersion-nonbootstrapped${separator}classes") | ||
|
||
lazy val scalaLibTastyPaths = | ||
new Directory(scalaLibClassesPath).deepFiles | ||
.filter(_.`extension` == "tasty") | ||
.map(_.normalize.path.stripPrefix(scalaLibClassesPath.toString + separator)) | ||
.toList | ||
|
||
def compileFromTastyInJar(blacklisted: Set[String]): Unit = { | ||
val driver = new dotty.tools.dotc.Driver | ||
val yFromTastyBlacklist = | ||
blacklisted.mkString("-Yfrom-tasty-ignore-list:", ",", "") | ||
val args = Array( | ||
"-classpath", ClasspathFromClassloader(getClass.getClassLoader), | ||
"-from-tasty", | ||
"-d", s"out${separator}scala2-library-from-tasty-jar-test-output.jar", | ||
"-nowarn", | ||
yFromTastyBlacklist, | ||
scalaLibJarPath, | ||
) | ||
val reporter = driver.process(args) | ||
assert(reporter.errorCount == 0, "Errors while re-compiling") | ||
} | ||
|
||
/** Set of tasty files that cannot be recompiled from TASTy */ | ||
def compileBlacklisted = Set[String]( | ||
// See #10048 | ||
// failed: java.lang.AssertionError: assertion failed: class Boolean | ||
// at dotty.tools.backend.jvm.BCodeHelpers$BCInnerClassGen.assertClassNotArrayNotPrimitive(BCodeHelpers.scala:247) | ||
// at dotty.tools.backend.jvm.BCodeHelpers$BCInnerClassGen.getClassBTypeAndRegisterInnerClass(BCodeHelpers.scala:265) | ||
// at dotty.tools.backend.jvm.BCodeHelpers$BCInnerClassGen.getClassBTypeAndRegisterInnerClass$(BCodeHelpers.scala:210) | ||
// at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.getClassBTypeAndRegisterInnerClass(BCodeSkelBuilder.scala:62) | ||
// at dotty.tools.backend.jvm.BCodeHelpers$BCInnerClassGen.internalName(BCodeHelpers.scala:237) | ||
s"scala${separator}Array.tasty", | ||
s"scala${separator}Boolean.tasty", | ||
s"scala${separator}Byte.tasty", | ||
s"scala${separator}Char.tasty", | ||
s"scala${separator}Double.tasty", | ||
s"scala${separator}Float.tasty", | ||
s"scala${separator}Int.tasty", | ||
s"scala${separator}Long.tasty", | ||
s"scala${separator}Short.tasty", | ||
s"scala${separator}Unit.tasty", | ||
) |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems ok, but perhaps
fromTastyIgnoreList
should accept binary names (.
separator, no file extension) rather than paths?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. Out of scope for this PR.