Skip to content

Simplify tests with custom args in CompilationTests #18376

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 1 commit into from
Aug 15, 2023
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
59 changes: 0 additions & 59 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,12 @@ class CompilationTests {
compileFilesInDir("tests/new", defaultOptions.and("-source", "3.2")), // just to see whether 3.2 works
compileFilesInDir("tests/pos-scala2", scala2CompatMode),
compileFilesInDir("tests/pos-custom-args/captures", defaultOptions.and("-language:experimental.captureChecking")),
compileFilesInDir("tests/pos-custom-args/erased", defaultOptions.and("-language:experimental.erasedDefinitions")),
compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init")),
// Run tests for legacy lazy vals
compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)),
compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes),
compileFilesInDir("tests/pos-custom-args/no-experimental", defaultOptions.and("-Yno-experimental")),
compileFilesInDir("tests/pos-custom-args/strict", defaultOptions.and("-source", "future", "-deprecation", "-Xfatal-warnings")),
compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")),
compileDir("tests/pos-special/stdlib", defaultOptions),
compileFile(
// succeeds despite -Xfatal-warnings because of -nowarn
"tests/neg-custom-args/fatal-warnings/xfatalWarnings.scala",
defaultOptions.and("-nowarn", "-Xfatal-warnings")
),
compileFile("tests/pos-special/typeclass-scaling.scala", defaultOptions.and("-Xmax-inlines", "40")),
compileFile("tests/pos-special/i7575.scala", defaultOptions.andLanguageFeature("dynamics")),
compileFile("tests/pos-special/kind-projector.scala", defaultOptions.and("-Ykind-projector")),
compileFile("tests/pos-special/kind-projector-underscores.scala", defaultOptions.and("-Ykind-projector:underscores")),
compileFile("tests/run/i5606.scala", defaultOptions.and("-Yretain-trees")),
compileFile("tests/pos-custom-args/i8875.scala", defaultOptions.and("-Xprint:getters")),
compileFile("tests/pos-custom-args/i9267.scala", defaultOptions.and("-Ystop-after:erasure")),
compileFile("tests/pos-special/extend-java-enum.scala", defaultOptions.and("-source", "3.0-migration")),
compileFile("tests/pos-custom-args/help.scala", defaultOptions.and("-help", "-V", "-W", "-X", "-Y")),
compileFile("tests/pos-custom-args/i13044.scala", defaultOptions.and("-Xmax-inlines:33")),
compileFile("tests/pos-custom-args/jdk-8-app.scala", defaultOptions.and("-release:8"))
)

if scala.util.Properties.isJavaAtLeast("16") then
Expand Down Expand Up @@ -142,29 +123,14 @@ class CompilationTests {
compileFilesInDir("tests/neg", defaultOptions),
compileFilesInDir("tests/neg-tailcall", defaultOptions),
compileFilesInDir("tests/neg-strict", defaultOptions.and("-source", "future", "-deprecation", "-Xfatal-warnings")),
compileFilesInDir("tests/neg-no-kind-polymorphism", defaultOptions and "-Yno-kind-polymorphism"),
compileFilesInDir("tests/neg-custom-args/deprecation", defaultOptions.and("-Xfatal-warnings", "-deprecation")),
compileFilesInDir("tests/neg-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")),
compileFilesInDir("tests/neg-custom-args/nowarn", defaultOptions.and("-deprecation", "-Wunused:nowarn", "-Wconf:msg=@nowarn annotation does not suppress any warnings:e")),
compileFilesInDir("tests/neg-custom-args/erased", defaultOptions.and("-language:experimental.erasedDefinitions")),
compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings),
compileFilesInDir("tests/neg-custom-args/allow-deep-subtypes", allowDeepSubtypes),
compileFilesInDir("tests/neg-custom-args/feature", defaultOptions.and("-Xfatal-warnings", "-feature")),
compileFilesInDir("tests/neg-custom-args/no-experimental", defaultOptions.and("-Yno-experimental")),
compileFilesInDir("tests/neg-custom-args/captures", defaultOptions.and("-language:experimental.captureChecking")),
compileFilesInDir("tests/neg-custom-args/explain", defaultOptions.and("-explain")),
compileFile("tests/neg-custom-args/avoid-warn-deprecation.scala", defaultOptions.and("-Xfatal-warnings", "-feature")),
compileFile("tests/neg-custom-args/i3246.scala", scala2CompatMode),
compileFile("tests/neg-custom-args/overrideClass.scala", scala2CompatMode),
compileFile("tests/neg-custom-args/ovlazy.scala", scala2CompatMode.and("-Xfatal-warnings")),
compileFile("tests/neg-custom-args/newline-braces.scala", scala2CompatMode.and("-Xfatal-warnings")),
compileFile("tests/neg-custom-args/autoTuplingTest.scala", defaultOptions.andLanguageFeature("noAutoTupling")),
compileFile("tests/neg-custom-args/i1650.scala", allowDeepSubtypes),
compileFile("tests/neg-custom-args/i3882.scala", allowDeepSubtypes),
compileFile("tests/neg-custom-args/i4372.scala", allowDeepSubtypes),
compileFile("tests/neg-custom-args/i1754.scala", allowDeepSubtypes),
compileFile("tests/neg-custom-args/i12650.scala", allowDeepSubtypes),
compileFile("tests/neg-custom-args/i9517.scala", defaultOptions.and("-Xprint-types")),
compileFile("tests/neg-custom-args/interop-polytypes.scala", allowDeepSubtypes.and("-Yexplicit-nulls")),
compileFile("tests/neg-custom-args/conditionalWarnings.scala", allowDeepSubtypes.and("-deprecation").and("-Xfatal-warnings")),
compileFilesInDir("tests/neg-custom-args/isInstanceOf", allowDeepSubtypes and "-Xfatal-warnings"),
Expand All @@ -176,23 +142,7 @@ class CompilationTests {
"tests/neg-custom-args/toplevel-samesource/nested/S.scala"),
defaultOptions),
compileFile("tests/neg-custom-args/i6300.scala", allowDeepSubtypes),
compileFile("tests/neg-custom-args/infix.scala", defaultOptions.and("-source", "future", "-deprecation", "-Xfatal-warnings")),
compileFile("tests/neg-custom-args/missing-targetName.scala", defaultOptions.and("-Yrequire-targetName", "-Xfatal-warnings")),
compileFile("tests/neg-custom-args/wildcards.scala", defaultOptions.and("-source", "future", "-deprecation", "-Xfatal-warnings")),
compileFile("tests/neg-custom-args/indentRight.scala", defaultOptions.and("-no-indent", "-Xfatal-warnings")),
compileDir("tests/neg-custom-args/adhoc-extension", defaultOptions.and("-source", "future", "-feature", "-Xfatal-warnings")),
compileFile("tests/neg/i7575.scala", defaultOptions.withoutLanguageFeatures.and("-language:_")),
compileFile("tests/neg-custom-args/kind-projector.scala", defaultOptions.and("-Ykind-projector")),
compileFile("tests/neg-custom-args/kind-projector-underscores.scala", defaultOptions.and("-Ykind-projector:underscores")),
compileFile("tests/neg-custom-args/typeclass-derivation2.scala", defaultOptions.and("-language:experimental.erasedDefinitions")),
compileFile("tests/neg-custom-args/deptypes.scala", defaultOptions.and("-language:experimental.dependent")),
compileFile("tests/neg-custom-args/matchable.scala", defaultOptions.and("-Xfatal-warnings", "-source", "future")),
compileFile("tests/neg-custom-args/i7314.scala", defaultOptions.and("-Xfatal-warnings", "-source", "future")),
compileFile("tests/neg-custom-args/capt-wf.scala", defaultOptions.and("-language:experimental.captureChecking", "-Xfatal-warnings")),
compileFile("tests/neg-custom-args/i13026.scala", defaultOptions.and("-print-lines")),
compileFile("tests/neg-custom-args/i13838.scala", defaultOptions.and("-Ximplicit-search-limit", "1000")),
compileFile("tests/neg-custom-args/jdk-9-app.scala", defaultOptions.and("-release:8")),
compileFile("tests/neg-custom-args/i10994.scala", defaultOptions.and("-source", "future")),
).checkExpectedErrors()
}

Expand All @@ -209,10 +159,6 @@ class CompilationTests {
compileFile("tests/run-custom-args/typeclass-derivation1.scala", defaultOptions.without(yCheckOptions*)),
compileFile("tests/run-custom-args/tuple-cons.scala", allowDeepSubtypes),
compileFile("tests/run-custom-args/i5256.scala", allowDeepSubtypes),
compileFile("tests/run-custom-args/no-useless-forwarders.scala", defaultOptions and "-Xmixin-force-forwarders:false"),
compileFile("tests/run-custom-args/defaults-serizaliable-no-forwarders.scala", defaultOptions and "-Xmixin-force-forwarders:false"),
compileFilesInDir("tests/run-custom-args/erased", defaultOptions.and("-language:experimental.erasedDefinitions")),
compileFilesInDir("tests/run-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")),
compileFilesInDir("tests/run-custom-args/captures", allowDeepSubtypes.and("-language:experimental.captureChecking")),
compileFilesInDir("tests/run-deep-subtype", allowDeepSubtypes),
compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init")),
Expand Down Expand Up @@ -254,7 +200,6 @@ class CompilationTests {
implicit val testGroup: TestGroup = TestGroup("explicitNullsNeg")
aggregateTests(
compileFilesInDir("tests/explicit-nulls/neg", explicitNullsOptions),
compileFilesInDir("tests/explicit-nulls/neg-patmat", explicitNullsOptions and "-Xfatal-warnings"),
compileFilesInDir("tests/explicit-nulls/unsafe-common", explicitNullsOptions),
)
}.checkExpectedErrors()
Expand All @@ -263,11 +208,7 @@ class CompilationTests {
implicit val testGroup: TestGroup = TestGroup("explicitNullsPos")
aggregateTests(
compileFilesInDir("tests/explicit-nulls/pos", explicitNullsOptions),
compileFilesInDir("tests/explicit-nulls/pos-separate", explicitNullsOptions),
compileFilesInDir("tests/explicit-nulls/pos-patmat", explicitNullsOptions and "-Xfatal-warnings"),
compileFilesInDir("tests/explicit-nulls/unsafe-common", explicitNullsOptions and "-language:unsafeNulls"),
compileFile("tests/explicit-nulls/pos-special/i14682.scala", explicitNullsOptions and "-Ysafe-init"),
compileFile("tests/explicit-nulls/pos-special/i14947.scala", explicitNullsOptions and "-Ytest-pickler" and "-Xprint-types"),
)
}.checkCompile()

Expand Down
2 changes: 2 additions & 0 deletions tests/explicit-nulls/neg-patmat/match-pat.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Xfatal-warnings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a zealot (much), but -Werror is more sleek and modern.

Possible warning options include:
         -Wconf  Configure compiler warnings.
        -Werror  Fail the compilation if there are any warnings.

My missed opportunity today on a scala 2 PR, for which I am overcompensating:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the size of this PR I prefer to keep all flags identical. We can refactor the flags after this PR.


class Foo {

val s: String = ???
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Ysafe-init

class C1:
sealed abstract class Name {
type ThisName <: Name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Ytest-pickler -Xprint-types

class B:
def g: String | Null = ???

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

// Ensure we don't get "the type test for argType cannot be checked at runtime" warning

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

import scala.language.unsafeNulls

def test1 =
Expand Down
20 changes: 0 additions & 20 deletions tests/neg-custom-args/deprecation/i11022.check

This file was deleted.

1 change: 0 additions & 1 deletion tests/neg-custom-args/erased/erased-case-class.scala

This file was deleted.

1 change: 0 additions & 1 deletion tests/neg-custom-args/erased/erased-object.scala

This file was deleted.

3 changes: 0 additions & 3 deletions tests/neg-custom-args/erased/erased-type.scala

This file was deleted.

3 changes: 0 additions & 3 deletions tests/neg-custom-args/erased/erased-var.scala

This file was deleted.

4 changes: 0 additions & 4 deletions tests/neg-custom-args/erased/i6795.check

This file was deleted.

30 changes: 0 additions & 30 deletions tests/neg-custom-args/fatal-warnings/i11333.check

This file was deleted.

1 change: 0 additions & 1 deletion tests/neg-custom-args/fatal-warnings/i11963a.scala

This file was deleted.

12 changes: 0 additions & 12 deletions tests/neg-custom-args/fatal-warnings/i13440.check

This file was deleted.

4 changes: 0 additions & 4 deletions tests/neg-custom-args/fatal-warnings/i16728.check

This file was deleted.

1 change: 0 additions & 1 deletion tests/neg-custom-args/fatal-warnings/i4936.scala

This file was deleted.

4 changes: 0 additions & 4 deletions tests/neg-custom-args/fatal-warnings/i6190b.check

This file was deleted.

12 changes: 0 additions & 12 deletions tests/neg-custom-args/fatal-warnings/i8711.check

This file was deleted.

16 changes: 0 additions & 16 deletions tests/neg-custom-args/fatal-warnings/symbolic-packages.check

This file was deleted.

4 changes: 0 additions & 4 deletions tests/neg-custom-args/feature/i13946/BadPrinter.scala

This file was deleted.

2 changes: 0 additions & 2 deletions tests/neg-custom-args/i10994.scala

This file was deleted.

6 changes: 0 additions & 6 deletions tests/neg-custom-args/nowarn/nowarn-typer-error.check

This file was deleted.

2 changes: 2 additions & 0 deletions tests/neg-custom-args/wildcards.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -source future -deprecation -Xfatal-warnings

object Test {
val xs: List[_] = List(1, 2, 3) // error
val ys: Map[_ <: AnyRef, _ >: Null] = Map() // error // error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Yno-experimental

import annotation.experimental

@experimental trait Exp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// scalac: -Xfatal-warnings -deprecation

@deprecated trait Exp
@deprecated val exp = 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Xfatal-warnings

import scala.reflect.ClassTag

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

import scala.reflect.TypeTest

object IsInstanceOfClassTag {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -source future -feature -Xfatal-warnings

package adhoc
class B extends A // error: adhoc-extension (under -strict -feature -Xfatal-warnings)
class C extends A // error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -language:noAutoTupling

object autoTupling {

val x = Some(1, 2) // error when running with -language:noAutoTupling
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -Xfatal-warnings -feature

object A {
@deprecated("use bar instead of this one", "0.2.3")
def foo: Int = 3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -language:experimental.erasedDefinitions

def f(x: => Int, erased y: => Int) = x // error
def g(erased x: => Int, y: => Int) = y // error

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// scalac: -language:experimental.captureChecking -Xfatal-warnings

class C
type Cap = C^

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

import scala.language.`future-migration`
import scala.reflect.ClassTag

Expand Down
Loading