Skip to content
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

[SR-10156] Fix test_current_working_directory on macOS #2040

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions TestFoundation/TestProcess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ class TestProcess : XCTestCase {
}

func test_current_working_directory() {
#if os(macOS)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should just replace all of this with NSTemporaryDirectory().

Copy link
Author

Choose a reason for hiding this comment

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

@millenomi Thank you for the comment!

If we use,

let tmpDir = NSTemporaryDirectory()

we will get these errors.

Test Case 'TestProcess.test_current_working_directory' started at 2019-04-01 01:22:45.245
/Users/nafu/Projects/swift-source/swift-corelibs-foundation/TestFoundation/TestProcess.swift:294: error: TestProcess.test_current_working_directory : XCTAssertEqual failed: ("/private/var/folders/gw/nv0tyl695m91txy7thrdppq40000gn/T") is not equal to ("/var/folders/gw/nv0tyl695m91txy7thrdppq40000gn/T/") - 
/Users/nafu/Projects/swift-source/swift-corelibs-foundation/TestFoundation/TestProcess.swift:303: error: TestProcess.test_current_working_directory : XCTAssertEqual failed: ("/var/folders/gw/nv0tyl695m91txy7thrdppq40000gn/T") is not equal to ("/var/folders/gw/nv0tyl695m91txy7thrdppq40000gn/T/") - 

[Q] Do you think it would be better we manipulate for two cases?

  1. Add /private/ and remove last / for first failure case
  2. Remove last / for second failure case

let tmpDir = "/private/tmp"
#else
let tmpDir = "/tmp".standardizingPath
#endif

let fm = FileManager.default
let previousWorkingDirectory = fm.currentDirectoryPath
Expand Down