Skip to content

Fix issue with running test on windows w/no-parallel #8676

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 1 commit 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
5 changes: 2 additions & 3 deletions Tests/BasicsTests/AsyncProcessTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import struct TSCBasic.ByteString
import struct TSCBasic.Format
import class TSCBasic.Thread
import func TSCBasic.withTemporaryFile
import func TSCTestSupport.withCustomEnv

#if os(Windows)
let catExecutable = "type"
Expand Down Expand Up @@ -168,7 +167,7 @@ final class AsyncProcessTests: XCTestCase {
#endif
try localFileSystem.writeFileContents(tempExecutable, bytes: exitScriptContent)

try withCustomEnv(["PATH": tmpdir.pathString]) {
try Environment.makeCustom(["PATH": tmpdir.pathString]) {
XCTAssertEqual(AsyncProcess.findExecutable("nonExecutableProgram"), nil)
}
}
Expand All @@ -184,7 +183,7 @@ final class AsyncProcessTests: XCTestCase {

""")

try withCustomEnv(["PATH": tmpdir.pathString]) {
try Environment.makeCustom(["PATH": tmpdir.pathString]) {
do {
let process = AsyncProcess(args: "nonExecutableProgram")
try process.launch()
Expand Down
15 changes: 15 additions & 0 deletions Tests/BasicsTests/Environment/EnvironmentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Foundation
import Basics

import Testing
import _InternalTestSupport

struct EnvironmentTests {
@Test
Expand Down Expand Up @@ -144,6 +145,20 @@ struct EnvironmentTests {
#expect(Environment.current[key] == nil)
}

/// Important: This test is inherently race-prone, if it is proven to be
/// flaky, it should run in a singled threaded environment/removed entirely.
@Test
func makeCustomPathEnv() async throws {
try XCTSkipOnWindows(because: "Fails in CI due to parallel running tests", skipPlatformCi: true, skipSelfHostedCI: true)
let customEnvironment: Environment = .current
let origPath = customEnvironment[.path]

try Environment.makeCustom(["PATH": "/foo/bar"]) {
#expect(Environment.current[.path] == "/foo/bar")
}
#expect(Environment.current[.path] == origPath)
}

/// Important: This test is inherently race-prone, if it is proven to be
/// flaky, it should run in a singled threaded environment/removed entirely.
@Test
Expand Down
3 changes: 1 addition & 2 deletions Tests/FunctionalTests/TraitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ final class TraitTests: XCTestCase {
error: Disabled default traits by package 'disablingemptydefaultsexample' on package 'Package11' that declares no traits. This is prohibited to allow packages to adopt traits initially without causing an API break.

"""
XCTAssertTrue(stderr.contains(expectedErr))

XCTAssertMatch(stderr, .contains(expectedErr))
}
}
}
Expand Down