Skip to content

Commit 848cd4e

Browse files
committed
improve test discovery to include inherited tests
motivation: test discovery on linux depends on index store test listing changes: * use new API from TSC that fixes the issue * adjust test * add docker setup for 5.7 rdar://59655518
1 parent 5bd3355 commit 848cd4e

File tree

9 files changed

+99
-22
lines changed

9 files changed

+99
-22
lines changed

Fixtures/Miscellaneous/TestDiscovery/Subclass/Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ let package = Package(
55
name: "Subclass",
66
targets: [
77
.target(name: "Subclass"),
8-
.testTarget(name: "SubclassTests", dependencies: ["Subclass"]),
8+
.testTarget(name: "Module1Tests", dependencies: ["Subclass"]),
9+
.testTarget(name: "Module2Tests", dependencies: ["Subclass"]),
910
]
1011
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import XCTest
2+
3+
class Tests1: XCTestCase {
4+
func test11() {
5+
print("->Tests1::test11")
6+
}
7+
8+
func test12() {
9+
print("->Tests1::test12")
10+
}
11+
12+
func test13() {
13+
print("->Tests1::test13")
14+
}
15+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import XCTest
2+
3+
class Tests3: Tests2 {
4+
override func test11() {
5+
print("->Tests3::test11")
6+
}
7+
8+
override func test21() {
9+
print("->Tests3::test21")
10+
}
11+
12+
func test31() {
13+
print("->Tests3::test31")
14+
}
15+
16+
func test32() {
17+
print("->Tests3::test32")
18+
}
19+
20+
func test33() {
21+
print("->Tests3::test33")
22+
}
23+
}
24+
25+
class Tests2: Tests1 {
26+
func test21() {
27+
print("->Tests2::test21")
28+
}
29+
30+
func test22() {
31+
print("->Tests2::test22")
32+
}
33+
}

Fixtures/Miscellaneous/TestDiscovery/Subclass/Tests/SubclassTests/SubclassTestsBase.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.

Fixtures/Miscellaneous/TestDiscovery/Subclass/Tests/SubclassTests/SubclassTestsDerived.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.

Sources/Build/BuildOperationBuildSystemDelegateHandler.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ final class TestDiscoveryCommand: CustomLLBuildCommand {
113113
let store = try IndexStore.open(store: index, api: api)
114114

115115
// FIXME: We can speed this up by having one llbuild command per object file.
116-
let tests = try tool.inputs.flatMap {
117-
try store.listTests(inObjectFile: AbsolutePath($0.name))
118-
}
116+
let tests = try store.listTests(in: tool.inputs.map{ AbsolutePath($0.name) })
119117

120118
let outputs = tool.outputs.compactMap{ try? AbsolutePath(validating: $0.name) }
121119
let testsByModule = Dictionary(grouping: tests, by: { $0.module.spm_mangledToC99ExtendedIdentifier() })

Tests/FunctionalTests/TestDiscoveryTests.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,17 @@ class TestDiscoveryTests: XCTestCase {
130130
// in "swift test" build output goes to stderr
131131
XCTAssertMatch(stderr, .contains("Build complete!"))
132132
// in "swift test" test output goes to stdout
133-
XCTAssertMatch(stdout, .contains("SubclassTestsBase.test1"))
134-
XCTAssertMatch(stdout, .contains("SubclassTestsDerived.test1"))
135-
XCTAssertMatch(stdout, .contains("Executed 2 tests"))
133+
XCTAssertMatch(stdout, .contains("Tests3.test11"))
134+
XCTAssertMatch(stdout, .contains("Tests3.test12"))
135+
XCTAssertMatch(stdout, .contains("Tests3.test13"))
136+
XCTAssertMatch(stdout, .contains("Tests3.test21"))
137+
XCTAssertMatch(stdout, .contains("Tests3.test22"))
138+
XCTAssertMatch(stdout, .contains("Tests3.test31"))
139+
XCTAssertMatch(stdout, .contains("Tests3.test32"))
140+
XCTAssertMatch(stdout, .contains("Tests3.test33"))
141+
XCTAssertMatch(stdout, .contains("->Tests3::test11"))
142+
XCTAssertMatch(stdout, .contains("->Tests3::test21"))
143+
XCTAssertMatch(stdout, .contains("Executed 8 tests"))
136144
}
137145
}
138146
}

Utilities/Docker/docker-compose.2004.56.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ services:
1616
args:
1717
ubuntu_version: "focal"
1818
swift_version: "5.6"
19-
base_image: "swiftlang/swift:nightly-5.6-focal"
2019

2120
build:
2221
image: swift-package-manager:20.04-5.6
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This source file is part of the Swift open source project
2+
#
3+
# Copyright (c) 2022 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
version: "3"
10+
11+
services:
12+
13+
runtime-setup:
14+
image: swift-package-manager:20.04-5.7
15+
build:
16+
args:
17+
ubuntu_version: "focal"
18+
swift_version: "5.7"
19+
base_image: "swiftlang/swift:nightly-5.7-focal"
20+
21+
build:
22+
image: swift-package-manager:20.04-5.7
23+
24+
test:
25+
image: swift-package-manager:20.04-5.7
26+
27+
bootstrap-clean:
28+
image: swift-package-manager:20.04-5.7
29+
30+
bootstrap-build:
31+
image: swift-package-manager:20.04-5.7
32+
33+
bootstrap-test:
34+
image: swift-package-manager:20.04-5.7
35+
36+
shell:
37+
image: swift-package-manager:20.04-5.7

0 commit comments

Comments
 (0)