mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-06 02:48:25 +00:00
Phase 2/3 of the std::fs lint initiative (Phase 1 refactors landed in
commit 9d1c0d98c).
clippy.toml additions (appended to disallowed-methods):
std::fs::read, read_to_string, write, read_dir, copy, canonicalize
std::fs::File::open, File::create, File::create_new
std::fs::OpenOptions::open
File::options was deliberately excluded — it returns an OpenOptions
builder with no syscall. OpenOptions::open is where the block happens.
Non-blocking std::fs items (metadata, exists, create_dir_all, remove_*,
rename, and all std::fs types) remain legal.
Annotation policy (per updated plan):
- Mixed async/sync production source: function- or statement-scoped
#[expect(...)] so future accidental Tokio-path regressions in the
same file still fire.
- Fully-sync production source, test modules, integration tests,
build.rs: file-level #![expect(...)].
- Every #[expect] has a specific reason identifying the sync context.
Annotations added in ~90 files across the workspace. Notable narrow
placements: fabro-server server.rs current_server_target,
build_disk_usage_response, create_test_app_state_with_session_key;
fabro-server install.rs read_to_string rollback snapshot;
fabro-sandbox local.rs list_recursive; fabro-agent cli.rs FOLLOW-UP on
the JSON-stdout writer; fabro-llm providers/common.rs FOLLOW-UP for
load_file_as_base64 (7 translator call sites; revisit if file:// URL
usage grows).
build.rs blanket allows: fabro-api/build.rs, fabro-util/build.rs.
Pre-existing unrelated nightly-clippy warnings fixed under scope:
fabro-sandbox sandbox_spec.rs (unused_imports, unused_async),
reconnect.rs (unused_variables, unused_async).
Verified: cargo +nightly-2026-04-14 clippy --workspace --all-targets
-- -D warnings passes; fmt clean; 4129/4131 tests pass (two known
flakes under parallel nextest load, both pass individually and are
unrelated to this change).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
142 lines
3.9 KiB
Rust
142 lines
3.9 KiB
Rust
#![expect(
|
|
clippy::disallowed_methods,
|
|
reason = "integration tests stage fixtures with sync std::fs; test infrastructure, not Tokio-hot path"
|
|
)]
|
|
|
|
use fabro_test::{fabro_snapshot, test_context};
|
|
use insta::assert_snapshot;
|
|
|
|
#[test]
|
|
fn help() {
|
|
let context = test_context!();
|
|
let mut cmd = context.command();
|
|
cmd.args(["repo", "init", "--help"]);
|
|
fabro_snapshot!(context.filters(), cmd, @"
|
|
success: true
|
|
exit_code: 0
|
|
----- stdout -----
|
|
Initialize a new project
|
|
|
|
Usage: fabro repo init [OPTIONS]
|
|
|
|
Options:
|
|
--json Output as JSON [env: FABRO_JSON=]
|
|
--server <SERVER> Fabro server target: http(s) URL or absolute Unix socket path [env: FABRO_SERVER=]
|
|
--debug Enable DEBUG-level logging (default is INFO) [env: FABRO_DEBUG=]
|
|
--no-upgrade-check Disable automatic upgrade check [env: FABRO_NO_UPGRADE_CHECK=true]
|
|
--quiet Suppress non-essential output [env: FABRO_QUIET=]
|
|
--verbose Enable verbose output [env: FABRO_VERBOSE=]
|
|
-h, --help Print help
|
|
----- stderr -----
|
|
");
|
|
}
|
|
|
|
#[test]
|
|
fn repo_init_creates_project_toml_and_hello_workflow() {
|
|
let context = test_context!();
|
|
context.git_init();
|
|
|
|
let mut cmd = context.command();
|
|
cmd.args(["repo", "init"]);
|
|
|
|
fabro_snapshot!(context.filters(), cmd, @"
|
|
success: true
|
|
exit_code: 0
|
|
----- stdout -----
|
|
----- stderr -----
|
|
✔ .fabro/project.toml
|
|
✔ .fabro/workflows/hello/workflow.fabro
|
|
✔ .fabro/workflows/hello/workflow.toml
|
|
|
|
Project initialized! Run a workflow with:
|
|
|
|
fabro run hello
|
|
|
|
! No git remote found — skipping GitHub check
|
|
Run `git remote add origin <url>`, then `gh auth login` or `fabro install` to configure GitHub access
|
|
");
|
|
|
|
assert_snapshot!(
|
|
std::fs::read_to_string(context.temp_dir.join(".fabro/project.toml")).unwrap(),
|
|
@r###"
|
|
# Fabro project configuration
|
|
# https://docs.fabro.computer/getting-started/quick-start
|
|
|
|
_version = 1
|
|
|
|
# Auto-create pull requests on successful workflow runs.
|
|
[run.pull_request]
|
|
enabled = true
|
|
draft = true
|
|
# auto_merge = true
|
|
"###
|
|
);
|
|
assert_snapshot!(
|
|
std::fs::read_to_string(context.temp_dir.join(".fabro/workflows/hello/workflow.fabro"))
|
|
.unwrap(),
|
|
@r###"
|
|
digraph Hello {
|
|
graph [goal="Say hello and demonstrate a basic Fabro workflow"]
|
|
rankdir=LR
|
|
|
|
start [shape=Mdiamond, label="Start"]
|
|
exit [shape=Msquare, label="Exit"]
|
|
|
|
greet [label="Greet", prompt="Say hello! Introduce yourself and explain that this is a test of the Fabro workflow engine."]
|
|
|
|
start -> greet -> exit
|
|
}
|
|
"###
|
|
);
|
|
assert_snapshot!(
|
|
std::fs::read_to_string(context.temp_dir.join(".fabro/workflows/hello/workflow.toml"))
|
|
.unwrap(),
|
|
@r###"
|
|
_version = 1
|
|
|
|
[workflow]
|
|
graph = "workflow.fabro"
|
|
|
|
[run.sandbox]
|
|
provider = "local"
|
|
"###
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn repo_init_rejects_already_initialized_repo() {
|
|
let context = test_context!();
|
|
context.git_init();
|
|
std::fs::create_dir_all(context.temp_dir.join(".fabro")).unwrap();
|
|
std::fs::write(
|
|
context.temp_dir.join(".fabro/project.toml"),
|
|
"_version = 1\n",
|
|
)
|
|
.unwrap();
|
|
|
|
let mut cmd = context.command();
|
|
cmd.args(["repo", "init"]);
|
|
|
|
fabro_snapshot!(context.filters(), cmd, @"
|
|
success: false
|
|
exit_code: 1
|
|
----- stdout -----
|
|
----- stderr -----
|
|
error: already initialized — .fabro/project.toml exists at [TEMP_DIR]/.fabro/project.toml
|
|
");
|
|
}
|
|
|
|
#[test]
|
|
fn repo_init_errors_outside_git_repo() {
|
|
let context = test_context!();
|
|
let mut cmd = context.command();
|
|
cmd.args(["repo", "init"]);
|
|
|
|
fabro_snapshot!(context.filters(), cmd, @"
|
|
success: false
|
|
exit_code: 1
|
|
----- stdout -----
|
|
----- stderr -----
|
|
error: not a git repository — run `git init` first
|
|
");
|
|
}
|