Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public enum MachineRecipeProvisioner {
}

private static func packageInstallScript(alpine: String, debian: String) -> String {
// Swift multiline strings drop the newline before the closing delimiter.
// A later `if` must start on a new line so ash does not see `fiif`.
"""
if command -v apk >/dev/null 2>&1; then
apk add --no-cache \(alpine)
Expand All @@ -44,7 +46,7 @@ public enum MachineRecipeProvisioner {
echo "Dory recipes support Alpine apk and Debian apt guests" >&2
exit 69
fi
"""
""" + "\n"
}

public static func recipe(id rawID: String) throws -> Recipe {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ final class MachineRecipeProvisionerTests: XCTestCase {
}
}

func testAgentCoreInstallScriptDoesNotJoinFiIntoTheFdShim() throws {
let script = try MachineRecipeProvisioner.recipe(id: "agent-core").installScript
XCTAssertFalse(script.contains("fiif"), script)
XCTAssertTrue(script.contains("fi\nif ! command -v fd"), script)
XCTAssertTrue(script.contains("exit 69\nfi\n"), script)
}

func testRequiredProvisioningStageRejectsNonzeroExitWithStderr() {
let result = DoryExecResult(
exitCode: 17,
Expand Down