Skip to content

improve test discovery to include inherited tests #5637

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 2 commits into from
Jul 5, 2022
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ let package = Package(
name: "Subclass",
targets: [
.target(name: "Subclass"),
.testTarget(name: "SubclassTests", dependencies: ["Subclass"]),
.testTarget(name: "Module1Tests", dependencies: ["Subclass"]),
.testTarget(name: "Module2Tests", dependencies: ["Subclass"]),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import XCTest

class Tests1: XCTestCase {
func test11() {
print("->Module1::Tests1::test11")
}

func test12() {
print("->Module1::Tests1::test12")
}

func test13() {
print("->Module1::Tests1::test13")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import XCTest

class Tests3: Tests2 {
override func test11() {
print("->Module1::Tests3::test11")
}

override func test21() {
print("->Module1::Tests3::test21")
}

func test31() {
print("->Module1::Tests3::test31")
}

func test32() {
print("->Module1::Tests3::test32")
}

func test33() {
print("->Module1::Tests3::test33")
}
}

class Tests2: Tests1 {
func test21() {
print("->Module1::Tests2::test21")
}

func test22() {
print("->Module1::Tests2::test22")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import XCTest

class Tests1: XCTestCase {
func test11() {
print("->Module2::Tests1::test11")
}

func test12() {
print("->Module2::Tests1::test12")
}

func test13() {
print("->Module2::Tests1::test13")
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ final class TestDiscoveryCommand: CustomLLBuildCommand {
let store = try IndexStore.open(store: index, api: api)

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

let outputs = tool.outputs.compactMap{ try? AbsolutePath(validating: $0.name) }
let testsByModule = Dictionary(grouping: tests, by: { $0.module.spm_mangledToC99ExtendedIdentifier() })
Expand Down
22 changes: 19 additions & 3 deletions Tests/FunctionalTests/TestDiscoveryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,25 @@ class TestDiscoveryTests: XCTestCase {
// in "swift test" build output goes to stderr
XCTAssertMatch(stderr, .contains("Build complete!"))
// in "swift test" test output goes to stdout
XCTAssertMatch(stdout, .contains("SubclassTestsBase.test1"))
XCTAssertMatch(stdout, .contains("SubclassTestsDerived.test1"))
XCTAssertMatch(stdout, .contains("Executed 2 tests"))
XCTAssertMatch(stdout, .contains("Tests3.test11"))
XCTAssertMatch(stdout, .contains("->Module1::Tests1::test11"))
XCTAssertMatch(stdout, .contains("Tests3.test12"))
XCTAssertMatch(stdout, .contains("->Module1::Tests1::test12"))
XCTAssertMatch(stdout, .contains("Tests3.test13"))
XCTAssertMatch(stdout, .contains("->Module1::Tests1::test13"))
XCTAssertMatch(stdout, .contains("Tests3.test21"))
XCTAssertMatch(stdout, .contains("->Module1::Tests2::test21"))
XCTAssertMatch(stdout, .contains("Tests3.test22"))
XCTAssertMatch(stdout, .contains("->Module1::Tests2::test22"))
XCTAssertMatch(stdout, .contains("Tests3.test31"))
XCTAssertMatch(stdout, .contains("->Module1::Tests3::test31"))
XCTAssertMatch(stdout, .contains("Tests3.test32"))
XCTAssertMatch(stdout, .contains("->Module1::Tests3::test32"))
XCTAssertMatch(stdout, .contains("Tests3.test33"))
XCTAssertMatch(stdout, .contains("->Module1::Tests3::test33"))

XCTAssertMatch(stdout, .contains("->Module2::Tests1::test11"))
XCTAssertMatch(stdout, .contains("->Module2::Tests1::test12"))
}
}
}
1 change: 0 additions & 1 deletion Utilities/Docker/docker-compose.2004.56.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ services:
args:
ubuntu_version: "focal"
swift_version: "5.6"
base_image: "swiftlang/swift:nightly-5.6-focal"

build:
image: swift-package-manager:20.04-5.6
Expand Down
37 changes: 37 additions & 0 deletions Utilities/Docker/docker-compose.2004.57.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This source file is part of the Swift open source project
#
# Copyright (c) 2022 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

version: "3"

services:

runtime-setup:
image: swift-package-manager:20.04-5.7
build:
args:
ubuntu_version: "focal"
swift_version: "5.7"
base_image: "swiftlang/swift:nightly-5.7-focal"

build:
image: swift-package-manager:20.04-5.7

test:
image: swift-package-manager:20.04-5.7

bootstrap-clean:
image: swift-package-manager:20.04-5.7

bootstrap-build:
image: swift-package-manager:20.04-5.7

bootstrap-test:
image: swift-package-manager:20.04-5.7

shell:
image: swift-package-manager:20.04-5.7