From cd9312505260c094ec39049b2de201c7e02d083c Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 9 May 2022 09:25:48 -0700 Subject: [PATCH] Tests: adjust LLBuildManifestTests expectations for Windows (#5477) This adjusts the expectations to allow Windows to be supported as well with the use of the paths more thoroughly. This identified an issue in the path handling in the manifest generation (tracked as #5475). --- Tests/BuildTests/LLBuildManifestTests.swift | 30 ++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Tests/BuildTests/LLBuildManifestTests.swift b/Tests/BuildTests/LLBuildManifestTests.swift index c9b9a564740..38445994f5b 100644 --- a/Tests/BuildTests/LLBuildManifestTests.swift +++ b/Tests/BuildTests/LLBuildManifestTests.swift @@ -20,13 +20,15 @@ final class LLBuildManifestTests: XCTestCase { func testBasics() throws { var manifest = BuildManifest() + let root: AbsolutePath = AbsolutePath("/some") + manifest.defaultTarget = "main" manifest.addPhonyCmd( name: "C.Foo", inputs: [ - .file(AbsolutePath("/some/file.c")), - .directory(AbsolutePath("/some/dir")), - .directoryStructure(AbsolutePath("/some/dir/structure")), + .file(root.appending(components: "file.c")), + .directory(root.appending(components: "dir")), + .directoryStructure(root.appending(components: "dir", "structure")), ], outputs: [.virtual("Foo")] ) @@ -38,7 +40,9 @@ final class LLBuildManifestTests: XCTestCase { let contents: String = try fs.readFileContents(AbsolutePath("/manifest.yaml")) - XCTAssertEqual(contents, """ + // FIXME(#5475) - use the platform's preferred separator for directory + // indicators + XCTAssertEqual(contents.replacingOccurrences(of: "\\\\", with: "\\"), """ client: name: basic tools: {} @@ -46,12 +50,12 @@ final class LLBuildManifestTests: XCTestCase { "main": [""] default: "main" nodes: - "/some/dir/structure/": + "\(root.appending(components: "dir", "structure"))/": is-directory-structure: true commands: "C.Foo": tool: phony - inputs: ["/some/file.c","/some/dir/","/some/dir/structure/"] + inputs: ["\(root.appending(components: "file.c"))","\(root.appending(components: "dir"))/","\(root.appending(components: "dir", "structure"))/"] outputs: [""] @@ -61,15 +65,17 @@ final class LLBuildManifestTests: XCTestCase { func testShellCommands() throws { var manifest = BuildManifest() + let root: AbsolutePath = AbsolutePath.root + manifest.defaultTarget = "main" manifest.addShellCmd( name: "shelley", description: "Shelley, Keats, and Byron", inputs: [ - .file(AbsolutePath("/file.in]")) + .file(root.appending(components: "file.in")) ], outputs: [ - .file(AbsolutePath("/file.out")) + .file(root.appending(components: "file.out")) ], arguments: [ "foo", "bar", "baz" @@ -89,18 +95,18 @@ final class LLBuildManifestTests: XCTestCase { let contents: String = try fs.readFileContents(AbsolutePath("/manifest.yaml")) - XCTAssertEqual(contents, """ + XCTAssertEqual(contents.replacingOccurrences(of: "\\\\", with: "\\"), """ client: name: basic tools: {} targets: - "main": ["/file.out"] + "main": ["\(root.appending(components: "file.out"))"] default: "main" commands: "shelley": tool: shell - inputs: ["/file.in]"] - outputs: ["/file.out"] + inputs: ["\(root.appending(components: "file.in"))"] + outputs: ["\(root.appending(components: "file.out"))"] description: "Shelley, Keats, and Byron" args: ["foo","bar","baz"] env: