Skip to content

Commit a69da1a

Browse files
[TEST] Switch to use new swift-driver when running tests
Default to use new swift-driver to run lit tests as legacy swift driver is deprecated for a long time. The lit tests for legacy drivers are also disable when running new swift-driver. Tests that relies on legacy swift driver (for example, tests merge module) can be enabled on conditions `legacy_swift_driver`. Fix and split up some existing tests that relies on legacy driver.
1 parent 85d522e commit a69da1a

File tree

6 files changed

+137
-20
lines changed

6 files changed

+137
-20
lines changed

test/Driver/lit.local.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if not 'legacy_swift_driver' in config.available_features:
2+
config.unsupported = True
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// REQUIRES: legacy_swift_driver
2+
// RUN: %empty-directory(%t)
3+
4+
// Generate the parseable interface of the current file via the merge-modules step
5+
// RUN: %target-build-swift -no-emit-module-separately -emit-module -o %t/Test.swiftmodule -emit-module-interface-path %t/TestMerge.swiftinterface -module-name Test %s
6+
7+
// Make sure both don't add override for inits shadowing convenience initializers
8+
// RUN: %FileCheck %s < %t/TestMerge.swiftinterface
9+
10+
// Check we can consume the interface without issue
11+
// RUN: %target-swift-frontend -swift-version 5 -compile-module-from-interface -o %t/Test.swiftmodule %t/TestMerge.swiftinterface
12+
13+
public class Base {
14+
let x: Int
15+
public init(x: Int) {
16+
self.x = x
17+
}
18+
convenience public init() {
19+
self.init(x: 1)
20+
}
21+
}
22+
23+
public class Derived: Base {
24+
// CHECK: {{^}} public init(z: Swift.Int)
25+
public init(z: Int) {
26+
super.init(x: z)
27+
}
28+
// CHECK: {{^}} public convenience init()
29+
convenience public init() {
30+
self.init(z: 1)
31+
}
32+
}
33+
34+
public class Derived2: Base {
35+
// CHECK: {{^}} public init()
36+
public init() {
37+
super.init(x: 1)
38+
}
39+
40+
// CHECK: {{^}} override public convenience init(x: Swift.Int)
41+
override convenience public init(x: Int) {
42+
self.init()
43+
}
44+
}

test/ModuleInterface/convenience-init.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
// RUN: %empty-directory(%t)
22

3-
// Generate the parseable interface of the current file via the merge-modules step
4-
// RUN: %target-build-swift -no-emit-module-separately -emit-module -o %t/Test.swiftmodule -emit-module-interface-path %t/TestMerge.swiftinterface -module-name Test %s
5-
63
// Generate the parseable interface of the current file via a single frontend invocation
74
// RUN: %target-swift-frontend -typecheck -enable-objc-interop -emit-module-interface-path %t/TestSingle.swiftinterface -module-name Test %s
85

96
// Make sure both don't add override for inits shadowing convenience initializers
10-
// RUN: %FileCheck --check-prefixes=CHECK,SINGLE %s < %t/TestSingle.swiftinterface
11-
// RUN: %FileCheck --check-prefixes=CHECK,MERGE %s < %t/TestMerge.swiftinterface
7+
// RUN: %FileCheck --check-prefixes=CHECK %s < %t/TestSingle.swiftinterface
128

139
// Check we can consume the interface without issue
1410
// RUN: %target-swift-frontend -swift-version 5 -compile-module-from-interface -o %t/Test.swiftmodule %t/TestSingle.swiftinterface
15-
// RUN: %target-swift-frontend -swift-version 5 -compile-module-from-interface -o %t/Test.swiftmodule %t/TestMerge.swiftinterface
1611

1712
public class Base {
1813
let x: Int
@@ -29,8 +24,7 @@ public class Derived: Base {
2924
public init(z: Int) {
3025
super.init(x: z)
3126
}
32-
// MERGE: {{^}} public convenience init()
33-
// SINGLE: {{^}} convenience public init()
27+
// CHECK: {{^}} convenience public init()
3428
convenience public init() {
3529
self.init(z: 1)
3630
}
@@ -42,8 +36,7 @@ public class Derived2: Base {
4236
super.init(x: 1)
4337
}
4438

45-
// MERGE: {{^}} override public convenience init(x: Swift.Int)
46-
// SINGLE: {{^}} override convenience public init(x: Swift.Int)
39+
// CHECK: {{^}} override convenience public init(x: Swift.Int)
4740
override convenience public init(x: Int) {
4841
self.init()
4942
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// REQUIRES: legacy_swift_driver
2+
// RUN: %empty-directory(%t)
3+
// RUN: %target-build-swift -no-emit-module-separately -emit-module-interface-path %t/Lib.swiftinterface -emit-module -o %t/unused.swiftmodule -enable-library-evolution -Xfrontend -enable-objc-interop -Xfrontend -disable-objc-attr-requires-foundation-module -swift-version 5 %S/Inputs/enums-layout-helper.swift -module-name Lib
4+
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK-MULTI-FILE %S/Inputs/enums-layout-helper.swift < %t/Lib.swiftinterface
5+
// RUN: %target-swift-frontend -enable-objc-interop -compile-module-from-interface %t/Lib.swiftinterface -o %t/compiled-from-interface.swiftmodule -module-name Lib
6+
// RUN: %target-swift-frontend -enable-objc-interop -O -emit-ir -primary-file %s -I %t -Xllvm -swiftmergefunc-threshold=0 | %FileCheck %s
7+
8+
9+
import Lib
10+
11+
// CHECK-LABEL: define{{.+}}testFutureproofEnum
12+
func testFutureproofEnum() -> FutureproofEnum {
13+
// Check a few things in the function to make sure it's getting the case
14+
// representation dynamically.
15+
// CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib15FutureproofEnumO1byA2CmFWC"
16+
// CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib15FutureproofEnumOMa"
17+
// CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
18+
// CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]])
19+
// CHECK-NEXT: ret void
20+
return .b
21+
} // CHECK-NEXT: {{^}$}}
22+
23+
// CHECK-LABEL: define{{.+}}testFrozenEnum
24+
func testFrozenEnum() -> FrozenEnum {
25+
// CHECK: ret i8 1
26+
return .b
27+
} // CHECK-NEXT: {{^}$}}
28+
29+
// CHECK-LABEL: define{{.+}}testFutureproofObjCEnum
30+
func testFutureproofObjCEnum() -> FutureproofObjCEnum {
31+
// CHECK: ret i{{32|64}} 10
32+
return .b
33+
} // CHECK-NEXT: {{^}$}}
34+
35+
// CHECK-LABEL: define{{.+}}testFrozenObjCEnum
36+
func testFrozenObjCEnum() -> FrozenObjCEnum {
37+
// CHECK: ret i{{32|64}} 10
38+
return .b
39+
} // CHECK-NEXT: {{^}$}}
40+
41+
// CHECK-LABEL: define{{.+}}testFutureproofUnicodeScalarEnum
42+
func testFutureproofUnicodeScalarEnum() -> FutureproofUnicodeScalarEnum {
43+
// CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib28FutureproofUnicodeScalarEnumO1ayA2CmFWC"
44+
// CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib28FutureproofUnicodeScalarEnumOMa"
45+
// CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
46+
// CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]])
47+
// CHECK-NEXT: ret void
48+
return .a
49+
}
50+
51+
// CHECK-LABEL: define{{.+}}testFutureproofIndirectEnum
52+
func testFutureproofIndirectEnum() -> FutureproofIndirectEnum {
53+
// CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib23FutureproofIndirectEnumO1cyA2CmFWC"
54+
// CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib23FutureproofIndirectEnumOMa"
55+
// CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
56+
// CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]])
57+
// CHECK-NEXT: ret void
58+
return .c
59+
}
60+
61+
// CHECK-LABEL: define{{.+}}testFrozenIndirectEnum
62+
func testFrozenIndirectEnum() -> FrozenIndirectEnum {
63+
// Whether this is "1" or "2" depends on whether the reserved ObjC tagged
64+
// pointer bit is the top or bottom bit on this platform.
65+
// CHECK: ret i{{32|64}} {{1|2}}
66+
return .c
67+
}
68+
69+
// CHECK-LABEL: define{{.+}}testFutureproofIndirectCaseEnum
70+
func testFutureproofIndirectCaseEnum() -> FutureproofIndirectCaseEnum {
71+
// CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib27FutureproofIndirectCaseEnumO1cyA2CmFWC"
72+
// CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib27FutureproofIndirectCaseEnumOMa"
73+
// CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
74+
// CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]])
75+
// CHECK-NEXT: ret void
76+
return .c
77+
}
78+
79+
// CHECK-LABEL: define{{.+}}testFrozenIndirectCaseEnum
80+
func testFrozenIndirectCaseEnum() -> FrozenIndirectCaseEnum {
81+
// Whether this is "1" or "2" depends on whether the reserved ObjC tagged
82+
// pointer bit is the top or bottom bit on this platform.
83+
// CHECK: ret i{{32|64}} {{1|2}}
84+
return .c
85+
}

test/ModuleInterface/enums-layout.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-build-swift -no-emit-module-separately -emit-module-interface-path %t/Lib.swiftinterface -emit-module -o %t/unused.swiftmodule -enable-library-evolution -Xfrontend -enable-objc-interop -Xfrontend -disable-objc-attr-requires-foundation-module -swift-version 5 %S/Inputs/enums-layout-helper.swift -module-name Lib
3-
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK-MULTI-FILE %S/Inputs/enums-layout-helper.swift < %t/Lib.swiftinterface
4-
// RUN: %target-swift-frontend -enable-objc-interop -compile-module-from-interface %t/Lib.swiftinterface -o %t/compiled-from-interface.swiftmodule -module-name Lib
5-
// RUN: %target-swift-frontend -enable-objc-interop -O -emit-ir -primary-file %s -I %t -Xllvm -swiftmergefunc-threshold=0 | %FileCheck %s
6-
7-
// Try again using a single-frontend build.
8-
// RUN: %empty-directory(%t)
92
// RUN: %target-build-swift -whole-module-optimization -emit-module-interface-path %t/Lib.swiftinterface -emit-module -o %t/unused.swiftmodule -enable-library-evolution -Xfrontend -enable-objc-interop -Xfrontend -disable-objc-attr-requires-foundation-module -swift-version 5 %S/Inputs/enums-layout-helper.swift -module-name Lib
103
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK-SINGLE-FRONTEND %S/Inputs/enums-layout-helper.swift < %t/Lib.swiftinterface
114
// RUN: %target-swift-frontend -enable-objc-interop -compile-module-from-interface %t/Lib.swiftinterface -o %t/compiled-from-interface.swiftmodule -module-name Lib

test/lit.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,11 +1021,11 @@ if not 'swift_driver' in lit_config.params:
10211021
config.available_features.add('swift_in_compiler')
10221022

10231023
# Check if we need to run lit tests using the legacy driver or the new driver
1024-
# The default for existing test runs is to use the legacy driver.
1025-
# The new driver is tested separately.
1026-
if os.environ.get('SWIFT_FORCE_TEST_NEW_DRIVER') is None:
1024+
# The default for existing test runs is to use the new driver.
1025+
if 'SWIFT_FORCE_TEST_OLD_DRIVER' in os.environ:
10271026
config.environment['SWIFT_USE_OLD_DRIVER'] = '1'
10281027
config.environment['SWIFT_AVOID_WARNING_USING_OLD_DRIVER'] = '1'
1028+
config.available_features.add('legacy_swift_driver')
10291029

10301030
# Enable benchmark testing when the binary is found (has fully qualified path).
10311031
if config.benchmark_o != 'Benchmark_O':

0 commit comments

Comments
 (0)