mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-16 04:33:16 +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>
163 lines
5 KiB
Rust
163 lines
5 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 super::support::{git_stdout, output_stderr, setup_git_backed_changed_run};
|
|
|
|
const SHARED_DAEMON_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
|
|
|
|
#[test]
|
|
fn help() {
|
|
let context = test_context!();
|
|
let mut cmd = context.command();
|
|
cmd.args(["resume", "--help"]);
|
|
fabro_snapshot!(context.filters(), cmd, @"
|
|
success: true
|
|
exit_code: 0
|
|
----- stdout -----
|
|
Resume an interrupted workflow run
|
|
|
|
Usage: fabro resume [OPTIONS] <RUN>
|
|
|
|
Arguments:
|
|
<RUN> Run ID or unambiguous prefix
|
|
|
|
Options:
|
|
--json Output as JSON [env: FABRO_JSON=]
|
|
--server <SERVER> Fabro server target: http(s) URL or absolute Unix socket path [env: FABRO_SERVER=]
|
|
-d, --detach Run in the background and print the run ID
|
|
--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 resume_requires_run_arg() {
|
|
let context = test_context!();
|
|
let mut cmd = context.command();
|
|
cmd.args(["resume"]);
|
|
fabro_snapshot!(context.filters(), cmd, @"
|
|
success: false
|
|
exit_code: 2
|
|
----- stdout -----
|
|
----- stderr -----
|
|
error: the following required arguments were not provided:
|
|
<RUN>
|
|
|
|
Usage: fabro resume --no-upgrade-check <RUN>
|
|
|
|
For more information, try '--help'.
|
|
");
|
|
}
|
|
|
|
#[test]
|
|
fn resume_rewound_run_succeeds() {
|
|
let context = test_context!();
|
|
let setup = setup_git_backed_changed_run(&context);
|
|
|
|
let rewind = context
|
|
.command()
|
|
.current_dir(&setup.repo_dir)
|
|
.args(["rewind", &setup.run.run_id, "@1", "--no-push"])
|
|
.output()
|
|
.expect("rewind should execute");
|
|
assert!(
|
|
rewind.status.success(),
|
|
"rewind should succeed\nstdout:\n{}\nstderr:\n{}",
|
|
String::from_utf8_lossy(&rewind.stdout),
|
|
output_stderr(&rewind)
|
|
);
|
|
let rewound_head = git_stdout(&setup.repo_dir, &[
|
|
"rev-parse",
|
|
&format!("fabro/run/{}", setup.run.run_id),
|
|
]);
|
|
|
|
let mut resume_cmd = context.command();
|
|
resume_cmd.current_dir(&setup.repo_dir);
|
|
resume_cmd.env("OPENAI_API_KEY", "test");
|
|
resume_cmd.args(["resume", &setup.run.run_id]);
|
|
let resume_output = resume_cmd.output().expect("resume should execute");
|
|
assert!(
|
|
resume_output.status.success(),
|
|
"resume should succeed\nstdout:\n{}\nstderr:\n{}",
|
|
String::from_utf8_lossy(&resume_output.stdout),
|
|
output_stderr(&resume_output)
|
|
);
|
|
|
|
let mut wait_filters = context.filters();
|
|
wait_filters.push((
|
|
r"\b\d+(\.\d+)?(ms|s)\b".to_string(),
|
|
"[DURATION]".to_string(),
|
|
));
|
|
let mut wait_cmd = context.command();
|
|
wait_cmd.args(["wait", &setup.run.run_id]);
|
|
fabro_snapshot!(wait_filters, wait_cmd, @"
|
|
success: true
|
|
exit_code: 0
|
|
----- stdout -----
|
|
----- stderr -----
|
|
Succeeded [ULID] [DURATION]
|
|
");
|
|
|
|
assert_eq!(
|
|
std::fs::read_to_string(setup.run.run_dir.join("worktree/story.txt")).unwrap(),
|
|
"line 1\nline 2\nline 3\n"
|
|
);
|
|
assert_eq!(
|
|
std::fs::read_to_string(setup.repo_dir.join("story.txt")).unwrap(),
|
|
"line 1\n"
|
|
);
|
|
let resumed_head = git_stdout(&setup.repo_dir, &[
|
|
"rev-parse",
|
|
&format!("fabro/run/{}", setup.run.run_id),
|
|
]);
|
|
assert_ne!(resumed_head.trim(), rewound_head.trim());
|
|
}
|
|
|
|
#[test]
|
|
fn resume_detached_does_not_create_launcher_record() {
|
|
let context = test_context!();
|
|
let setup = setup_git_backed_changed_run(&context);
|
|
|
|
context
|
|
.command()
|
|
.current_dir(&setup.repo_dir)
|
|
.args(["rewind", &setup.run.run_id, "@1", "--no-push"])
|
|
.assert()
|
|
.success();
|
|
|
|
let mut resume_cmd = context.command();
|
|
resume_cmd.current_dir(&setup.repo_dir);
|
|
resume_cmd.env("OPENAI_API_KEY", "test");
|
|
resume_cmd.args(["resume", "--detach", &setup.run.run_id]);
|
|
let resume_output = resume_cmd.output().expect("resume should execute");
|
|
assert!(
|
|
resume_output.status.success(),
|
|
"resume should succeed\nstdout:\n{}\nstderr:\n{}",
|
|
String::from_utf8_lossy(&resume_output.stdout),
|
|
output_stderr(&resume_output)
|
|
);
|
|
|
|
assert!(
|
|
!context
|
|
.storage_dir
|
|
.join("launchers")
|
|
.join(format!("{}.json", setup.run.run_id))
|
|
.exists(),
|
|
"server-owned resume should not create a launcher record"
|
|
);
|
|
|
|
context
|
|
.command()
|
|
.args(["wait", &setup.run.run_id])
|
|
.timeout(SHARED_DAEMON_TIMEOUT)
|
|
.assert()
|
|
.success();
|
|
}
|