Skip to content

[6.1] Update build-using-self for CI. #8567

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

Closed
wants to merge 4 commits into from
Closed
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
51 changes: 27 additions & 24 deletions IntegrationTests/Tests/IntegrationTests/XCBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,18 @@ final class XCBuildTests: XCTestCase {

try sh(swiftBuild, "--package-path", fooPath, "--build-system", "xcode")
let debugPath = binaryPath.appending(component: "Debug")
XCTAssertFileExists(debugPath.appending(component: "FooLib_Module.o"))
XCTAssertFileExists(debugPath.appending(component: "CFooLib_Module.o"))
XCTAssertFileExists(debugPath.appending(component: "BarLib_Module.o"))
let (stdout, stderr) = try sh("ls", debugPath.pathString)
print("ls:", stdout)
print("err:", stderr)
XCTAssertFileExists(debugPath.appending(component: "FooLib.o"))
XCTAssertFileExists(debugPath.appending(component: "CFooLib.o"))
XCTAssertFileExists(debugPath.appending(component: "BarLib.o"))

try sh(swiftBuild, "--package-path", fooPath, "--build-system", "xcode", "-c", "release")
let releasePath = binaryPath.appending(component: "Release")
XCTAssertFileExists(releasePath.appending(component: "FooLib_Module.o"))
XCTAssertFileExists(releasePath.appending(component: "CFooLib_Module.o"))
XCTAssertFileExists(releasePath.appending(component: "BarLib_Module.o"))
XCTAssertFileExists(releasePath.appending(component: "FooLib.o"))
XCTAssertFileExists(releasePath.appending(component: "CFooLib.o"))
XCTAssertFileExists(releasePath.appending(component: "BarLib.o"))
}

fixture(name: "XCBuild/Libraries") { path in
Expand All @@ -226,15 +229,15 @@ final class XCBuildTests: XCTestCase {

try sh(swiftBuild, "--package-path", fooPath, "--build-system", "xcode", "--target", "FooLib")
let debugPath = binaryPath.appending(component: "Debug")
XCTAssertFileExists(debugPath.appending(component: "FooLib_Module.o"))
XCTAssertFileExists(debugPath.appending(component: "CFooLib_Module.o"))
XCTAssertFileExists(debugPath.appending(component: "BarLib_Module.o"))
XCTAssertFileExists(debugPath.appending(component: "FooLib.o"))
XCTAssertFileExists(debugPath.appending(component: "CFooLib.o"))
XCTAssertFileExists(debugPath.appending(component: "BarLib.o"))

try sh(swiftBuild, "--package-path", fooPath, "--build-system", "xcode", "--target", "FooLib", "-c", "release")
let releasePath = binaryPath.appending(component: "Release")
XCTAssertFileExists(releasePath.appending(component: "FooLib_Module.o"))
XCTAssertFileExists(releasePath.appending(component: "CFooLib_Module.o"))
XCTAssertFileExists(releasePath.appending(component: "BarLib_Module.o"))
XCTAssertFileExists(releasePath.appending(component: "FooLib.o"))
XCTAssertFileExists(releasePath.appending(component: "CFooLib.o"))
XCTAssertFileExists(releasePath.appending(component: "BarLib.o"))
}

fixture(name: "XCBuild/Libraries") { path in
Expand All @@ -243,15 +246,15 @@ final class XCBuildTests: XCTestCase {

try sh(swiftBuild, "--package-path", fooPath, "--build-system", "xcode", "--target", "CFooLib")
let debugPath = binaryPath.appending(component: "Debug")
XCTAssertNoSuchPath(debugPath.appending(component: "FooLib_Module.o"))
XCTAssertFileExists(debugPath.appending(component: "CFooLib_Module.o"))
XCTAssertFileExists(debugPath.appending(component: "BarLib_Module.o"))
XCTAssertNoSuchPath(debugPath.appending(component: "FooLib.o"))
XCTAssertFileExists(debugPath.appending(component: "CFooLib.o"))
XCTAssertFileExists(debugPath.appending(component: "BarLib.o"))

try sh(swiftBuild, "--package-path", fooPath, "--build-system", "xcode", "--target", "CFooLib", "-c", "release")
let releasePath = binaryPath.appending(component: "Release")
XCTAssertNoSuchPath(releasePath.appending(component: "FooLib_Module.o"))
XCTAssertFileExists(releasePath.appending(component: "CFooLib_Module.o"))
XCTAssertFileExists(releasePath.appending(component: "BarLib_Module.o"))
XCTAssertNoSuchPath(releasePath.appending(component: "FooLib.o"))
XCTAssertFileExists(releasePath.appending(component: "CFooLib.o"))
XCTAssertFileExists(releasePath.appending(component: "BarLib.o"))
}

fixture(name: "XCBuild/Libraries") { path in
Expand All @@ -260,15 +263,15 @@ final class XCBuildTests: XCTestCase {

try sh(swiftBuild, "--package-path", fooPath, "--build-system", "xcode", "--target", "BarLib")
let debugPath = binaryPath.appending(component: "Debug")
XCTAssertNoSuchPath(debugPath.appending(component: "FooLib_Module.o"))
XCTAssertNoSuchPath(debugPath.appending(component: "CFooLib_Module.o"))
XCTAssertFileExists(debugPath.appending(component: "BarLib_Module.o"))
XCTAssertNoSuchPath(debugPath.appending(component: "FooLib.o"))
XCTAssertNoSuchPath(debugPath.appending(component: "CFooLib.o"))
XCTAssertFileExists(debugPath.appending(component: "BarLib.o"))

try sh(swiftBuild, "--package-path", fooPath, "--build-system", "xcode", "--target", "BarLib", "-c", "release")
let releasePath = binaryPath.appending(component: "Release")
XCTAssertNoSuchPath(releasePath.appending(component: "FooLib_Module.o"))
XCTAssertNoSuchPath(releasePath.appending(component: "CFooLib_Module.o"))
XCTAssertFileExists(releasePath.appending(component: "BarLib_Module.o"))
XCTAssertNoSuchPath(releasePath.appending(component: "FooLib.o"))
XCTAssertNoSuchPath(releasePath.appending(component: "CFooLib.o"))
XCTAssertFileExists(releasePath.appending(component: "BarLib.o"))
}
}

Expand Down
8 changes: 8 additions & 0 deletions Sources/_InternalTestSupport/XCTAssertHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public func XCTSkipIfCI(file: StaticString = #filePath, line: UInt = #line) thro
}
}

public func XCTSkipIfWindowsCI(file: StaticString = #filePath, line: UInt = #line) throws {
#if os(Windows)
if ProcessInfo.processInfo.environment["SWIFTCI_IS_SELF_HOSTED"] != nil {
throw XCTSkip("Skipping because the test is being run on CI", file: file, line: line)
}
#endif
}

/// An `async`-friendly replacement for `XCTAssertThrowsError`.
public func XCTAssertAsyncThrowsError<T>(
_ expression: @autoclosure () async throws -> T,
Expand Down
5 changes: 5 additions & 0 deletions Tests/SourceControlTests/GitRepositoryProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import XCTest

class GitRepositoryProviderTests: XCTestCase {
func testIsValidDirectory() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { sandbox in
let provider = GitRepositoryProvider()

Expand All @@ -42,6 +43,7 @@ class GitRepositoryProviderTests: XCTestCase {
}

func testIsValidDirectoryThrowsPrintableError() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { temp in
let provider = GitRepositoryProvider()
let expectedErrorMessage = "not a git repository"
Expand All @@ -56,6 +58,7 @@ class GitRepositoryProviderTests: XCTestCase {
}

func testGitShellErrorIsPrintable() throws {
try XCTSkipIfWindowsCI()
let stdOut = "An error from Git - stdout"
let stdErr = "An error from Git - stderr"
let arguments = ["git", "error"]
Expand Down Expand Up @@ -84,6 +87,7 @@ class GitRepositoryProviderTests: XCTestCase {
}

func testGitShellErrorEmptyStdOut() throws {
try XCTSkipIfWindowsCI()
let stdErr = "An error from Git - stderr"
let result = AsyncProcessResult(
arguments: ["git", "error"],
Expand All @@ -101,6 +105,7 @@ class GitRepositoryProviderTests: XCTestCase {
}

func testGitShellErrorEmptyStdErr() throws {
try XCTSkipIfWindowsCI()
let stdOut = "An error from Git - stdout"
let result = AsyncProcessResult(
arguments: ["git", "error"],
Expand Down
19 changes: 19 additions & 0 deletions Tests/SourceControlTests/GitRepositoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class GitRepositoryTests: XCTestCase {

/// Test the basic provider functions.
func testProvider() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
let testRepoPath = path.appending("test-repo")
try! makeDirectories(testRepoPath)
Expand Down Expand Up @@ -187,6 +188,7 @@ class GitRepositoryTests: XCTestCase {
}

func testSubmoduleRead() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
let testRepoPath = path.appending("test-repo")
try makeDirectories(testRepoPath)
Expand All @@ -210,6 +212,7 @@ class GitRepositoryTests: XCTestCase {

/// Test the Git file system view.
func testGitFileView() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
let testRepoPath = path.appending("test-repo")
try makeDirectories(testRepoPath)
Expand Down Expand Up @@ -298,6 +301,7 @@ class GitRepositoryTests: XCTestCase {

/// Test the handling of local checkouts.
func testCheckouts() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a test repository.
let testRepoPath = path.appending("test-repo")
Expand Down Expand Up @@ -344,6 +348,7 @@ class GitRepositoryTests: XCTestCase {
}

func testFetch() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a repo.
let testRepoPath = path.appending("test-repo")
Expand Down Expand Up @@ -383,6 +388,7 @@ class GitRepositoryTests: XCTestCase {
}

func testHasUnpushedCommits() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a repo.
let testRepoPath = path.appending("test-repo")
Expand Down Expand Up @@ -419,6 +425,7 @@ class GitRepositoryTests: XCTestCase {
}

func testSetRemote() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a repo.
let testRepoPath = path.appending("test-repo")
Expand Down Expand Up @@ -449,6 +456,7 @@ class GitRepositoryTests: XCTestCase {
}

func testUncommittedChanges() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a repo.
let testRepoPath = path.appending("test-repo")
Expand Down Expand Up @@ -476,6 +484,7 @@ class GitRepositoryTests: XCTestCase {
}

func testBranchOperations() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a repo.
let testRepoPath = path.appending("test-repo")
Expand Down Expand Up @@ -506,6 +515,7 @@ class GitRepositoryTests: XCTestCase {
}

func testRevisionOperations() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a repo.
let repositoryPath = path.appending("test-repo")
Expand All @@ -531,6 +541,7 @@ class GitRepositoryTests: XCTestCase {
}

func testCheckoutRevision() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a repo.
let testRepoPath = path.appending("test-repo")
Expand Down Expand Up @@ -574,6 +585,7 @@ class GitRepositoryTests: XCTestCase {
}

func testSubmodules() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
let provider = GitRepositoryProvider()

Expand Down Expand Up @@ -663,6 +675,7 @@ class GitRepositoryTests: XCTestCase {
}

func testAlternativeObjectStoreValidation() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a repo.
let testRepoPath = path.appending("test-repo")
Expand Down Expand Up @@ -696,6 +709,7 @@ class GitRepositoryTests: XCTestCase {
}

func testAreIgnored() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a repo.
let testRepoPath = path.appending("test_repo")
Expand All @@ -717,6 +731,7 @@ class GitRepositoryTests: XCTestCase {
}

func testAreIgnoredWithSpaceInRepoPath() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a repo.
let testRepoPath = path.appending("test repo")
Expand All @@ -733,6 +748,7 @@ class GitRepositoryTests: XCTestCase {
}

func testMissingDefaultBranch() throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { path in
// Create a repository.
let testRepoPath = path.appending("test-repo")
Expand Down Expand Up @@ -770,6 +786,7 @@ class GitRepositoryTests: XCTestCase {
}

func testValidDirectoryLocalRelativeOrigin() async throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { tmpDir in
// Create a repository.
let packageDir = tmpDir.appending("SomePackage")
Expand Down Expand Up @@ -816,6 +833,7 @@ class GitRepositoryTests: XCTestCase {
}

func testValidDirectoryLocalAbsoluteOrigin() async throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { tmpDir in
// Create a repository.
let packageDir = tmpDir.appending("SomePackage")
Expand Down Expand Up @@ -866,6 +884,7 @@ class GitRepositoryTests: XCTestCase {
}

func testValidDirectoryRemoteOrigin() async throws {
try XCTSkipIfWindowsCI()
try testWithTemporaryDirectory { tmpDir in
// Create a repository.
let packageDir = tmpDir.appending("SomePackage")
Expand Down
Loading