Skip to content

Followup to increasing swift-build test coverage #8374

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 1 commit into from
Mar 17, 2025
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
13 changes: 11 additions & 2 deletions Tests/CommandsTests/BuildCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ class BuildCommandTestCases: CommandsBuildProviderTestCase {
XCTAssertMatch(stdout, .contains("SEE ALSO: swift run, swift package, swift test"))
}

func testCommandDoesNotEmitDuplicateSymbols() async throws {
let (stdout, stderr) = try await SwiftPM.Build.execute(["--help"])
XCTAssertNoMatch(stdout, duplicateSymbolRegex)
XCTAssertNoMatch(stderr, duplicateSymbolRegex)
}

func testVersion() async throws {
let stdout = try await execute(["--version"]).stdout
XCTAssertMatch(stdout, .regex(#"Swift Package Manager -( \w+ )?\d+.\d+.\d+(-\w+)?"#))
Expand Down Expand Up @@ -202,12 +208,15 @@ class BuildCommandTestCases: CommandsBuildProviderTestCase {
)

guard buildSystemProvider == .xcode || buildSystemProvider == .swiftbuild else {
// The remainder of this test only applies to XCBuild or Swift Build
return
}

// Print correct path when building with XCBuild or Swift Build
let xcodeDebugOutput = try await execute(["--show-bin-path"], packagePath: fullPath)
.stdout
let xcodeDebugOutput = try await execute(
["-c", "debug", "--show-bin-path"],
packagePath: fullPath)
.stdout
let xcodeReleaseOutput = try await execute(
["-c", "release", "--show-bin-path"],
packagePath: fullPath
Expand Down
7 changes: 6 additions & 1 deletion Tests/CommandsTests/PackageCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
var environment = env ?? [:]
// don't ignore local packages when caching
environment["SWIFTPM_TESTS_PACKAGECACHE"] = "1"
// return try await self.execute(args, packagePath: packagePath, env: environment)
return try await executeSwiftPackage(
packagePath,
extraArgs: args,
Expand Down Expand Up @@ -77,6 +76,12 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
XCTAssertMatch(stdout, .contains("SEE ALSO: swift build, swift run, swift test"))
}

func testCommandDoesNotEmitDuplicateSymbols() async throws {
let (stdout, stderr) = try await SwiftPM.Package.execute(["--help"])
XCTAssertNoMatch(stdout, duplicateSymbolRegex)
XCTAssertNoMatch(stderr, duplicateSymbolRegex)
}

func testVersion() async throws {
// This test fails when `--build-system <system>` is provided, so directly invoke SwiftPM.Package.execute
let stdout = try await SwiftPM.Package.execute(["--version"]).stdout
Expand Down