Skip to content

Commit cee0b9c

Browse files
authored
Merge pull request #15870 from rintaro/driver-moduleonly-diff
[Test] Ensure '-emit-module' emits identical module file with full build
2 parents f1202c4 + a4df3a5 commit cee0b9c

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
11
public func bar() { }
22

3+
public class Bar {
4+
@usableFromInline internal class Inner {
5+
6+
/// makeX is declared in foo.swift
7+
var x = makeX([1,2,3,4])
8+
9+
@usableFromInline internal func f() {
10+
print("Bar.Inner.f")
11+
}
12+
}
13+
}
14+
15+
#if _runtime(_ObjC) && canImport(Foundation)
16+
17+
import Foundation
18+
19+
public class ObjCBar : NSObject {
20+
21+
@objc(foo)
22+
public func bar() -> String {
23+
return ""
24+
}
25+
26+
}
27+
28+
#endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
11
public func baz() {}
2+
3+
public protocol BazProtocol {
4+
associatedtype Ret
5+
func method1() -> Ret?
6+
}
7+
8+
public enum Baz<T: Collection> : BazProtocol {
9+
case collection(T)
10+
case other
11+
12+
public func method1() -> T.SubSequence? {
13+
switch self {
14+
case .collection(let collection):
15+
return makeX(collection)
16+
default:
17+
return nil
18+
}
19+
}
20+
}
Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
1-
public func foo() { }
1+
@inlinable
2+
public func foo(x: Int) -> Int {
3+
return x + 1
4+
}
25

6+
/// something
7+
func makeX<T: Collection>(_ seed: T) -> T.SubSequence {
8+
return seed.dropFirst(1)
9+
}
10+
11+
public struct Foo : BazProtocol {
12+
/// varx
13+
public var x = makeX("foobar")
14+
15+
/// method
16+
public func method1() -> Int? { return 1 }
17+
18+
/* Foo Bar */
19+
@_transparent
20+
public func method2(x: Int) -> Int {
21+
return x * 12
22+
}
23+
24+
@inlinable
25+
public func method3<T: Equatable>(x: T, y: T) -> T {
26+
return x == y ? x : y
27+
}
28+
}

test/Driver/Dependencies/moduleonly.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,18 @@
6363
// RUN: test ! -f %t/buildrecord.swiftdeps~moduleonly
6464
// RUN: test -f %t/buildrecord.swiftdeps
6565
// RUN: test -f %t/foo~partial.swiftmodule
66+
67+
// Ensure '-emit-module' and '-c -emit-module' emits identical 'swiftmodule' and 'swiftdoc' file.
68+
//
69+
// RUN: rm -f %t-moduleonly.swiftmodule
70+
// RUN: rm -f %t-moduleonly.swiftdoc
71+
// RUN: rm -rf %t && cp -r %S/Inputs/moduleonly/ %t
72+
// RUN: touch -t 201801230045 %t/*.swift
73+
// RUN: cd %t && %target-build-swift -emit-module -output-file-map ./output.json -incremental ./foo.swift ./bar.swift ./baz.swift -module-name testmodule -v 2>&1
74+
// RUN: cp -f %t/testmodule.swiftmodule %t-moduleonly.swiftmodule
75+
// RUN: cp -f %t/testmodule.swiftdoc %t-moduleonly.swiftdoc
76+
// RUN: rm -rf %t && cp -r %S/Inputs/moduleonly/ %t
77+
// RUN: touch -t 201801230045 %t/*.swift
78+
// RUN: cd %t && %target-build-swift -c -emit-module -output-file-map ./output.json -incremental ./foo.swift ./bar.swift ./baz.swift -module-name testmodule -v 2>&1
79+
// RUN: diff %t/testmodule.swiftmodule %t-moduleonly.swiftmodule
80+
// RUN: diff %t/testmodule.swiftdoc %t-moduleonly.swiftdoc

0 commit comments

Comments
 (0)