refactor: split engine into a library target (src/lib.rs)#29
Merged
Conversation
driller was a binary-only crate, which blocked integration tests, benchmarks, and sibling tools from using the engine directly -- they could only shell out to the binary. Introduce a clean engine-in-library / CLI-in-binary boundary: - src/lib.rs is the new crate root. It re-exports the engine modules (actions, benchmark, checker, config, expandable, reader, tags) and exposes a typed entry point, `run(&RunOptions) -> BenchmarkResult`. interpolator and writer stay crate-private (no public interface). - src/main.rs keeps the CLI: clap structs, version strings, argv -> RunOptions mapping, the stats/compare presentation, and process exit codes. It now drives the engine via `driller::run`. - Cargo.toml declares explicit [lib] and [[bin]] targets. Behaviour-preserving: identical CLI output and exit codes; fmt, clippy, and the full test suite (lib + bin unit tests, integration tests, the new lib doctest) pass unchanged. Member-level visibility is untouched -- only module-level reachability changed.
Owner
Author
Code reviewFound 4 issues:
Lines 24 to 29 in d6475fd
Lines 40 to 42 in d6475fd
Lines 51 to 54 in d6475fd
Lines 11 to 14 in d6475fd All four are documentation/visibility refinements; the structural split itself is behaviour-preserving (verified clean across history, comments, and a shallow bug scan). |
Follow-up to the code review on the library-target split: - Drop the reference to the private-workbench-only `harness/` crate from the crate-level doc comment (it does not exist in this repo and would surface in cargo doc); use a generic "sibling crates" phrasing. - Document BenchmarkResult and its reports/duration fields, now that it is part of the public API. - Narrow benchmark::execute to pub(crate) so driller::run is genuinely the single public entry point for executing a run. - Document on run() and checker::compare() that some fatal-input paths terminate the process via process::exit rather than returning, so library callers can pre-validate. The die() -> Result migration remains a tracked follow-up.
Owner
Author
|
Addressed all four in e052ad3:
fmt + clippy clean; all tests (95 lib + 25 bin + cli_errors + 32 moat + doctest) pass; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
driller was a binary-only crate (no
src/lib.rs), which blocked integration tests, benchmarks, and sibling tooling from using the engine directly -- they could only shell out to the compiled binary.This PR introduces a clean engine-in-library / CLI-in-binary split:
src/lib.rsis the new crate root. It re-exports the engine modules (actions,benchmark,checker,config,expandable,reader,tags) and exposes a single typed entry point:interpolatorandwriterstay crate-private (they appear in no public interface).src/main.rskeeps everything CLI: clap structs, version strings, argv ->RunOptionsmapping, the stats/compare presentation, andprocess::exitcodes. It now drives the engine viadriller::run.Cargo.tomldeclares explicit[lib]and[[bin]]targets (both nameddriller).This is a cleaner shape than making
main()public: consumers getrun(options) -> result, not "run the whole CLI," and clap/version/exit concerns never leak into the library.Why
Unblocks library-level integration tests, in-process parse/throughput benchmarks (a
benches/harness can nowuse driller::reader), and sibling crates depending on driller viapath.Behaviour-preserving
CLI output and exit codes are unchanged; only module reachability changed (no member-level visibility was altered).
cargo build/cargo clippy --all-targets -- -D warnings-- cleancargo fmt --check-- cleancargo test-- 95 lib + 25 bin unit tests,cli_errors,serde_yaml_moat(32), and the new lib doctest all passcargo doc --no-deps-- buildsdriller --versionand an ad-hoc run (connection error -> clean 520, exit 0) verifiedNotes
Implements a deliberately cleaner design than upstream fcsonline/drill#180 (which makes
main()public and leaves CLI concerns in the library). Thedie()->Resultcleanup (so the library never callsprocess::exit) is intentionally out of scope and left as a follow-up.