Skip to content

Commit 381e32e

Browse files
committed
Use --skip and --compliant semantics flags inside source files.
1 parent 26be60a commit 381e32e

File tree

274 files changed

+611
-121
lines changed

Some content is hidden

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

274 files changed

+611
-121
lines changed

compiler/test/dotty/tools/utils.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,16 @@ end assertThrows
5252

5353
/** Famous tool names in the ecosystem. Used for tool args in test files. */
5454
enum ToolName:
55-
case Scala, Scalac, Java, Javac, Test
55+
case Scala, Scalac, Java, Javac, ScalaJS, Test
5656
object ToolName:
5757
def named(s: String): ToolName = values.find(_.toString.equalsIgnoreCase(s)).getOrElse(throw IllegalArgumentException(s))
5858

59+
type ToolArgs = Map[ToolName, List[String]]
60+
5961
/** Take a prefix of each file, extract tool args, parse, and combine.
6062
* Arg parsing respects quotation marks. Result is a map from ToolName to the combined tokens.
6163
*/
62-
def toolArgsFor(files: List[JPath], charset: Charset = UTF_8): Map[ToolName, List[String]] =
64+
def toolArgsFor(files: List[JPath], charset: Charset = UTF_8): ToolArgs =
6365
files.foldLeft(Map.empty[ToolName, List[String]]) { (res, path) =>
6466
val toolargs = toolArgsParse(resource(Files.lines(path, charset))(_.limit(10).toScala(List)))
6567
toolargs.foldLeft(res) {

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
9696
self.copy(flags = flags.without(flags1: _*))
9797
}
9898

99+
lazy val allToolArgs: ToolArgs =
100+
toolArgsFor(sourceFiles.toList.map(_.toPath), getCharsetFromEncodingOpt(flags))
101+
99102
/** Generate the instructions to redo the test from the command line */
100103
def buildInstructions(errors: Int, warnings: Int): String = {
101104
val sb = new StringBuilder
@@ -199,6 +202,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
199202
def sourceFiles = compilationGroups.map(_._2).flatten.toArray
200203
}
201204

205+
protected def shouldSkipTestSource(testSource: TestSource): Boolean =
206+
false
207+
202208
private trait CompilationLogic { this: Test =>
203209
def suppressErrors = false
204210

@@ -344,13 +350,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
344350

345351
/** All testSources left after filtering out */
346352
private val filteredSources =
347-
if (testFilter.isEmpty) testSources
348-
else testSources.filter {
349-
case JointCompilationSource(_, files, _, _, _, _) =>
350-
testFilter.exists(filter => files.exists(file => file.getPath.contains(filter)))
351-
case SeparateCompilationSource(_, dir, _, _) =>
352-
testFilter.exists(dir.getPath.contains)
353-
}
353+
val filteredByName =
354+
if (testFilter.isEmpty) testSources
355+
else testSources.filter {
356+
case JointCompilationSource(_, files, _, _, _, _) =>
357+
testFilter.exists(filter => files.exists(file => file.getPath.contains(filter)))
358+
case SeparateCompilationSource(_, dir, _, _) =>
359+
testFilter.exists(dir.getPath.contains)
360+
}
361+
filteredByName.filterNot(shouldSkipTestSource(_))
354362

355363
/** Total amount of test sources being compiled by this test */
356364
val sourceCount = filteredSources.length
@@ -739,7 +747,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
739747

740748
private def verifyOutput(checkFile: Option[JFile], dir: JFile, testSource: TestSource, warnings: Int, reporters: Seq[TestReporter], logger: LoggedRunnable) = {
741749
if (Properties.testsNoRun) addNoRunWarning()
742-
else runMain(testSource.runClassPath, testSource.flags) match {
750+
else runMain(testSource.runClassPath, testSource.allToolArgs) match {
743751
case Success(output) => checkFile match {
744752
case Some(file) if file.exists => diffTest(testSource, file, output.linesIterator.toList, reporters, logger)
745753
case _ =>

compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ trait RunnerOrchestration {
4848
def safeMode: Boolean
4949

5050
/** Running a `Test` class's main method from the specified `dir` */
51-
def runMain(classPath: String, flags: TestFlags)(implicit summaryReport: SummaryReporting): Status =
51+
def runMain(classPath: String, toolArgs: ToolArgs)(implicit summaryReport: SummaryReporting): Status =
5252
monitor.runMain(classPath)
5353

5454
/** Kill all processes */

compiler/test/dotty/tools/vulpix/TestFlags.scala

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,22 @@ final case class TestFlags(
88
defaultClassPath: String,
99
runClassPath: String, // class path that is used when running `run` tests (not compiling)
1010
options: Array[String],
11-
javacOptions: Array[String],
12-
scalaJSCompliantSemantics: Boolean) {
11+
javacOptions: Array[String]) {
1312

1413
def and(flags: String*): TestFlags =
15-
TestFlags(defaultClassPath, runClassPath, options ++ flags, javacOptions, scalaJSCompliantSemantics)
14+
TestFlags(defaultClassPath, runClassPath, options ++ flags, javacOptions)
1615

1716
def without(flags: String*): TestFlags =
18-
TestFlags(defaultClassPath, runClassPath, options diff flags, javacOptions, scalaJSCompliantSemantics)
17+
TestFlags(defaultClassPath, runClassPath, options diff flags, javacOptions)
1918

2019
def withClasspath(classPath: String): TestFlags =
21-
TestFlags(s"$defaultClassPath${JFile.pathSeparator}$classPath", runClassPath, options, javacOptions, scalaJSCompliantSemantics)
20+
TestFlags(s"$defaultClassPath${JFile.pathSeparator}$classPath", runClassPath, options, javacOptions)
2221

2322
def withRunClasspath(classPath: String): TestFlags =
24-
TestFlags(defaultClassPath, s"$runClassPath${JFile.pathSeparator}$classPath", options, javacOptions, scalaJSCompliantSemantics)
23+
TestFlags(defaultClassPath, s"$runClassPath${JFile.pathSeparator}$classPath", options, javacOptions)
2524

2625
def withJavacOnlyOptions(flags: String*): TestFlags =
27-
TestFlags(defaultClassPath, runClassPath, options, javacOptions ++ flags, scalaJSCompliantSemantics)
28-
29-
def withScalaJSCompliantSemantics(compliantSemantics: Boolean): TestFlags =
30-
TestFlags(defaultClassPath, runClassPath, options, javacOptions, compliantSemantics)
26+
TestFlags(defaultClassPath, runClassPath, options, javacOptions ++ flags)
3127

3228
def all: Array[String] = Array("-classpath", defaultClassPath) ++ options
3329

@@ -58,6 +54,5 @@ final case class TestFlags(
5854
}
5955

6056
object TestFlags {
61-
def apply(classPath: String, flags: Array[String]): TestFlags =
62-
TestFlags(classPath, classPath, flags, Array.empty, false)
57+
def apply(classPath: String, flags: Array[String]): TestFlags = TestFlags(classPath, classPath, flags, Array.empty)
6358
}

sjs-compiler-tests/test/scala/dotty/tools/dotc/ScalaJSCompilationTests.scala

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@ class ScalaJSCompilationTests extends ParallelTesting {
3535

3636
// Run tests -----------------------------------------------------------------
3737

38-
override def runMain(classPath: String, flags: TestFlags)(implicit summaryReport: SummaryReporting): Status =
38+
override protected def shouldSkipTestSource(testSource: TestSource): Boolean =
39+
testSource.allToolArgs.get(ToolName.ScalaJS).exists(_.contains("--skip"))
40+
41+
override def runMain(classPath: String, toolArgs: ToolArgs)(implicit summaryReport: SummaryReporting): Status =
3942
import scala.concurrent.ExecutionContext.Implicits.global
4043

44+
val scalaJSOptions = toolArgs.getOrElse(ToolName.ScalaJS, Nil)
45+
4146
try
42-
val sjsCode = ScalaJSLink.link(classPath, flags.scalaJSCompliantSemantics)
47+
val useCompliantSemantics = scalaJSOptions.contains("--compliant-semantics")
48+
val sjsCode = ScalaJSLink.link(classPath, useCompliantSemantics)
4349
JSRun.runJSCode(sjsCode)
4450
catch
4551
case t: Exception =>
@@ -52,7 +58,9 @@ class ScalaJSCompilationTests extends ParallelTesting {
5258
implicit val testGroup: TestGroup = TestGroup("runScalaJS")
5359
aggregateTests(
5460
compileFilesInDir("tests/run", scalaJSOptions),
55-
compileFilesInDir("tests/run-with-compliant-semantics", scalaJSOptions.withScalaJSCompliantSemantics(true)),
61+
compileFilesInDir("tests/run-with-compliant-semantics", scalaJSOptions),
62+
compileFilesInDir("tests/run-pending-js", scalaJSOptions),
63+
compileFilesInDir("tests/run-jvm-only", scalaJSOptions),
5664
).checkRuns()
5765
}
5866
}

tests/run-jvm-only/10838/Test.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
object Test {
24
def main(args: Array[String]): Unit = {
35
val a = new A

tests/run-jvm-only/Course-2002-01.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Programmation IV - 2002 - Week 01
35
//############################################################################

tests/run-jvm-only/Course-2002-02.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Programmation IV - 2002 - Week 02
35
//############################################################################

tests/run-jvm-only/Course-2002-03.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Programmation IV - 2002 - Week 03
35
//############################################################################

tests/run-jvm-only/Course-2002-04.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Programmation IV - 2002 - Week 04
35
//############################################################################

tests/run-jvm-only/Course-2002-05.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Programmation IV - 2002 - Week 05
35
//############################################################################

tests/run-jvm-only/Course-2002-06.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Programmation IV - 2002 - Week 06
35
//############################################################################

tests/run-jvm-only/Course-2002-07.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Programmation IV - 2002 - Week 07
35
//############################################################################

tests/run-jvm-only/Course-2002-08.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Programmation IV - 2002 - Week 08
35
//############################################################################

tests/run-jvm-only/Course-2002-09.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Programmation IV - 2002 - Week 09
35
//############################################################################

tests/run-jvm-only/Course-2002-10.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Programmation IV - 2002 - Week 10
35
//############################################################################

tests/run-jvm-only/Course-2002-13.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Programmation IV - 2002 - Week 13
35
//############################################################################

tests/run-jvm-only/arrays-from-java/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
object Test {
24
def main(args: Array[String]): Unit =
35
C_2.test()

tests/run-jvm-only/assert-stack.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
// scalajs: --skip
22

33
object Test {
44

tests/run-jvm-only/beans/Test_4.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
// scalajs: --skip
2+
13
object Test:
24
def main(args: Array[String]) =
35
val a = JavaTest().run()
4-
println(a.mutableOneWithLongName)
6+
println(a.mutableOneWithLongName)

tests/run-jvm-only/capturing.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
class MT(sf: MT => String) {
24
// `s` is retained as a field, but `sf` should not be.
35
val s = sf(this)

tests/run-jvm-only/case-class-serializable.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
case class Foo(s: String)
24

35
object Test {

tests/run-jvm-only/classof.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
class ValueClass(val i: Integer) extends AnyVal
24
class SomeClass
35

tests/run-jvm-only/deadlock.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
// from https://github.com/rickynils/scalacheck/issues/290
24
import scala.concurrent.*
35
import scala.concurrent.duration.*

tests/run-jvm-only/defaults-serizaliable-with-forwarders.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, ObjectOutputStream}
24

35
trait T1 extends Serializable {

tests/run-jvm-only/enum-efficient-collections.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
enum Day extends java.lang.Enum[Day] {
24
case MONDAY, TUESDAY, SATURDAY, WEDNESDAY
35
}

tests/run-jvm-only/enum-java/Test.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
public class Test {
24
public static void log(String x) { System.out.println(x); }
35
public static void check(Boolean p, String message) {

tests/run-jvm-only/enum-values.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
import reflect.Selectable.reflectiveSelectable
24
import deriving.Mirror
35

tests/run-jvm-only/enums-serialization-compat.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
import java.io.*
24
import scala.util.Using
35

tests/run-jvm-only/enums.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
//############################################################################
24
// Enumerations
35
//############################################################################

tests/run-jvm-only/erased-inline-vals.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalajs: --skip
12

23
abstract class A:
34
def x: Int

tests/run-jvm-only/exceptions-2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
/*
24
* Try exception handling and finally blocks.
35
*/

tests/run-jvm-only/exceptions-nest.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
object Test extends App {
24

35
println(test1)

tests/run-jvm-only/forwarder-java-package-private/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
package scalapackage:
24
object Foo extends javapackage.Base_1
35
end scalapackage

tests/run-jvm-only/forwarder.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
class Foo
24
object Foo extends Bar
35

tests/run-jvm-only/future-flatmap-exec-count.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
import scala.concurrent.*
24
import java.util.concurrent.atomic.AtomicInteger
35

tests/run-jvm-only/getclass.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
class ValueClass(val i: Integer) extends AnyVal
24
class SomeClass
35

tests/run-jvm-only/hashhash.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
object Test {
24
def confirmSame(x: Any) = assert(x.## == x.hashCode, "%s.## != %s.hashCode".format(x, x))
35
def confirmDifferent(x: Any) = assert(x.## != x.hashCode, "%s.## == %s.hashCode (but should not)".format(x, x))

tests/run-jvm-only/i10884/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
object Exporter:
24
export JavaExporter_1._
35

tests/run-jvm-only/i11114.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
@main def Test() =
24
println((1, 1).getClass)
35
println(Tuple2.apply(1, 1).getClass)

tests/run-jvm-only/i11367.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
trait NoOuter:
24
val outerFields = getClass.getDeclaredFields.filter(_.getName.contains("$outer"))
35
if outerFields.nonEmpty then println(s"$getClass has outer fields")

tests/run-jvm-only/i11486/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
import java.lang.reflect.Executable
24

35
case class Tested(foo: Int, bar: String, baz: Double):

tests/run-jvm-only/i12086/Test_3.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
object Test {
24
def main(args: Array[String]): Unit = {
35
val c = new C

tests/run-jvm-only/i12204/Test_3.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
object Test {
24
def main(args: Array[String]): Unit = {
35
B_2.test()

tests/run-jvm-only/i12753/Test.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalajs: --skip
2+
13
public class Test {
24
public static void s(Object s) {
35
System.out.println(s);

0 commit comments

Comments
 (0)