Skip to content
Merged
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
32 changes: 27 additions & 5 deletions Tests/IntegrationTests/BasicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,31 @@ private struct BasicTests {
Tag.Feature.Command.Build,
),
)
func testExamplePackageDealer() throws {
try withTemporaryDirectory { tempDir in
func testExamplePackageDealer() async throws {
try await withTemporaryDirectory { tempDir in
let packagePath = tempDir.appending(component: "dealer")
let repoToClone = "https://github.com/swiftlang/example-package-dealer"
withKnownIssue(isIntermittent: true) {
// marking as withKnownIssue(intermittent: trye) as git operation can fail.
try sh("git\(ProcessInfo.exeSuffix)", "clone", "https://github.com/apple/example-package-dealer", packagePath)
// marking as withKnownIssue(intermittent: true) as git operation can fail.

#if os(macOS)
// On macOS, we add the HOME variable to avoid git errors.
try sh("git\(ProcessInfo.exeSuffix)", "clone", repoToClone, packagePath, env: ["HOME": tempDir.pathString])
#else
try sh("git\(ProcessInfo.exeSuffix)", "clone", repoToClone, packagePath)
#endif
}

// Do not run the test when the git clone operation failed
if !FileManager.default.fileExists(atPath: packagePath.pathString) {
//TODO: use Test Cancellation when available
//https://forums.swift.org/t/pitch-test-cancellation/81847/18
#if compiler(>=6.3)
Issue.record("Can't clone the repository \(repoToClone), abording the test.", severity: .warning)
#endif
return
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not fond of this as it gives the impression the tests passes, when it wasn't executed at all. We should include a TODO to use the Test cancellation feature once it's available.

https://forums.swift.org/t/pitch-test-cancellation/81847/18

In the meantime, can we record a warning Issue.record("....", severity: .warning) as introduced by https://forums.swift.org/t/accepted-st-0013-test-issue-severity/81385/2 (though our self-hosted pipelines doesn't currently use a version of the toolchain that has these features)

Copy link
Contributor Author

@sebsto sebsto Sep 16, 2025

Choose a reason for hiding this comment

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

I added this code to record the issue, only when compiling with Swift 6.3 or more recent

#if compiler(>=6.3)
   Issue.record("Can't clone the repository \(repoToClone), abording the test.", severity: .warning)
#endif

}

let build1Output = try await executeSwiftBuild(
packagePath,
buildSystem: .native,
Expand All @@ -59,7 +77,11 @@ private struct BasicTests {
buildSystem: .native,
).stdout
#expect(build2Output.contains("Build complete"))
#expect(build2Output.contains("Compiling") == false)

// Check that no compilation happened (except for plugins which are allowed)
// catch "Compiling xxx" but ignore "Compiling plugin" messages
let compilingRegex = try Regex("Compiling (?!plugin)")
#expect(build2Output.contains(compilingRegex) == false)
}
}

Expand Down