Repository navigation
refactor(harness): one is_executable instead of four - #253
ArihantDeva wants to merge 1 commit into
Conversation
deepsec, vvah, shannon and openwork each grew the same "is this path a regular file with an execute bit" check. They agreed on behaviour but not on spelling, and disagreed outright off unix: three answered `true`, openwork answered `path.is_file()`. Nothing read differently on the platforms this ships to, which is exactly why the drift was invisible -- a fourth copy would have been written by copying whichever one was nearest. Declared once in `crate::util`, with the `is_file()` requirement kept (a directory carrying 0o755 is not a program) and the off-unix answer left as `true`, which is what three of the four already did. The new test pins the part that is easy to lose: a directory with the execute bit is not executable, a missing path is `false` rather than an error, and a plain file without any x bit is not executable. Removing the `is_file()` guard fails it, so it is covering the distinction rather than restating the body. Net -68/+67 across five files; the four call sites are unchanged.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
2 issues found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/util/mod.rs">
<violation number="1" location="src/util/mod.rs:260">
P3: This explanatory comment is missing the two function names, so it no longer says which old implementation used which check. Restore `path.is_file()` and `metadata.is_file()` in the comment.</violation>
<violation number="2" location="src/util/mod.rs:268">
P3: The non-Unix test branch never verifies that directories are rejected, so a Windows regression in the regular-file guard would pass. Add the same directory assertion to that branch.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| assert!(!is_executable(&plain), "regular file without any x bit"); | ||
| // A directory carrying the execute bit is not a program. This is | ||
| // the case the copies agreed on only by accident -- one of them | ||
| // answered off unix and merely on it. |
There was a problem hiding this comment.
P3: This explanatory comment is missing the two function names, so it no longer says which old implementation used which check. Restore path.is_file() and metadata.is_file() in the comment.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/util/mod.rs, line 260:
<comment>This explanatory comment is missing the two function names, so it no longer says which old implementation used which check. Restore `path.is_file()` and `metadata.is_file()` in the comment.</comment>
<file context>
@@ -211,4 +239,38 @@ mod tests {
+ assert!(!is_executable(&plain), "regular file without any x bit");
+ // A directory carrying the execute bit is not a program. This is
+ // the case the copies agreed on only by accident -- one of them
+ // answered off unix and merely on it.
+ std::fs::set_permissions(dir.path(), std::fs::Permissions::from_mode(0o755))
+ .expect("chmod dir");
</file context>
| // answered off unix and merely on it. | |
| // answered `path.is_file()` off Unix and merely `metadata.is_file()` on it. |
| #[cfg(not(unix))] | ||
| { | ||
| assert!(is_executable(&executable)); | ||
| assert!(is_executable(&plain), "no execute bit to read off unix"); |
There was a problem hiding this comment.
P3: The non-Unix test branch never verifies that directories are rejected, so a Windows regression in the regular-file guard would pass. Add the same directory assertion to that branch.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/util/mod.rs, line 268:
<comment>The non-Unix test branch never verifies that directories are rejected, so a Windows regression in the regular-file guard would pass. Add the same directory assertion to that branch.</comment>
<file context>
@@ -211,4 +239,38 @@ mod tests {
+ #[cfg(not(unix))]
+ {
+ assert!(is_executable(&executable));
+ assert!(is_executable(&plain), "no execute bit to read off unix");
+ }
+
</file context>
| assert!(is_executable(&plain), "no execute bit to read off unix"); | |
| assert!(is_executable(&plain), "no execute bit to read off unix"); | |
| assert!(!is_executable(dir.path()), "a directory is not executable"); |
deepsec,vvah,shannonandopenworkeach grew their own "is this path a regular file with an execute bit" check:Three copies are byte-identical. The fourth, in
openwork.rs, was written differently and disagreed off unix — it answeredpath.is_file()where the others answeredtrue. Nothing reads differently on the platforms this ships to, which is why the drift stayed invisible: a fifth copy would have been written by copying whichever one was nearest.There is now one in
crate::util, with theis_file()requirement kept (a directory carrying0o755is not a program) and the off-unix answer left astrue, matching three of the four.The test pins the distinction that is easy to lose rather than restating the body:
false, not an errorDropping the
is_file()guard fails it, so it covers the case the copies quietly disagreed about.Verification
cargo test --lib: 631 passed (630 + the new test)cargo fmt --checkclean,cargo clippy --all-targets -- -D warningscleanNote on building this branch: plain
maindoes not link on macOS here —-nostdinc++and its SDK operand reachccas an input file. That is #245; I applied it locally to run the gate and left it out of this PR.Summary by cubic
Consolidates the four duplicated
is_executablehelpers in the harness modules (deepsec,vvah,shannon,openwork) into a singlecrate::util::is_executable. The copies behaved identically on Unix but disagreed off-Unix: three answeredtrueandopenworkansweredpath.is_file(), a drift that nothing exercised. The shared helper keeps theis_file()guard and thetrueoff-Unix answer, and the four call sites are unchanged.Verification
false, not an error), and a plain file without any x bit.cargo test --libpasses 631 tests, withcargo fmtandcargo clippy --all-targets -- -D warningsclean.Written for commit 2a13e5a. Summary will update on new commits.
Summary by CodeRabbit