add xtask#66
Merged
Merged
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
xtask/src/lib.rs,Exit::from(Cmd)only surfacesstderron non-zero exit and discardsstdout; consider includingstdout(or at least a truncated version) in the error message to make diagnosing failing commands easier. - The xtask
maincurrently anchors all commands atPath::new("."); if this is intended to operate at the workspace root, consider resolving the workspace root explicitly (e.g., viaCARGO_MANIFEST_DIRorcargo metadata) to avoid surprising behavior when run from subdirectories.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `xtask/src/lib.rs`, `Exit::from(Cmd)` only surfaces `stderr` on non-zero exit and discards `stdout`; consider including `stdout` (or at least a truncated version) in the error message to make diagnosing failing commands easier.
- The xtask `main` currently anchors all commands at `Path::new(".")`; if this is intended to operate at the workspace root, consider resolving the workspace root explicitly (e.g., via `CARGO_MANIFEST_DIR` or `cargo metadata`) to avoid surprising behavior when run from subdirectories.
## Individual Comments
### Comment 1
<location path="xtask/tests/test_fmt.rs" line_range="14-15" />
<code_context>
+ let original = fs::read_to_string("tests/fixture/src/lib.rs").unwrap();
+ let copied = fs::read_to_string(tmp.path().join("src/lib.rs")).unwrap();
+ assert_eq!(original, copied);
+ let _ = fmt(tmp.path());
+ let formatted = fs::read_to_string(tmp.path().join("src/lib.rs")).unwrap();
+ assert_ne!(original, formatted);
+}
</code_context>
<issue_to_address>
**suggestion (testing):** Assert that `fmt` actually succeeds instead of ignoring its result, so failures in running `cargo fmt` don’t show up as confusing assertion errors.
`fmt(tmp.path())` is currently ignored, so if `cargo fmt` fails (e.g. missing rustfmt, bad Cargo.toml), the test only fails later at `assert_ne!(original, formatted)`, which is misleading.
Instead, check the command result before reading the file, e.g.:
```rust
let cmd = fmt(tmp.path());
let output = cmd.result.expect("`cargo fmt` failed to run");
assert!(
output.status.success(),
"`cargo fmt` exited with status {:?}\nstderr: {}",
output.status,
String::from_utf8_lossy(&output.stderr),
);
```
That way the test fails clearly when `cargo fmt` itself fails, and only then checks that the file changed.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
No description provided.