Skip to content

Commit d594863

Browse files
committed
compile javacp files as part of expect tests
1 parent f02321a commit d594863

27 files changed

+18
-3
lines changed

compiler/test/dotty/tools/dotc/semanticdb/SemanticdbTests.scala

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import scala.util.control.NonFatal
1111
import scala.collection.mutable
1212
import scala.jdk.CollectionConverters._
1313

14+
import javax.tools.ToolProvider
15+
1416
import org.junit.Assert._
1517
import org.junit.Test
1618
import org.junit.experimental.categories.Category
@@ -25,11 +27,12 @@ import dotty.tools.dotc.util.SourceFile
2527

2628
@Category(Array(classOf[BootstrappedOnlyTests]))
2729
class SemanticdbTests with
30+
val javaFile = FileSystems.getDefault.getPathMatcher("glob:**.java")
2831
val scalaFile = FileSystems.getDefault.getPathMatcher("glob:**.scala")
2932
val expectFile = FileSystems.getDefault.getPathMatcher("glob:**.expect.scala")
30-
// val semanticdbFile = FileSystems.getDefault.getPathMatcher("glob:**.scala.semanticdb")
3133
val rootSrc = Paths.get(System.getProperty("dotty.tools.dotc.semanticdb.test"))
3234
val expectSrc = rootSrc.resolve("expect")
35+
val javaRoot = rootSrc.resolve("javacp")
3336
val metacExpectFile = rootSrc.resolve("metac.expect")
3437

3538
@Category(Array(classOf[dotty.SlowTests]))
@@ -87,8 +90,20 @@ class SemanticdbTests with
8790
require(files.nonEmpty, s"No input files! $expectSrc")
8891
files.toList
8992

93+
def javaFiles(): List[Path] =
94+
val ls = Files.walk(javaRoot)
95+
val files =
96+
try ls.filter(p => javaFile.matches(p)).collect(Collectors.toList).asScala
97+
finally ls.close()
98+
require(files.nonEmpty, s"No input files! $expectSrc")
99+
files.toList
100+
90101
def generateSemanticdb(): Path =
91102
val target = Files.createTempDirectory("semanticdb")
103+
val javaArgs = Array("-d", target.toString) ++ javaFiles().map(_.toString)
104+
val javac = ToolProvider.getSystemJavaCompiler
105+
val exitJava = javac.run(null, null, null, javaArgs:_*)
106+
assert(exitJava == 0, "java compiler has errors")
92107
val args = Array(
93108
"-Ysemanticdb",
94109
"-d", target.toString,
@@ -97,7 +112,8 @@ class SemanticdbTests with
97112
// "-Ydebug-flags",
98113
// "-Xprint:extractSemanticDB",
99114
"-sourceroot", expectSrc.toString,
100-
"-usejavacp",
115+
"-classpath", target.toString,
116+
"-usejavacp"
101117
) ++ inputFiles().map(_.toString)
102118
val exit = Main.process(args)
103119
assertFalse(s"dotc errors: ${exit.errorCount}", exit.hasErrors)

project/Build.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ object Build {
271271
// Settings used when compiling dotty with a non-bootstrapped dotty
272272
lazy val commonBootstrappedSettings = commonDottySettings ++ Seq(
273273
unmanagedSourceDirectories in Compile += baseDirectory.value / "src-bootstrapped",
274-
unmanagedSourceDirectories in Test += baseDirectory.value / "test-bootstrapped",
275274

276275
version := dottyVersion,
277276
scalaVersion := dottyNonBootstrappedVersion,

0 commit comments

Comments
 (0)