Merge branch 'v3' into v3-t90

This commit is contained in:
2026-11-12 08:46:33 +00:00
5 changed files with 225 additions and 15 deletions
+78 -1
View File
@@ -60,7 +60,8 @@ async fn init_seeds_config_tools_and_one_source_commit() -> anyhow::Result<()> {
"etc/sausage/config.yaml",
include_str!("../../../config/config.yaml"),
)?;
let destination = dir.path().join("new-world");
write(&bundle, "srv/www/index.html", "World page")?;
let destination = dir.path().join("new world");
let initialized = std::process::Command::new(env!("CARGO_BIN_EXE_sausage"))
.arg("init")
.arg(&destination)
@@ -75,6 +76,36 @@ async fn init_seeds_config_tools_and_one_source_commit() -> anyhow::Result<()> {
"{}",
String::from_utf8_lossy(&initialized.stderr)
);
assert!(initialized.stdout.is_empty());
let stderr = String::from_utf8(initialized.stderr)?;
let lines: Vec<_> = stderr.lines().collect();
assert_eq!(
lines,
[
format!("Create world folder: {}", destination.display()),
"Copy tools: 1".into(),
"Create /src/sausage".into(),
"Seed /etc and /srv/www".into(),
format!(
"Write config: {}",
destination.join("world/etc/sausage/config.yaml").display()
),
"Precompile tools 0/1".into(),
"Precompile tools 1/1".into(),
"Create the first commit in /src/sausage".into(),
"Next steps:".into(),
format!(
" Edit {} to configure providers and API keys.",
destination.join("world/etc/sausage/config.yaml").display()
),
format!(" sausage run '{}'", destination.display()),
]
);
assert!(!stderr.contains(['\r', '\x1b']));
assert_eq!(
std::fs::read_to_string(destination.join("world/srv/www/index.html"))?,
"World page"
);
let world = World::open(&destination)?;
assert!(destination.join("world/bin/git").exists());
let config = world
@@ -112,6 +143,52 @@ async fn init_seeds_config_tools_and_one_source_commit() -> anyhow::Result<()> {
Ok(())
}
#[test]
fn init_errors_name_the_failed_step() -> anyhow::Result<()> {
let dir = tempfile::tempdir()?;
let bundle = dir.path().join("bundle");
for (name, expected) in [
("missing", "Copy tools failed"),
("invalid", "Precompile tools failed"),
] {
if name == "invalid" {
write(&bundle, "bin/invalid.wasm", "not a component")?;
write(&bundle, "src/sausage/README.md", "Source")?;
}
let output = std::process::Command::new(env!("CARGO_BIN_EXE_sausage"))
.arg("init")
.arg(dir.path().join(name))
.arg("--userland")
.arg(&bundle)
.output()?;
assert!(!output.status.success());
assert!(output.stdout.is_empty());
let stderr = String::from_utf8(output.stderr)?;
assert!(stderr.contains(expected), "{stderr}");
assert!(!stderr.contains("Next steps:"), "{stderr}");
if name == "invalid" {
assert!(stderr.contains("/bin/invalid.wasm"), "{stderr}");
}
}
Ok(())
}
#[test]
fn run_does_not_print_init_progress() -> anyhow::Result<()> {
let dir = tempfile::tempdir()?;
let output = std::process::Command::new(env!("CARGO_BIN_EXE_sausage"))
.arg("run")
.arg(dir.path())
.output()?;
assert!(!output.status.success());
assert!(output.stdout.is_empty());
let stderr = String::from_utf8(output.stderr)?;
assert!(stderr.starts_with("Error: No world at "), "{stderr}");
assert!(!stderr.contains("Create world folder"));
assert!(!stderr.contains("Next steps:"));
Ok(())
}
#[tokio::test(flavor = "current_thread")]
async fn core_extensions() -> anyhow::Result<()> {
let repo = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap();