Conversation
- Parse Netsukefile and convert to IR - Write Ninja script to a temp file and pass via -f - Cover manifest→IR→Ninja pipeline with CLI tests
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Summary by CodeRabbit
WalkthroughPromote the "tempfile" crate from a development dependency to a main dependency. Refactor the Ninja runner to load a manifest, convert it to a build graph, generate a Ninja build script, and execute Ninja with this script. Update and expand tests to use temporary manifest files and verify Ninja script generation. Add and refactor test helpers for script creation and capturing Ninja invocations. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI
participant Runner
participant ManifestLoader
participant IRBuilder
participant NinjaGenerator
participant TempFile
participant NinjaProcess
CLI->>Runner: run_ninja(program, cli, targets)
Runner->>ManifestLoader: load_manifest(cli.file)
ManifestLoader-->>Runner: Manifest
Runner->>IRBuilder: manifest_to_graph(Manifest)
IRBuilder-->>Runner: BuildGraph
Runner->>NinjaGenerator: generate_ninja(BuildGraph)
NinjaGenerator-->>Runner: NinjaScript
Runner->>TempFile: write(NinjaScript)
TempFile-->>Runner: temp_file_path
Runner->>NinjaProcess: run_ninja(-f temp_file_path, targets)
NinjaProcess-->>Runner: Output/Error
Runner-->>CLI: Stream output/error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Reviewer's GuideThis PR embeds the Netsukefile→IR→Ninja build file pipeline into the runner: it parses the manifest, constructs the IR graph, generates a Ninja script in a temp file, and then invokes ninja with that script. It also enhances tests with manifest-writing helpers and a capture variant to validate the end-to-end flow, and adds the requisite tempfile dependency. Sequence diagram for manifest-to-Ninja pipeline integrationsequenceDiagram
actor User
participant Runner
participant ManifestParser as manifest::from_path
participant IR as ir::BuildGraph
participant NinjaGen as ninja_gen::generate
participant TempFile as NamedTempFile
participant Ninja
User->>Runner: run_ninja()
Runner->>ManifestParser: Parse Netsukefile
ManifestParser-->>Runner: Manifest
Runner->>IR: BuildGraph::from_manifest(Manifest)
IR-->>Runner: BuildGraph
Runner->>NinjaGen: generate(BuildGraph)
NinjaGen-->>Runner: Ninja script (String)
Runner->>TempFile: Create temp file, write Ninja script
TempFile-->>Runner: Path to temp build file
Runner->>Ninja: Invoke with -f <temp build file>
Ninja-->>User: Build output
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and found some issues that need to be addressed.
- Consider refactoring run_ninja to separate the Ninja script generation (manifest→IR→ninja) from the actual process invocation for better readability and testability.
- Rename test_cli to something like cli_with_manifest or cli_for_file to clarify that it accepts a manifest file path.
- Extract the write_manifest helper into the shared test support module to avoid duplication and keep tests DRY.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider refactoring run_ninja to separate the Ninja script generation (manifest→IR→ninja) from the actual process invocation for better readability and testability.
- Rename test_cli to something like cli_with_manifest or cli_for_file to clarify that it accepts a manifest file path.
- Extract the write_manifest helper into the shared test support module to avoid duplication and keep tests DRY.
## Individual Comments
### Comment 1
<location> `src/runner.rs:59` </location>
<code_context>
+ let graph = ir::BuildGraph::from_manifest(&manifest).map_err(io::Error::other)?;
+ let ninja_script = ninja_gen::generate(&graph);
+
+ let mut build_file = NamedTempFile::new().map_err(io::Error::other)?;
+ build_file.write_all(ninja_script.as_bytes())?;
+ build_file.flush()?;
+ let build_path: PathBuf = build_file.path().to_path_buf();
+
let mut cmd = Command::new(program);
</code_context>
<issue_to_address>
Consider handling the lifetime of the temporary file more explicitly.
Since the file handle isn't passed to the child process, the temporary file may be deleted before Ninja finishes using it. Ensure the file persists for the duration of the child process, either by keeping the handle alive or using another method.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
Cargo.toml(1 hunks)src/runner.rs(3 hunks)tests/runner_tests.rs(2 hunks)tests/support/mod.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
Cargo.toml
📄 CodeRabbit Inference Engine (AGENTS.md)
Cargo.toml: Use explicit version ranges inCargo.tomland keep dependencies up-to-date.
Mandate caret requirements for all dependencies: All crate versions specified inCargo.tomlmust use SemVer-compatible caret requirements (e.g.,some-crate = "1.2.3").
Prohibit unstable version specifiers: The use of wildcard (*) or open-ended inequality (>=) version requirements is strictly forbidden. Tilde requirements (~) should only be used where a dependency must be locked to patch-level updates for a specific, documented reason.
Files:
Cargo.toml
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Useconcat!()to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums: Derivestd::error::Error(via thethiserrorcrate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Useeyre::Reportfor human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and toeyreonly in the mainmain()entrypoint or top-level async task.
Files:
tests/support/mod.rstests/runner_tests.rssrc/runner.rs
⚙️ CodeRabbit Configuration File
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Files:
tests/support/mod.rstests/runner_tests.rssrc/runner.rs
🔇 Additional comments (11)
Cargo.toml (1)
16-16: LGTM: Dependency promotion justified by main codebase usage.The promotion of
tempfilefrom dev-dependencies to main dependencies is appropriate given its usage insrc/runner.rsfor temporary Ninja build file generation.src/runner.rs (3)
7-10: LGTM: Import organisation follows logical grouping.The imports are well-organised with internal crates grouped together and standard library imports separated.
55-63: LGTM: Pipeline implementation follows proper error handling patterns.The manifest loading, IR conversion, and Ninja generation steps properly convert domain errors to
io::Errorusingmap_err(io::Error::other). The temporary file handling correctly flushes before use and preserves the path for later reference.
71-71: LGTM: Ninja build file argument correctly specified.The
-fargument properly passes the temporary build file path to Ninja.tests/runner_tests.rs (4)
12-21: LGTM: Test helper properly parameterised.The
test_clifunction correctly accepts aPathBufparameter for the manifest file, making tests more flexible.
30-35: LGTM: Existing tests properly updated for temporary manifests.The tests correctly create temporary manifest files and pass their paths to the test CLI configuration.
47-83: LGTM: Comprehensive pipeline test validates end-to-end functionality.The
run_pipeline_generates_ninjatest excellently validates the complete pipeline by:
- Creating a temporary manifest with known content
- Capturing the generated Ninja build file
- Verifying the generated content matches expected Ninja rules and build statements
- Using proper hash-based rule naming
The test demonstrates thorough understanding of the pipeline flow and provides good coverage.
85-97: LGTM: Helper function provides clean test data setup.The
write_manifestfunction properly encapsulates test manifest creation with realistic YAML content that exercises the pipeline.tests/support/mod.rs (3)
8-20: LGTM: Helper function properly extracts common script creation logic.The
write_scriptfunction effectively eliminates code duplication and handles cross-platform executable permissions correctly with the#[cfg(unix)]conditional compilation.
25-30: LGTM: Refactored fake_ninja uses helper effectively.The refactoring to use
write_scriptimproves code organisation and maintainability whilst preserving the original functionality.
37-46: LGTM: Comprehensive fake Ninja implementation for build file capture.The
fake_ninja_capturefunction provides excellent test infrastructure by:
- Creating a shell script that properly parses command-line arguments
- Correctly identifying and capturing the
-fargument's build file- Using appropriate temporary file management
- Including proper documentation and dead code allowance
The shell script logic correctly handles argument parsing and file capture for testing the pipeline.
There was a problem hiding this comment.
Actionable comments posted: 6
🔭 Outside diff range comments (1)
tests/steps/process_steps.rs (1)
56-92: Manifest handling logic addresses pipeline integration requirements.The code properly:
- Resolves manifest paths relative to the temporary directory
- Creates manifest files when they don't exist using the
write_manifesthelper- Updates CLI configuration to use the resolved path
- Cleans up manifest files outside the temp directory
However, there are several issues:
Mutable borrow issue: Line 56 takes a mutable reference to CLI, but line 71 attempts to clone from it whilst still borrowed mutably.
Missing error context: File operations lack proper error context as required by the coding guidelines.
Overly complex path resolution: The manifest path handling could be simplified.
Apply this diff to fix the mutable borrow and improve error handling:
- let cli = world.cli.as_mut().expect("cli"); - - // Ensure a manifest exists at the path expected by the CLI. - let dir = world.temp.as_ref().expect("temp dir"); - let manifest_path = if cli.file.is_absolute() { - cli.file.clone() - } else { - dir.path().join(&cli.file) - }; - if !manifest_path.exists() { - let mut file = NamedTempFile::new_in(dir.path()).expect("manifest"); - support::write_manifest(&mut file); - // Persist the temporary file to the desired manifest path. - file.persist(&manifest_path).expect("persist manifest"); - } - cli.file.clone_from(&manifest_path); + let dir = world.temp.as_ref().expect("temp dir"); + let manifest_path = { + let cli = world.cli.as_ref().expect("cli"); + if cli.file.is_absolute() { + cli.file.clone() + } else { + dir.path().join(&cli.file) + } + }; + + if !manifest_path.exists() { + let mut file = NamedTempFile::new_in(dir.path()) + .expect("Failed to create temporary manifest file"); + support::write_manifest(&mut file); + file.persist(&manifest_path) + .expect("Failed to persist manifest file"); + } + + let cli = world.cli.as_mut().expect("cli"); + cli.file.clone_from(&manifest_path);
♻️ Duplicate comments (2)
src/runner.rs (2)
42-58: Documentation improvement addresses previous feedback.The updated documentation clearly describes the complete pipeline flow from Netsukefile → IR → Ninja generation → execution, addressing the previous review comment effectively.
56-58: Proper temporary file lifetime management.The comment and implementation correctly ensure the
build_filehandle remains alive for the duration of the child process, preventing premature deletion of the temporary Ninja script.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
src/runner.rs(4 hunks)tests/runner_tests.rs(2 hunks)tests/steps/process_steps.rs(3 hunks)tests/support/mod.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Useconcat!()to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums: Derivestd::error::Error(via thethiserrorcrate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Useeyre::Reportfor human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and toeyreonly in the mainmain()entrypoint or top-level async task.
Files:
tests/steps/process_steps.rssrc/runner.rstests/runner_tests.rstests/support/mod.rs
⚙️ CodeRabbit Configuration File
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Files:
tests/steps/process_steps.rssrc/runner.rstests/runner_tests.rstests/support/mod.rs
🧬 Code Graph Analysis (4)
tests/steps/process_steps.rs (2)
tests/steps/cli_steps.rs (1)
manifest_path(94-97)tests/support/mod.rs (1)
write_manifest(53-65)
src/runner.rs (3)
src/manifest.rs (1)
from_path(51-56)src/ir.rs (1)
from_manifest(108-119)src/ninja_gen.rs (1)
generate(37-73)
tests/runner_tests.rs (3)
tests/support/mod.rs (2)
write_manifest(53-65)fake_ninja_capture(37-46)src/runner.rs (1)
run_ninja(55-107)src/hasher.rs (1)
hash(38-43)
tests/support/mod.rs (1)
tests/steps/process_steps.rs (1)
fake_ninja(32-35)
🔇 Additional comments (5)
tests/runner_tests.rs (3)
11-20: LGTM! Function signature improvement aligns with dynamic manifest handling.The rename from
test_clitocli_with_manifestand the parameter change from hardcoded "Netsukefile" to aPathBufargument properly supports the new dynamic manifest file approach.
29-31: LGTM! Proper temporary file management for test isolation.The use of
NamedTempFilewith thewrite_manifesthelper ensures each test operates with its own manifest file, providing proper test isolation.
46-75: Comprehensive end-to-end pipeline validation.This test properly validates the complete manifest→IR→Ninja pipeline by:
- Creating a temporary manifest
- Capturing the generated Ninja build file using
fake_ninja_capture- Verifying the generated content matches expected Ninja syntax with correct rule hash
The hash calculation and expected output format are correctly implemented.
tests/support/mod.rs (2)
8-20: Extract script creation logic effectively.The
write_scripthelper properly centralises executable script creation with correct permission handling on Unix platforms. The implementation correctly handles file creation and permission setting.
25-30: LGTM! Simplified fake ninja creation using the helper.The refactored
fake_ninjafunction now delegates script creation to thewrite_scripthelper, improving code reuse and maintainability.
| /// Generate a temporary Ninja build file from a manifest. | ||
| fn manifest_to_build_file(path: &Path) -> io::Result<NamedTempFile> { | ||
| let manifest = manifest::from_path(path).map_err(io::Error::other)?; | ||
| let graph = ir::BuildGraph::from_manifest(&manifest).map_err(io::Error::other)?; | ||
| let ninja_script = ninja_gen::generate(&graph); | ||
|
|
||
| let mut build_file = NamedTempFile::new().map_err(io::Error::other)?; | ||
| build_file.write_all(ninja_script.as_bytes())?; | ||
| build_file.flush()?; | ||
| Ok(build_file) | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Error handling violates Result type guidelines.
The manifest_to_build_file function uses io::Error::other() to convert all errors to io::Error, which loses important error context. The coding guidelines require proper error propagation and context.
Create a proper error type or improve error context:
-fn manifest_to_build_file(path: &Path) -> io::Result<NamedTempFile> {
- let manifest = manifest::from_path(path).map_err(io::Error::other)?;
- let graph = ir::BuildGraph::from_manifest(&manifest).map_err(io::Error::other)?;
+fn manifest_to_build_file(path: &Path) -> io::Result<NamedTempFile> {
+ let manifest = manifest::from_path(path)
+ .map_err(|e| io::Error::new(io::ErrorKind::InvalidData,
+ format!("Failed to load manifest from {}: {}", path.display(), e)))?;
+ let graph = ir::BuildGraph::from_manifest(&manifest)
+ .map_err(|e| io::Error::new(io::ErrorKind::InvalidData,
+ format!("Failed to convert manifest to build graph: {}", e)))?;
let ninja_script = ninja_gen::generate(&graph);
- let mut build_file = NamedTempFile::new().map_err(io::Error::other)?;
+ let mut build_file = NamedTempFile::new()
+ .map_err(|e| io::Error::new(io::ErrorKind::Other,
+ format!("Failed to create temporary build file: {}", e)))?;
build_file.write_all(ninja_script.as_bytes())?;
build_file.flush()?;
Ok(build_file)
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /// Generate a temporary Ninja build file from a manifest. | |
| fn manifest_to_build_file(path: &Path) -> io::Result<NamedTempFile> { | |
| let manifest = manifest::from_path(path).map_err(io::Error::other)?; | |
| let graph = ir::BuildGraph::from_manifest(&manifest).map_err(io::Error::other)?; | |
| let ninja_script = ninja_gen::generate(&graph); | |
| let mut build_file = NamedTempFile::new().map_err(io::Error::other)?; | |
| build_file.write_all(ninja_script.as_bytes())?; | |
| build_file.flush()?; | |
| Ok(build_file) | |
| } | |
| /// Generate a temporary Ninja build file from a manifest. | |
| fn manifest_to_build_file(path: &Path) -> io::Result<NamedTempFile> { | |
| let manifest = manifest::from_path(path) | |
| .map_err(|e| io::Error::new( | |
| io::ErrorKind::InvalidData, | |
| format!("Failed to load manifest from {}: {}", path.display(), e), | |
| ))?; | |
| let graph = ir::BuildGraph::from_manifest(&manifest) | |
| .map_err(|e| io::Error::new( | |
| io::ErrorKind::InvalidData, | |
| format!("Failed to convert manifest to build graph: {}", e), | |
| ))?; | |
| let ninja_script = ninja_gen::generate(&graph); | |
| let mut build_file = NamedTempFile::new() | |
| .map_err(|e| io::Error::new( | |
| io::ErrorKind::Other, | |
| format!("Failed to create temporary build file: {}", e), | |
| ))?; | |
| build_file.write_all(ninja_script.as_bytes())?; | |
| build_file.flush()?; | |
| Ok(build_file) | |
| } |
🤖 Prompt for AI Agents
In src/runner.rs around lines 109 to 119, the function manifest_to_build_file
improperly converts all errors to io::Error using io::Error::other(), losing
error context. To fix this, define a custom error type or use a suitable error
handling crate like thiserror or anyhow to propagate errors with full context.
Replace map_err(io::Error::other) calls with proper conversions or use the ?
operator to propagate errors while preserving their original types and messages.
| #[allow( | ||
| dead_code, | ||
| reason = "helper is unused when the support crate builds independently" |
There was a problem hiding this comment.
Inappropriate use of #[allow] violates coding guidelines.
The coding guidelines explicitly forbid #[allow] and require #[expect] with reasons instead. Additionally, the dead_code suppression should be more narrowly scoped.
Replace the lint suppression:
-#[allow(dead_code, reason = "not every test exercises the capture variant")]
+#[expect(dead_code, reason = "not every test exercises the capture variant")]Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In tests/support/mod.rs around lines 49 to 51, replace the #[allow(dead_code,
reason = "...")] attribute with #[expect(dead_code, reason = "...")] to comply
with coding guidelines that forbid #[allow]. Also, narrow the scope of the
dead_code suppression to only the specific helper function or item that is
unused, rather than applying it broadly.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (2)
tests/support/mod.rs (1)
32-56: Shell script robustness improvements implemented.The script now properly handles argument parsing with
$#checks and ensures-fhas a following argument, addressing the previous review concerns.src/runner.rs (1)
136-144: Replaceio::Error::otherwith proper error kinds.The use of
io::Error::otherviolates the error handling guidelines. Use appropriate error kinds instead.- let mut build_file = NamedTempFile::new() - .map_err(|e| io::Error::other(format!("Failed to create temporary build file: {e}")))?; + let mut build_file = NamedTempFile::new() + .map_err(|e| io::Error::new( + io::ErrorKind::Other, + format!("Failed to create temporary build file: {e}") + ))?; build_file .write_all(ninja_script.as_bytes()) - .map_err(|e| io::Error::other(format!("Failed to write build file: {e}")))?; + .map_err(|e| io::Error::new( + e.kind(), + format!("Failed to write build file: {e}") + ))?; build_file .flush() - .map_err(|e| io::Error::other(format!("Failed to flush build file: {e}")))?; + .map_err(|e| io::Error::new( + e.kind(), + format!("Failed to flush build file: {e}") + ))?;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
src/runner.rs(4 hunks)tests/runner_tests.rs(2 hunks)tests/steps/process_steps.rs(3 hunks)tests/support/mod.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Useconcat!()to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums: Derivestd::error::Error(via thethiserrorcrate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Useeyre::Reportfor human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and toeyreonly in the mainmain()entrypoint or top-level async task.
Files:
tests/support/mod.rssrc/runner.rstests/runner_tests.rstests/steps/process_steps.rs
⚙️ CodeRabbit Configuration File
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Files:
tests/support/mod.rssrc/runner.rstests/runner_tests.rstests/steps/process_steps.rs
🧬 Code Graph Analysis (3)
tests/support/mod.rs (1)
tests/steps/process_steps.rs (1)
fake_ninja(32-35)
src/runner.rs (3)
src/manifest.rs (1)
from_path(51-56)src/ir.rs (1)
from_manifest(108-119)src/ninja_gen.rs (1)
generate(37-73)
tests/steps/process_steps.rs (1)
tests/support/mod.rs (2)
fake_ninja_capture(36-56)write_manifest(59-71)
🔇 Additional comments (12)
tests/runner_tests.rs (5)
1-4: Documentation improvements look good!The expanded module documentation clearly explains that the tests verify both manifest translation and Ninja process invocation.
14-23: Helper function refactoring is appropriate.The renamed function with the
PathBufparameter provides better flexibility for tests to specify different manifest paths.
31-37: Test updates correctly handle temporary manifest files.The test properly creates a temporary manifest and passes its path to the runner.
40-47: Consistent test pattern implementation.The test follows the same pattern as
run_ninja_statusfor manifest handling.
49-78: Comprehensive end-to-end pipeline test.The test effectively verifies the complete manifest-to-Ninja pipeline, including correct hash generation and build script formatting.
tests/steps/process_steps.rs (2)
60-74: Robust manifest file handling.The code correctly ensures a manifest exists at the CLI-specified path, handling both absolute and relative paths appropriately.
91-94: Appropriate cleanup of test artifacts.The cleanup logic correctly removes manifests created outside the temporary directory, preventing test pollution.
tests/support/mod.rs (3)
8-20: Well-structured helper function for script creation.The
write_scriptfunction properly centralizes script creation with appropriate Unix permissions handling.
22-30: Clean refactoring using the helper function.The refactored implementation properly delegates script creation to the helper.
58-71: Proper test manifest generation.The function creates a valid minimal Netsukefile with appropriate use of
concat!for the multi-line string literal.src/runner.rs (2)
56-68: Pipeline integration implemented correctly.The implementation properly manages the temporary build file lifetime and passes it to Ninja via the
-fflag.
122-133: Proper error context for manifest operations.The error handling for manifest loading and graph conversion provides clear context about what failed.
| // Touch the capture variant so the support module's helpers remain used. | ||
| let _ = support::fake_ninja_capture as fn() -> (TempDir, PathBuf, PathBuf); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Remove the workaround for unused function reference.
The comment indicates this is keeping fake_ninja_capture artificially referenced. Instead, use #[expect(dead_code)] on the function in the support module if it's genuinely unused in some contexts.
- // Touch the capture variant so the support module's helpers remain used.
- let _ = support::fake_ninja_capture as fn() -> (TempDir, PathBuf, PathBuf);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Touch the capture variant so the support module's helpers remain used. | |
| let _ = support::fake_ninja_capture as fn() -> (TempDir, PathBuf, PathBuf); |
🤖 Prompt for AI Agents
In tests/steps/process_steps.rs around lines 56 to 57, remove the line that
assigns `support::fake_ninja_capture` to an unused variable as a workaround to
keep the function referenced. Instead, go to the support module where
`fake_ninja_capture` is defined and add the attribute `#[expect(dead_code)]` to
that function to suppress unused code warnings properly.
|
Stale |
Summary
Testing
make fmtmake lintmake test(fails: 3 steps failed)cargo test --test runner_testshttps://chatgpt.com/codex/tasks/task_e_6891a8f2ed1c8322830bd969f8bedf19
Summary by Sourcery
Integrate a manifest-to-Ninja pipeline by updating the runner to parse a Netsukefile, convert it to IR, generate a temporary Ninja build script, and invoke Ninja with the generated file; extend tests to use temporary manifests and capture the generated build file; refactor test support and add the tempfile dependency.
New Features:
Enhancements:
Build:
Tests: