Skip to content

Tests: Minor tweaks in Swift Build related tests #8473

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion IntegrationTests/Tests/IntegrationTests/BasicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private struct BasicTests {
}

@Test(
.skipHostOS(.windows, "'try!' expression unexpectedly raised an error: TSCBasic.Process.Error.missingExecutableProgram(program: \"which\")"),
.skipHostOS(.windows, "'try!' expression unexpectedly raised an error: TSCBasic.Process.Error.missingExecutableProgram(program: \"which\")")
)
func testSwiftCompiler() throws {
try withTemporaryDirectory { tempDir in
Expand Down
22 changes: 6 additions & 16 deletions Tests/BuildTests/BuildPlanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6977,23 +6977,15 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
}
}

class BuildPlanNativeTests: BuildPlanTestCase {
override open var buildSystemProvider: BuildSystemProvider.Kind {
return .native
}

override func testDuplicateProductNamesWithNonDefaultLibsThrowError() async throws {
try await super.testDuplicateProductNamesWithNonDefaultLibsThrowError()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all overrides that just call back the corresponding super class method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore (blocking): Please re-add the override as it was needed to ensure the XCTests on linux instantiate all the tests in the subclass.

@cmcgee1024 can provide additional information as to why it was originally added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, wasn't aware of that Linux hack, sorry :-(

So to be clear: all Linux test suites need to override all test cases... and then call super? If so, are we sure we actually did this hack everywhere? For instance BuildPlanSwiftBuildTests has dozen of tests but only two are overridden like this.

CC @cmcgee1024

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from my understanding, only 1 test needs to be overridden to have XCTest "populate" all the tests in the subclass.

final class BuildPlanNativeTests: BuildPlanTestCase {
Copy link
Contributor Author

@pmattos pmattos Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked all these subclasses final to make it clear we don't further extend such tests anywhere else.

override public var buildSystemProvider: BuildSystemProvider.Kind {
.native
}
}

class BuildPlanSwiftBuildTests: BuildPlanTestCase {
override open var buildSystemProvider: BuildSystemProvider.Kind {
return .swiftbuild
}

override func testDuplicateProductNamesWithNonDefaultLibsThrowError() async throws {
try await super.testDuplicateProductNamesWithNonDefaultLibsThrowError()
final class BuildPlanSwiftBuildTests: BuildPlanTestCase {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.swiftbuild
}

override func testTargetsWithPackageAccess() async throws {
Expand All @@ -7014,8 +7006,6 @@ class BuildPlanSwiftBuildTests: BuildPlanTestCase {
throw XCTSkip("Skipping SwiftBuild testing on Amazon Linux because of platform issues.")
}
#endif

try await super.testPackageNameFlag()
}

}
23 changes: 6 additions & 17 deletions Tests/CommandsTests/APIDiffTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -455,25 +455,14 @@ class APIDiffTestCase: CommandsBuildProviderTestCase {
}
}

class APIDiffNativeTests: APIDiffTestCase {

override open var buildSystemProvider: BuildSystemProvider.Kind {
return .native
}

override func skipIfApiDigesterUnsupportedOrUnset() throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore (blocking): please re-add this override.

try super.skipIfApiDigesterUnsupportedOrUnset()
final class APIDiffNativeTests: APIDiffTestCase {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.native
}

}

class APIDiffSwiftBuildTests: APIDiffTestCase {

override open var buildSystemProvider: BuildSystemProvider.Kind {
return .swiftbuild
}

override func skipIfApiDigesterUnsupportedOrUnset() throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore (blocking): please re-add this override.

try super.skipIfApiDigesterUnsupportedOrUnset()
final class APIDiffSwiftBuildTests: APIDiffTestCase {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.swiftbuild
}
}
34 changes: 11 additions & 23 deletions Tests/CommandsTests/BuildCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -782,27 +782,17 @@ class BuildCommandTestCases: CommandsBuildProviderTestCase {

}


class BuildCommandNativeTests: BuildCommandTestCases {

override open var buildSystemProvider: BuildSystemProvider.Kind {
return .native
}

override func testUsage() async throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore (blocking): please re-add this override.

try await super.testUsage()
final class BuildCommandNativeTests: BuildCommandTestCases {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.native
}
}

#if os(macOS)
// Xcode build system tests can only function on macOS
class BuildCommandXcodeTests: BuildCommandTestCases {
override open var buildSystemProvider: BuildSystemProvider.Kind {
return .xcode
}

override func testUsage() async throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore (blocking): please re-add this override.

try await super.testUsage()
/// Xcode build system tests can only function on macOS.
final class BuildCommandXcodeTests: BuildCommandTestCases {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.xcode
}

override func testAutomaticParseableInterfacesWithLibraryEvolution() async throws {
Expand Down Expand Up @@ -855,10 +845,9 @@ class BuildCommandXcodeTests: BuildCommandTestCases {
}
#endif

class BuildCommandSwiftBuildTests: BuildCommandTestCases {

override open var buildSystemProvider: BuildSystemProvider.Kind {
return .swiftbuild
final class BuildCommandSwiftBuildTests: BuildCommandTestCases {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.swiftbuild
}

override func testNonReachableProductsAndTargetsFunctional() async throws {
Expand Down Expand Up @@ -892,7 +881,7 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
override func testImportOfMissedDepWarning() async throws {
throw XCTSkip("SWBINTTODO: Test fails because the warning message regarding missing imports is expected to be more verbose and actionable at the SwiftPM level with mention of the involved targets. This needs to be investigated. See case targetDiagnostic(TargetDiagnosticInfo) as a message type that may help.")
}

override func testProductAndTarget() async throws {
throw XCTSkip("SWBINTTODO: Test fails because there isn't a clear warning message about the lib1 being an automatic product and that the default product is being built instead. This needs to be investigated")
}
Expand Down Expand Up @@ -946,5 +935,4 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
try await super.testBuildCompleteMessage()
#endif
}

}
23 changes: 6 additions & 17 deletions Tests/CommandsTests/PackageCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3836,26 +3836,15 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
}
}


class PackageCommandNativeTests: PackageCommandTestCase {

override open var buildSystemProvider: BuildSystemProvider.Kind {
return .native
}

override func testNoParameters() async throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore (blocking): please re-add this override.

try await super.testNoParameters()
final class PackageCommandNativeTests: PackageCommandTestCase {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.native
}
}

class PackageCommandSwiftBuildTests: PackageCommandTestCase {

override open var buildSystemProvider: BuildSystemProvider.Kind {
return .swiftbuild
}

override func testNoParameters() async throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore (blocking): please re-add this override to ensure the tests gets "instantiated" on linux when all other tests are "fixed".

try await super.testNoParameters()
final class PackageCommandSwiftBuildTests: PackageCommandTestCase {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.swiftbuild
}

override func testCommandPluginBuildingCallbacks() async throws {
Expand Down
21 changes: 6 additions & 15 deletions Tests/CommandsTests/RunCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,24 +234,15 @@ class RunCommandTestCase: CommandsBuildProviderTestCase {

}

class RunCommandNativeTests: RunCommandTestCase {
override open var buildSystemProvider: BuildSystemProvider.Kind {
return .native
}

override func testUsage() async throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore (blocking): please re-add this override.

try await super.testUsage()
final class RunCommandNativeTests: RunCommandTestCase {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.native
}
}


class RunCommandSwiftBuildTests: RunCommandTestCase {
override open var buildSystemProvider: BuildSystemProvider.Kind {
return .swiftbuild
}

override func testUsage() async throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore (blocking): please re-add this override.

try await super.testUsage()
final class RunCommandSwiftBuildTests: RunCommandTestCase {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.swiftbuild
}

override func testMultipleExecutableAndExplicitExecutable() async throws {
Expand Down
22 changes: 6 additions & 16 deletions Tests/CommandsTests/TestCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -601,27 +601,17 @@ class TestCommandTestCase: CommandsBuildProviderTestCase {
}
}
}

}

class TestCommandNativeTests: TestCommandTestCase {
override open var buildSystemProvider: BuildSystemProvider.Kind {
return .native
}

override func testUsage() async throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore (blocking): please re-add this override.

try await super.testUsage()
final class TestCommandNativeTests: TestCommandTestCase {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.native
}
}


class TestCommandSwiftBuildTests: TestCommandTestCase {
override open var buildSystemProvider: BuildSystemProvider.Kind {
return .swiftbuild
}

override func testUsage() async throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore (blocking): please re-add this override.

try await super.testUsage()
final class TestCommandSwiftBuildTests: TestCommandTestCase {
override public var buildSystemProvider: BuildSystemProvider.Kind {
.swiftbuild
}

override func testFatalErrorDisplayedCorrectNumberOfTimesWhenSingleXCTestHasFatalErrorInBuildCompilation() async throws {
Expand Down
4 changes: 2 additions & 2 deletions Tests/PackageRegistryTests/RegistryClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ final class RegistryClientTests: XCTestCase {
let availableManifests = try await registryClient.getAvailableManifests(
package: identity,
version: version,
observabilityScope: ObservabilitySystem.NOOP,
observabilityScope: ObservabilitySystem.NOOP
)

XCTAssertEqual(availableManifests["Package.swift"]?.toolsVersion, .v5_5)
Expand Down Expand Up @@ -3987,7 +3987,7 @@ extension RegistryClient {
package: package.underlying,
version: version,
fileSystem: InMemoryFileSystem(),
observabilityScope: ObservabilitySystem.NOOP,
observabilityScope: ObservabilitySystem.NOOP
)
}

Expand Down