Generalize tests for both diagnostic styles, or force the LLVM style

These tests are using FileCheck to check the result of diagnostic
formatting in ways that don't match the new formatter. Force the old
formatter or, where possible, generalize so that they match both
formatters.
This commit is contained in:
Doug Gregor
2024-02-19 02:40:22 -10:00
parent 69ab4fc56c
commit 8cd2f34654
23 changed files with 56 additions and 59 deletions

View File

@@ -25,12 +25,12 @@ func nonIsolatedAsync() async {
await nonIsolatedAsync()
// Swift6-CHECK: foo.swift{{.*}}main actor-isolated var 'a' can not be referenced from a non-isolated context
// Swift6-CHECK: var declared here
// Swift6-CHECK: foo.swift{{.*}}add '@MainActor' to make global function 'foo()' part of global actor 'MainActor'
// Swift6-CHECK-DAG: var declared here
// Swift6-CHECK-DAG: add '@MainActor' to make global function 'foo()' part of global actor 'MainActor'
// Swift5-CHECK-NOT: foo.swift{{.*}}main actor-isolated var 'a' can not be referenced from a non-isolated context
// Swift5-CHECK-NOT: var declared here
// Swift5-CHECK-NOT: foo.swift{{.*}}add '@MainActor' to make global function 'foo()' part of global actor 'MainActor'
// Swift5-CHECK-NOT: add '@MainActor' to make global function 'foo()' part of global actor 'MainActor'
@MainActor
func isolated() {

View File

@@ -3,7 +3,7 @@
// CHECK-CD: [0m1 = 2{{$}}
// RUN: not %target-swiftc_driver -no-color-diagnostics -emit-executable -o %t %s 2>&1 \
// RUN: | %FileCheck -check-prefix=CHECK-NCD --match-full-lines %s
// CHECK-NCD: 1 = 2
// RUN: | %FileCheck -check-prefix=CHECK-NCD %s
// CHECK-NCD: {{[ ]}}1 = 2
1 = 2

View File

@@ -4,4 +4,8 @@
@testable import single_int // CHECK: module 'single_int' was not compiled for testing
x = 8 // CHECK-NOT: cannot find 'x' in scope
x = 8
// CHECK-NOT: cannot find 'x' in scope

View File

@@ -1,6 +1,6 @@
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: not %target-swift-frontend -typecheck -I %t/Inputs %t/test.swift -enable-experimental-cxx-interop 2>&1 | %FileCheck %s
// RUN: not %target-swift-frontend -typecheck -I %t/Inputs %t/test.swift -enable-experimental-cxx-interop -diagnostic-style llvm 2>&1 | %FileCheck %s
//--- Inputs/module.modulemap
module Test {

View File

@@ -1,6 +1,6 @@
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: not %target-swift-frontend -typecheck -I %t/Inputs %t/test.swift -enable-experimental-cxx-interop 2>&1 | %FileCheck %s
// RUN: not %target-swift-frontend -typecheck -I %t/Inputs %t/test.swift -enable-experimental-cxx-interop -diagnostic-style llvm 2>&1 | %FileCheck %s
// REQUIRES: OS=macosx || OS=linux-gnu

View File

@@ -1,6 +1,6 @@
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: not %target-swift-frontend -typecheck -I %t/Inputs %t/test.swift -enable-experimental-cxx-interop 2>&1 | %FileCheck %s
// RUN: not %target-swift-frontend -typecheck -I %t/Inputs %t/test.swift -enable-experimental-cxx-interop -diagnostic-style llvm 2>&1 | %FileCheck %s
//--- Inputs/module.modulemap
module Test {

View File

@@ -1,6 +1,6 @@
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: not %target-swift-frontend -typecheck -I %t/Inputs %t/test.swift -enable-experimental-cxx-interop 2>&1 | %FileCheck %s
// RUN: not %target-swift-frontend -typecheck -I %t/Inputs %t/test.swift -enable-experimental-cxx-interop -diagnostic-style llvm 2>&1 | %FileCheck %s
//--- Inputs/module.modulemap
module Test {

View File

@@ -1,5 +1,5 @@
// RUN: %target-typecheck-verify-swift
// RUN: not %target-swift-frontend -c %s 2>&1 | %FileCheck %s
// RUN: not %target-swift-frontend -c %s -diagnostic-style llvm 2>&1 | %FileCheck %s
let x = 0 // We need this because of the #sourceLocation-ends-with-a-newline requirement.

View File

@@ -18,7 +18,7 @@ class Extant {
// GOOD-IGNORE-NOT: access-notes-invalid.swift:[[@LINE-1]]:{{[0-9]+}}: remark: implicitly added '@objc' to this instance method, as specified by access note for Access notes containing future, unknown syntax
// GOOD-IGNORE-NOT: access-notes-invalid.swift:[[@LINE-2]]:{{[0-9]+}}: note: add '@objc' explicitly to silence this warning
// GOOD-REMARK-DAG: access-notes-invalid.swift:[[@LINE-3]]:{{[0-9]+}}: remark: implicitly added '@objc' to this instance method, as specified by access note for Access notes containing future, unknown syntax
// GOOD-REMARK-DAG: access-notes-invalid.swift:[[@LINE-4]]:{{[0-9]+}}: note: add '@objc' explicitly to silence this warning
// GOOD-REMARK-DAG: note: add '@objc' explicitly to silence this warning
func bad(_: Int?) {} // expected-remark * {{}}
// BAD-IGNORE-NOT: access-notes-invalid.swift:[[@LINE-1]]:{{[0-9]+}}: remark: ignored access note: method cannot be marked @objc by an access note because the type of the parameter cannot be represented in Objective-C; did not implicitly add '@objc' to this instance method, even though it was specified by access note for Access notes containing future, unknown syntax

View File

@@ -1,4 +1,4 @@
// RUN: not %target-swift-frontend -typecheck %s \
// RUN: not %target-swift-frontend -typecheck %s -diagnostic-style llvm \
// RUN: -define-availability "_brokenParse:a b c d" \
// RUN: -define-availability ":a b c d" \
// RUN: -define-availability "_justAName" \

View File

@@ -2,7 +2,7 @@
// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -disable-objc-attr-requires-foundation-module -typecheck %s 2>&1 | %FileCheck %s '--implicit-check-not=<unknown>:0'
// Make sure we do not emit availability errors or warnings when -disable-availability-checking is passed
// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -typecheck -disable-objc-attr-requires-foundation-module -disable-availability-checking %s 2>&1 | %FileCheck %s '--implicit-check-not=error:'
// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -typecheck -disable-objc-attr-requires-foundation-module -disable-availability-checking %s -diagnostic-style llvm 2>&1 | %FileCheck %s '--implicit-check-not=error:'
// REQUIRES: OS=macosx

View File

@@ -2,7 +2,7 @@
// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -disable-objc-attr-requires-foundation-module -typecheck %s 2>&1 | %FileCheck %s '--implicit-check-not=<unknown>:0'
// Make sure we do not emit availability errors or warnings when -disable-availability-checking is passed
// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -typecheck -disable-objc-attr-requires-foundation-module -disable-availability-checking %s 2>&1 | %FileCheck %s '--implicit-check-not=error:' '--implicit-check-not=warning:'
// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -typecheck -disable-objc-attr-requires-foundation-module -disable-availability-checking %s -diagnostic-style llvm 2>&1 | %FileCheck %s '--implicit-check-not=error:' '--implicit-check-not=warning:'
// REQUIRES: OS=macosx

View File

@@ -19,4 +19,3 @@ public func f(_ x: ModuleType.MyStruct) {}
// CHECK: error: 'MyStruct' is not a member type of struct 'SecondModule.ModuleType'
// CHECK: SecondModule.ModuleType:1:15: note: 'ModuleType' declared here
// CHECK: public struct ModuleType {
// CHECK: ^

View File

@@ -8,7 +8,7 @@
// RUN: %target-swift-frontend -module-name errors -emit-module -o %t/errors.swiftmodule -experimental-allow-module-with-compiler-errors %t/errors.partial.swiftmodule %t/errorsempty.partial.swiftmodule
// RUN: %target-swift-frontend -emit-module -o %t/mods/uses.swiftmodule -experimental-allow-module-with-compiler-errors -I %t/mods %t/uses.swift 2>&1 | %FileCheck -check-prefix=CHECK-USES %s
// RUN: %target-swift-frontend -emit-module -o %t/mods/uses.swiftmodule -experimental-allow-module-with-compiler-errors -I %t/mods %t/uses.swift -diagnostic-style llvm 2>&1 | %FileCheck -check-prefix=CHECK-USES %s
// BEGIN errors.swift
typealias AnAlias = undefined // expected-error {{cannot find type 'undefined'}}

View File

@@ -1,9 +1,9 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -o %t -module-name Lib -I %S/Inputs/custom-modules -swift-version 4 %s
// RUN: echo 'import Lib; _ = Sub.disappearingMethod' | not --crash %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules -swift-version 4 -disable-deserialization-recovery -Xcc -DBAD - 2>&1 | %FileCheck -check-prefix CHECK-CRASH -check-prefix CHECK-CRASH-4 %s
// RUN: echo 'import Lib; _ = Sub.disappearingMethod' | not --crash %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules -swift-version 4.2 -disable-deserialization-recovery -Xcc -DBAD - 2>&1 | %FileCheck -check-prefix CHECK-CRASH -check-prefix CHECK-CRASH-4_2 %s
// RUN: echo 'import Lib; _ = Sub.disappearingMethod' | not --crash %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules -debugger-support -swift-version 4 -disable-deserialization-recovery -Xcc -DBAD - 2>&1 | %FileCheck -check-prefix CHECK-CRASH-DEBUGGER %s
// RUN: echo 'import Lib; _ = Sub.disappearingMethod' | not --crash %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules -swift-version 4 -disable-deserialization-recovery -Xcc -DBAD - -diagnostic-style llvm 2>&1 | %FileCheck -check-prefix CHECK-CRASH -check-prefix CHECK-CRASH-4 %s
// RUN: echo 'import Lib; _ = Sub.disappearingMethod' | not --crash %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules -swift-version 4.2 -disable-deserialization-recovery -Xcc -DBAD - -diagnostic-style llvm 2>&1 | %FileCheck -check-prefix CHECK-CRASH -check-prefix CHECK-CRASH-4_2 %s
// RUN: echo 'import Lib; _ = Sub.disappearingMethod' | not --crash %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules -debugger-support -swift-version 4 -disable-deserialization-recovery -Xcc -DBAD - -diagnostic-style llvm 2>&1 | %FileCheck -check-prefix CHECK-CRASH-DEBUGGER %s
// REQUIRES: objc_interop

View File

@@ -33,7 +33,7 @@
// CHECK-MOVED: <unknown>:0: note: declarations in the underlying clang module 'A' may be hidden by clang preprocessor macros
// CHECK-MOVED: <unknown>:0: note: the distributed module 'LibWithXRef' refers to the local module 'A'; this may be caused by header maps or search paths
// CHECK-MOVED: <unknown>:0: note: the type 'MyType' moved between related modules; clang preprocessor macros may affect headers shared between these modules
// CHECK-MOVED: LibWithXRef.swiftmodule:1:1: note: could not deserialize type for 'foo()'
// CHECK-MOVED: note: could not deserialize type for 'foo()'
// CHECK-MOVED: error: cannot find 'foo' in scope
/// Move A to the SDK, triggering a different note about layering.

View File

@@ -4,7 +4,7 @@
// RUN: %target-build-swift -emit-module -o %t/System/Library/Frameworks/TestFramework.framework/Modules/TestFramework.swiftmodule/%target-swiftmodule-name -module-name TestFramework %s -DFRAMEWORK
// RUN: %target-build-swift -emit-module -o %t/Library/Frameworks/TestFramework2.framework/Modules/TestFramework2.swiftmodule/%target-swiftmodule-name -module-name TestFramework2 %s -DFRAMEWORK
// RUN: not %target-swift-frontend -typecheck -sdk %t -show-diagnostics-after-fatal %s 2>&1 | %FileCheck -check-prefix=CHECK-%target-runtime %s
// RUN: not %target-swift-frontend -typecheck -sdk %t -show-diagnostics-after-fatal %s -diagnostic-style llvm 2>&1 | %FileCheck -check-prefix=CHECK-%target-runtime %s
// FIXME: This isn't really about objc vs. native runtime,
// but about Apple vs. non-Apple platforms.
@@ -23,4 +23,4 @@ TestFramework2.foo()
// CHECK-objc-NOT: error
dummyError()
#endif // FRAMEWORK
#endif // FRAMEWORK

View File

@@ -51,6 +51,9 @@ internal func dependsOnHiddenType() -> HiddenType { fatalError() }
/// Note that the import doesn't have to be testable, only the imported module
/// needs to enable testing. We may want to improve upon this in the future.
import TestedLib
// CHECK-NOT-LOADED-NOT: remark: loaded module 'HiddenDep'
//--- ClientTestableImport.swift

View File

@@ -19,15 +19,11 @@
// CHECK-ALL-NOT: error:
// CHECK: {{.*}} error: could not find module 'new_module' for target '[[TARGET_ARCHITECTURE]]'; found: {{ppc65, i387|i387, ppc65}}, at: {{.*}}new_module.swiftmodule
// CHECK-NEXT: import new_module
// CHECK-NEXT: ^
// CHECK: import new_module
// CHECK-ALL: error: no such module 'new_module'
// CHECK-ALL-NEXT: import new_module
// CHECK-ALL-NEXT: ^
// CHECK-ALL: import new_module
// CHECK-ALL: error: cannot find 'new_module' in scope
// CHECK-ALL-NEXT: new_module.foo()
// CHECK-ALL-NEXT: ^~~~~~~~~~
// CHECK-ALL-NOT: error:
// CHECK-ALL: new_module.foo()
import new_module

View File

@@ -10,13 +10,13 @@
/// Move MyType from A to B.
// RUN: %target-swift-frontend %t/Empty.swift -emit-module-path %t/A.swiftmodule -module-name A
// RUN: %target-swift-frontend %t/LibOriginal.swift -emit-module-path %t/B.swiftmodule -module-name B
// RUN: not %target-swift-frontend -emit-sil %t/LibWithXRef.swiftmodule -module-name LibWithXRef -I %t 2>&1 \
// RUN: not %target-swift-frontend -emit-sil %t/LibWithXRef.swiftmodule -module-name LibWithXRef -I %t -diagnostic-style llvm 2>&1 \
// RUN: | %FileCheck --check-prefixes CHECK,CHECK-MOVED %s
// CHECK-MOVED: LibWithXRef.swiftmodule:1:1: error: reference to type 'MyType' broken by a context change; 'MyType' was expected to be in 'A', but now a candidate is found only in 'B'
/// Force working around the broken modularization to get a result and no errors.
// RUN: %target-swift-frontend -emit-sil %t/LibWithXRef.swiftmodule -module-name LibWithXRef -I %t \
// RUN: -experimental-force-workaround-broken-modules 2>&1 \
// RUN: -experimental-force-workaround-broken-modules -diagnostic-style llvm 2>&1 \
// RUN: | %FileCheck --check-prefixes CHECK-WORKAROUND %s
// CHECK-WORKAROUND: LibWithXRef.swiftmodule:1:1: warning: reference to type 'MyType' broken by a context change; 'MyType' was expected to be in 'A', but now a candidate is found only in 'B'
// CHECK-WORKAROUND-NEXT: A.MyType
@@ -31,21 +31,21 @@
/// Change MyType into a function.
// RUN: %target-swift-frontend %t/LibTypeChanged.swift -emit-module-path %t/A.swiftmodule -module-name A
// RUN: %target-swift-frontend %t/Empty.swift -emit-module-path %t/B.swiftmodule -module-name B
// RUN: not %target-swift-frontend -emit-sil %t/LibWithXRef.swiftmodule -module-name LibWithXRef -I %t 2>&1 \
// RUN: not %target-swift-frontend -emit-sil %t/LibWithXRef.swiftmodule -module-name LibWithXRef -I %t -diagnostic-style llvm 2>&1 \
// RUN: | %FileCheck --check-prefixes CHECK,CHECK-KIND-CHANGED %s
// CHECK-KIND-CHANGED: LibWithXRef.swiftmodule:1:1: error: reference to type 'MyType' broken by a context change; the declaration kind of 'MyType' from 'A' changed since building 'LibWithXRef'
/// Change MyType into a function and move it.
// RUN: %target-swift-frontend %t/Empty.swift -emit-module-path %t/A.swiftmodule -module-name A
// RUN: %target-swift-frontend %t/LibTypeChanged.swift -emit-module-path %t/B.swiftmodule -module-name B
// RUN: not %target-swift-frontend -emit-sil %t/LibWithXRef.swiftmodule -module-name LibWithXRef -I %t 2>&1 \
// RUN: not %target-swift-frontend -emit-sil %t/LibWithXRef.swiftmodule -module-name LibWithXRef -I %t -diagnostic-style llvm 2>&1 \
// RUN: | %FileCheck --check-prefixes CHECK,CHECK-KIND-CHANGED-AND-MOVED %s
// CHECK-KIND-CHANGED-AND-MOVED: LibWithXRef.swiftmodule:1:1: error: reference to type 'MyType' broken by a context change; the declaration kind of 'MyType' changed since building 'LibWithXRef', it was in 'A' and now a candidate is found only in 'B'
/// Remove MyType from all imported modules.
// RUN: %target-swift-frontend %t/Empty.swift -emit-module-path %t/A.swiftmodule -module-name A
// RUN: %target-swift-frontend %t/Empty.swift -emit-module-path %t/B.swiftmodule -module-name B
// RUN: not %target-swift-frontend -emit-sil %t/LibWithXRef.swiftmodule -module-name LibWithXRef -I %t 2>&1 \
// RUN: not %target-swift-frontend -emit-sil %t/LibWithXRef.swiftmodule -module-name LibWithXRef -I %t -diagnostic-style llvm 2>&1 \
// RUN: | %FileCheck --check-prefixes CHECK,CHECK-NOT-FOUND %s
// CHECK-NOT-FOUND: LibWithXRef.swiftmodule:1:1: error: reference to type 'MyType' broken by a context change; 'MyType' is not found, it was expected to be in 'A'

View File

@@ -35,6 +35,11 @@
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
// RUN: -experimental-spi-only-imports \
// RUN: -Rmodule-loading 2>&1 | %FileCheck -check-prefix=VISIBLE-DEP-NOT %s
// VISIBLE-DEP-NOT-NOT: loaded module 'SPIDependency'
import Lib
// VISIBLE-DEP-NOT-NOT: loaded module 'SPIDependency'

View File

@@ -25,34 +25,24 @@ internal func internalAmbiguity() {}
func foo() {
publicAmbiguity()
// CHECK: error: ambiguous use of 'publicAmbiguity()'
// CHECK-NEXT: publicAmbiguity()
// CHECK-NEXT: ^
// CHECK-NEXT: Lib.swift:1:13: note: found this candidate in module 'A'
// CHECK-NEXT: public func publicAmbiguity() {}
// CHECK-NEXT: ^
// CHECK-NEXT: Lib.swift:1:13: note: found this candidate in module 'B'
// CHECK-NEXT: public func publicAmbiguity() {}
// CHECK-NEXT: ^
// CHECK: publicAmbiguity()
// CHECK: note: found this candidate in module 'A'
// CHECK: public func publicAmbiguity() {}
// CHECK: note: found this candidate in module 'B'
// CHECK: public func publicAmbiguity() {}
packageAmbiguity()
// CHECK: error: ambiguous use of 'packageAmbiguity()'
// CHECK-NEXT: packageAmbiguity()
// CHECK-NEXT: ^
// CHECK-NEXT: Lib.swift:2:14: note: found this candidate in module 'A'
// CHECK-NEXT: package func packageAmbiguity() {}
// CHECK-NEXT: ^
// CHECK-NEXT: Lib.swift:2:14: note: found this candidate in module 'B'
// CHECK-NEXT: package func packageAmbiguity() {}
// CHECK-NEXT: ^
// CHECK: note: found this candidate in module 'A'
// CHECK: package func packageAmbiguity() {}
// CHECK: note: found this candidate in module 'B'
// CHECK: package func packageAmbiguity() {}
internalAmbiguity()
// CHECK: error: ambiguous use of 'internalAmbiguity()'
// CHECK-NEXT: internalAmbiguity()
// CHECK-NEXT: ^
// CHECK-NEXT: Lib.swift:3:15: note: found this candidate in module 'A'
// CHECK-NEXT: internal func internalAmbiguity() {}
// CHECK-NEXT: ^
// CHECK-NEXT: Lib.swift:3:15: note: found this candidate in module 'B'
// CHECK-NEXT: internal func internalAmbiguity() {}
// CHECK-NEXT: ^
// CHECK: note: found this candidate in module 'A'
// CHECK: internal func internalAmbiguity() {}
// CHECK: note: found this candidate in module 'B'
}

View File

@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
// RUN: not %target-swift-frontend -I %S/Inputs/failing-overlay/ -typecheck %s 2>&1 | %FileCheck %s
// RUN: not %target-swift-frontend -I %S/Inputs/failing-overlay/ -typecheck %s -diagnostic-style llvm 2>&1 | %FileCheck %s
import ImportsOverlay