Skip to content

Commit ff8a19c

Browse files
authored
Tests: adjust repository test and disable on Windows (#5543)
This adds support for Windows to the compressed repository download test. Unfortunately, the repository contained within the tarball contains files which contain invalid characters for some file systems. For the time being, disable the test, though it would be preferable to limit the repository contents to that which can be represented on all file systems (perhaps consider the FAT32 restrictions which likely can cover the file systems that we are likely to run on).
1 parent c0d5daa commit ff8a19c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Tests/SourceControlTests/GitRepositoryTests.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,17 @@ class GitRepositoryTests: XCTestCase {
113113
/// `Inputs`, which has known commit hashes. See the `construct.sh` script
114114
/// contained within it for more information.
115115
func testRawRepository() throws {
116+
#if os(Windows)
117+
try XCTSkipIf(true, "test repository has non-portable file names")
118+
#endif
116119
try testWithTemporaryDirectory { path in
117120
// Unarchive the static test repository.
118121
let inputArchivePath = AbsolutePath(#file).parentDirectory.appending(components: "Inputs", "TestRepo.tgz")
122+
#if os(Windows)
123+
try systemQuietly(["tar.exe", "-x", "-v", "-C", path.pathString, "-f", inputArchivePath.pathString])
124+
#else
119125
try systemQuietly(["tar", "-x", "-v", "-C", path.pathString, "-f", inputArchivePath.pathString])
126+
#endif
120127
let testRepoPath = path.appending(component: "TestRepo")
121128

122129
// Check hash resolution.
@@ -205,7 +212,7 @@ class GitRepositoryTests: XCTestCase {
205212
try localFileSystem.createDirectory(testRepoPath.appending(component: "subdir"))
206213
try localFileSystem.writeFileContents(testRepoPath.appending(components: "subdir", "test-file-2.txt"), bytes: test2FileContents)
207214
try localFileSystem.writeFileContents(testRepoPath.appending(component: "test-file-3.sh"), bytes: test3FileContents)
208-
try! Process.checkNonZeroExit(args: "chmod", "+x", testRepoPath.appending(component: "test-file-3.sh").pathString)
215+
try localFileSystem.chmod(.executable, path: testRepoPath.appending(component: "test-file-3.sh"), options: [])
209216
let testRepo = GitRepository(path: testRepoPath)
210217
try testRepo.stage(files: "test-file-1.txt", "subdir/test-file-2.txt", "test-file-3.sh")
211218
try testRepo.commit()
@@ -230,7 +237,9 @@ class GitRepositoryTests: XCTestCase {
230237
XCTAssert(view.isFile(AbsolutePath("/test-file-1.txt")))
231238
XCTAssert(!view.isSymlink(AbsolutePath("/test-file-1.txt")))
232239
XCTAssert(!view.isExecutableFile(AbsolutePath("/does-not-exist")))
240+
#if !os(Windows)
233241
XCTAssert(view.isExecutableFile(AbsolutePath("/test-file-3.sh")))
242+
#endif
234243

235244
// Check read of a directory.
236245
let subdirPath = AbsolutePath("/subdir")

0 commit comments

Comments
 (0)