From 6c8ebe37fd7bb465b316c49fa7c5949d9fa6247a Mon Sep 17 00:00:00 2001 From: Antonius Naumann Date: Fri, 9 Aug 2024 19:31:31 +0200 Subject: [PATCH] Update init tests --- testing/end-to-end/init.swift | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/testing/end-to-end/init.swift b/testing/end-to-end/init.swift index 425074a..3d3ae7f 100755 --- a/testing/end-to-end/init.swift +++ b/testing/end-to-end/init.swift @@ -13,7 +13,7 @@ func fileExists(atPath path: String) -> Bool { return exists && !isDirectory.boolValue } -print("Running tests for cargo swift init...") +print("Running tests for cargo swift init in macro mode...") let cargoSwiftInit = Process() let projectName = "ExampleProject" @@ -23,6 +23,37 @@ cargoSwiftInit.arguments = ["cargo", "swift", "init", projectName, "-y", "--sile try! cargoSwiftInit.run() cargoSwiftInit.waitUntilExit() +guard dirExists(atPath: projectName) else { + error("Project directory does not exist") + exit(1) +} +guard fileExists(atPath: "\(projectName)/Cargo.toml") else { + error("No Cargo.toml found in project directory") + exit(1) +} +guard fileExists(atPath: "\(projectName)/.gitignore") else { + error("No .gitignore found in project directory") + exit(1) +} +guard dirExists(atPath: "\(projectName)/src") else { + error("No src-directory found in project directory") + exit(1) +} +guard fileExists(atPath: "\(projectName)/src/lib.rs") else { + error("No lib.rs file found in src directory") + exit(1) +} + +print("Running tests for cargo swift init in udl mode...") + +let cargoSwiftInit = Process() +let projectName = "ExampleProject" +cargoSwiftInit.executableURL = URL(fileURLWithPath: "/usr/bin/env") +cargoSwiftInit.arguments = ["cargo", "swift", "init", projectName, "-y", "--silent", "--udl"] + +try! cargoSwiftInit.run() +cargoSwiftInit.waitUntilExit() + guard dirExists(atPath: projectName) else { error("Project directory does not exist") exit(1) @@ -47,5 +78,9 @@ guard fileExists(atPath: "\(projectName)/src/lib.rs") else { error("No lib.rs file found in src directory") exit(1) } +guard fileExists(atPath: "\(projectName)/src/lib.udl") else { + error("No lib.udl file found in src directory") + exit(1) +} print("Tests for cargo swift init passed!")