Skip to content

Commit

Permalink
Update init tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniusnaumann committed Aug 9, 2024
1 parent eedab41 commit 6c8ebe3
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion testing/end-to-end/init.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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!")

0 comments on commit 6c8ebe3

Please sign in to comment.