fix: add --all to cargo fmt in script/test and autoformat codebase
cargo fmt without --all fails with "Failed to find targets" in workspace repos. This was blocking every story's gates. Also ran cargo fmt --all to fix all existing formatting issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,8 +6,8 @@ pub mod project;
|
||||
pub mod scaffold;
|
||||
|
||||
pub use files::{
|
||||
create_directory_absolute, list_directory, list_directory_absolute, list_project_files,
|
||||
read_file, write_file, FileEntry,
|
||||
FileEntry, create_directory_absolute, list_directory, list_directory_absolute,
|
||||
list_project_files, read_file, write_file,
|
||||
};
|
||||
pub use paths::{find_story_kit_root, get_home_directory, resolve_cli_path};
|
||||
pub use preferences::{get_model_preference, set_model_preference};
|
||||
|
||||
+67
-22
@@ -180,7 +180,13 @@ mod tests {
|
||||
let store = make_store(&dir);
|
||||
let state = SessionState::default();
|
||||
|
||||
let result = open_project(project_dir.to_string_lossy().to_string(), &state, &store, 3001).await;
|
||||
let result = open_project(
|
||||
project_dir.to_string_lossy().to_string(),
|
||||
&state,
|
||||
&store,
|
||||
3001,
|
||||
)
|
||||
.await;
|
||||
|
||||
assert!(result.is_ok());
|
||||
let root = state.get_project_root().unwrap();
|
||||
@@ -201,9 +207,14 @@ mod tests {
|
||||
let store = make_store(&dir);
|
||||
let state = SessionState::default();
|
||||
|
||||
open_project(project_dir.to_string_lossy().to_string(), &state, &store, 3001)
|
||||
.await
|
||||
.unwrap();
|
||||
open_project(
|
||||
project_dir.to_string_lossy().to_string(),
|
||||
&state,
|
||||
&store,
|
||||
3001,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
fs::read_to_string(&mcp_path).unwrap(),
|
||||
@@ -220,15 +231,29 @@ mod tests {
|
||||
let store = make_store(&dir);
|
||||
let state = SessionState::default();
|
||||
|
||||
open_project(project_dir.to_string_lossy().to_string(), &state, &store, 3001)
|
||||
.await
|
||||
.unwrap();
|
||||
open_project(
|
||||
project_dir.to_string_lossy().to_string(),
|
||||
&state,
|
||||
&store,
|
||||
3001,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mcp_path = project_dir.join(".mcp.json");
|
||||
assert!(mcp_path.exists(), "open_project should write .mcp.json for new projects");
|
||||
assert!(
|
||||
mcp_path.exists(),
|
||||
"open_project should write .mcp.json for new projects"
|
||||
);
|
||||
let content = fs::read_to_string(&mcp_path).unwrap();
|
||||
assert!(content.contains("3001"), "mcp.json should reference the server port");
|
||||
assert!(content.contains("localhost"), "mcp.json should reference localhost");
|
||||
assert!(
|
||||
content.contains("3001"),
|
||||
"mcp.json should reference the server port"
|
||||
);
|
||||
assert!(
|
||||
content.contains("localhost"),
|
||||
"mcp.json should reference localhost"
|
||||
);
|
||||
}
|
||||
|
||||
/// Regression test for bug 371: no-arg `huskies` in empty directory skips scaffold.
|
||||
@@ -242,9 +267,14 @@ mod tests {
|
||||
let store = make_store(&dir);
|
||||
let state = SessionState::default();
|
||||
|
||||
open_project(project_dir.to_string_lossy().to_string(), &state, &store, 3001)
|
||||
.await
|
||||
.unwrap();
|
||||
open_project(
|
||||
project_dir.to_string_lossy().to_string(),
|
||||
&state,
|
||||
&store,
|
||||
3001,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
project_dir.join(".huskies/project.toml").exists(),
|
||||
@@ -316,9 +346,14 @@ mod tests {
|
||||
let store = make_store(&dir);
|
||||
let state = SessionState::default();
|
||||
|
||||
open_project(project_dir.to_string_lossy().to_string(), &state, &store, 3001)
|
||||
.await
|
||||
.unwrap();
|
||||
open_project(
|
||||
project_dir.to_string_lossy().to_string(),
|
||||
&state,
|
||||
&store,
|
||||
3001,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let projects = get_known_projects(&store).unwrap();
|
||||
assert_eq!(projects.len(), 1);
|
||||
@@ -383,9 +418,14 @@ mod tests {
|
||||
let store = make_store(&dir);
|
||||
let state = SessionState::default();
|
||||
|
||||
open_project(project_dir.to_string_lossy().to_string(), &state, &store, 3001)
|
||||
.await
|
||||
.unwrap();
|
||||
open_project(
|
||||
project_dir.to_string_lossy().to_string(),
|
||||
&state,
|
||||
&store,
|
||||
3001,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// .huskies/ should have been created automatically
|
||||
assert!(project_dir.join(".huskies").is_dir());
|
||||
@@ -402,9 +442,14 @@ mod tests {
|
||||
let store = make_store(&dir);
|
||||
let state = SessionState::default();
|
||||
|
||||
open_project(project_dir.to_string_lossy().to_string(), &state, &store, 3001)
|
||||
.await
|
||||
.unwrap();
|
||||
open_project(
|
||||
project_dir.to_string_lossy().to_string(),
|
||||
&state,
|
||||
&store,
|
||||
3001,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Existing .huskies/ content should not be overwritten
|
||||
assert_eq!(fs::read_to_string(&readme).unwrap(), "custom content");
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::path::Path;
|
||||
|
||||
const STORY_KIT_README: &str = include_str!("../../../../.huskies/README.md");
|
||||
|
||||
const BOT_TOML_MATRIX_EXAMPLE: &str =
|
||||
include_str!("../../../../.huskies/bot.toml.matrix.example");
|
||||
const BOT_TOML_MATRIX_EXAMPLE: &str = include_str!("../../../../.huskies/bot.toml.matrix.example");
|
||||
const BOT_TOML_WHATSAPP_META_EXAMPLE: &str =
|
||||
include_str!("../../../../.huskies/bot.toml.whatsapp-meta.example");
|
||||
const BOT_TOML_WHATSAPP_TWILIO_EXAMPLE: &str =
|
||||
@@ -194,9 +193,7 @@ pub fn detect_components_toml(root: &Path) -> String {
|
||||
// No tech stack markers detected — emit a single generic component
|
||||
// with an empty setup list. The ONBOARDING_PROMPT instructs the chat
|
||||
// agent to inspect the project and replace this with real definitions.
|
||||
sections.push(
|
||||
"[[component]]\nname = \"app\"\npath = \".\"\nsetup = []\n".to_string(),
|
||||
);
|
||||
sections.push("[[component]]\nname = \"app\"\npath = \".\"\nsetup = []\n".to_string());
|
||||
}
|
||||
|
||||
sections.join("\n")
|
||||
@@ -826,9 +823,18 @@ mod tests {
|
||||
let mcp_path = dir.path().join(".mcp.json");
|
||||
assert!(mcp_path.exists(), ".mcp.json should be created by scaffold");
|
||||
let content = fs::read_to_string(&mcp_path).unwrap();
|
||||
assert!(content.contains("4242"), ".mcp.json should reference the given port");
|
||||
assert!(content.contains("localhost"), ".mcp.json should reference localhost");
|
||||
assert!(content.contains("huskies"), ".mcp.json should name the huskies server");
|
||||
assert!(
|
||||
content.contains("4242"),
|
||||
".mcp.json should reference the given port"
|
||||
);
|
||||
assert!(
|
||||
content.contains("localhost"),
|
||||
".mcp.json should reference localhost"
|
||||
);
|
||||
assert!(
|
||||
content.contains("huskies"),
|
||||
".mcp.json should name the huskies server"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -976,7 +982,10 @@ mod tests {
|
||||
fs::write(dir.path().join("go.mod"), "module example.com/app\n").unwrap();
|
||||
|
||||
let toml = detect_components_toml(dir.path());
|
||||
assert!(!toml.contains("cargo"), "go project must not contain cargo commands");
|
||||
assert!(
|
||||
!toml.contains("cargo"),
|
||||
"go project must not contain cargo commands"
|
||||
);
|
||||
assert!(toml.contains("go build"), "go project must use Go tooling");
|
||||
}
|
||||
|
||||
@@ -986,8 +995,14 @@ mod tests {
|
||||
fs::write(dir.path().join("package.json"), "{}").unwrap();
|
||||
|
||||
let toml = detect_components_toml(dir.path());
|
||||
assert!(!toml.contains("cargo"), "node project must not contain cargo commands");
|
||||
assert!(toml.contains("npm install"), "node project must use npm tooling");
|
||||
assert!(
|
||||
!toml.contains("cargo"),
|
||||
"node project must not contain cargo commands"
|
||||
);
|
||||
assert!(
|
||||
toml.contains("npm install"),
|
||||
"node project must use npm tooling"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -995,9 +1010,15 @@ mod tests {
|
||||
let dir = tempdir().unwrap();
|
||||
|
||||
let toml = detect_components_toml(dir.path());
|
||||
assert!(!toml.contains("cargo"), "unknown stack must not contain cargo commands");
|
||||
assert!(
|
||||
!toml.contains("cargo"),
|
||||
"unknown stack must not contain cargo commands"
|
||||
);
|
||||
// setup list must be empty
|
||||
assert!(toml.contains("setup = []"), "unknown stack must have empty setup list");
|
||||
assert!(
|
||||
toml.contains("setup = []"),
|
||||
"unknown stack must have empty setup list"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1047,7 +1068,10 @@ mod tests {
|
||||
fs::write(dir.path().join("Cargo.toml"), "[package]\nname = \"x\"\n").unwrap();
|
||||
|
||||
let script = detect_script_test(dir.path());
|
||||
assert!(script.contains("cargo test"), "Rust project should run cargo test");
|
||||
assert!(
|
||||
script.contains("cargo test"),
|
||||
"Rust project should run cargo test"
|
||||
);
|
||||
assert!(!script.contains("No tests configured"));
|
||||
}
|
||||
|
||||
@@ -1057,7 +1081,10 @@ mod tests {
|
||||
fs::write(dir.path().join("package.json"), "{}").unwrap();
|
||||
|
||||
let script = detect_script_test(dir.path());
|
||||
assert!(script.contains("npm test"), "Node project without pnpm-lock should run npm test");
|
||||
assert!(
|
||||
script.contains("npm test"),
|
||||
"Node project without pnpm-lock should run npm test"
|
||||
);
|
||||
assert!(!script.contains("No tests configured"));
|
||||
}
|
||||
|
||||
@@ -1068,18 +1095,31 @@ mod tests {
|
||||
fs::write(dir.path().join("pnpm-lock.yaml"), "").unwrap();
|
||||
|
||||
let script = detect_script_test(dir.path());
|
||||
assert!(script.contains("pnpm test"), "Node project with pnpm-lock should run pnpm test");
|
||||
assert!(
|
||||
script.contains("pnpm test"),
|
||||
"Node project with pnpm-lock should run pnpm test"
|
||||
);
|
||||
// "pnpm test" is a substring of itself; verify there's no bare "npm test" line
|
||||
assert!(!script.lines().any(|l| l.trim() == "npm test"), "should not use npm when pnpm-lock.yaml is present");
|
||||
assert!(
|
||||
!script.lines().any(|l| l.trim() == "npm test"),
|
||||
"should not use npm when pnpm-lock.yaml is present"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detect_script_test_pyproject_toml_adds_pytest() {
|
||||
let dir = tempdir().unwrap();
|
||||
fs::write(dir.path().join("pyproject.toml"), "[project]\nname = \"x\"\n").unwrap();
|
||||
fs::write(
|
||||
dir.path().join("pyproject.toml"),
|
||||
"[project]\nname = \"x\"\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let script = detect_script_test(dir.path());
|
||||
assert!(script.contains("pytest"), "Python project should run pytest");
|
||||
assert!(
|
||||
script.contains("pytest"),
|
||||
"Python project should run pytest"
|
||||
);
|
||||
assert!(!script.contains("No tests configured"));
|
||||
}
|
||||
|
||||
@@ -1089,7 +1129,10 @@ mod tests {
|
||||
fs::write(dir.path().join("requirements.txt"), "flask\n").unwrap();
|
||||
|
||||
let script = detect_script_test(dir.path());
|
||||
assert!(script.contains("pytest"), "Python project (requirements.txt) should run pytest");
|
||||
assert!(
|
||||
script.contains("pytest"),
|
||||
"Python project (requirements.txt) should run pytest"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1098,7 +1141,10 @@ mod tests {
|
||||
fs::write(dir.path().join("go.mod"), "module example.com/app\n").unwrap();
|
||||
|
||||
let script = detect_script_test(dir.path());
|
||||
assert!(script.contains("go test ./..."), "Go project should run go test ./...");
|
||||
assert!(
|
||||
script.contains("go test ./..."),
|
||||
"Go project should run go test ./..."
|
||||
);
|
||||
assert!(!script.contains("No tests configured"));
|
||||
}
|
||||
|
||||
@@ -1109,8 +1155,14 @@ mod tests {
|
||||
fs::write(dir.path().join("package.json"), "{}").unwrap();
|
||||
|
||||
let script = detect_script_test(dir.path());
|
||||
assert!(script.contains("go test ./..."), "multi-stack should include Go test command");
|
||||
assert!(script.contains("npm test"), "multi-stack should include Node test command");
|
||||
assert!(
|
||||
script.contains("go test ./..."),
|
||||
"multi-stack should include Go test command"
|
||||
);
|
||||
assert!(
|
||||
script.contains("npm test"),
|
||||
"multi-stack should include Node test command"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1128,13 +1180,23 @@ mod tests {
|
||||
#[test]
|
||||
fn scaffold_script_test_contains_detected_commands_for_rust() {
|
||||
let dir = tempdir().unwrap();
|
||||
fs::write(dir.path().join("Cargo.toml"), "[package]\nname = \"myapp\"\n").unwrap();
|
||||
fs::write(
|
||||
dir.path().join("Cargo.toml"),
|
||||
"[package]\nname = \"myapp\"\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
scaffold_story_kit(dir.path(), 3001).unwrap();
|
||||
|
||||
let content = fs::read_to_string(dir.path().join("script/test")).unwrap();
|
||||
assert!(content.contains("cargo test"), "Rust project scaffold should set cargo test in script/test");
|
||||
assert!(!content.contains("No tests configured"), "should not use stub when stack is detected");
|
||||
assert!(
|
||||
content.contains("cargo test"),
|
||||
"Rust project scaffold should set cargo test in script/test"
|
||||
);
|
||||
assert!(
|
||||
!content.contains("No tests configured"),
|
||||
"should not use stub when stack is detected"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1143,7 +1205,10 @@ mod tests {
|
||||
scaffold_story_kit(dir.path(), 3001).unwrap();
|
||||
|
||||
let content = fs::read_to_string(dir.path().join("script/test")).unwrap();
|
||||
assert!(content.contains("No tests configured"), "unknown stack should use the generic stub");
|
||||
assert!(
|
||||
content.contains("No tests configured"),
|
||||
"unknown stack should use the generic stub"
|
||||
);
|
||||
}
|
||||
|
||||
// --- generate_project_toml ---
|
||||
|
||||
Reference in New Issue
Block a user