refactor(harness): one is_executable instead of four
deepsec, vvah, shannon and openwork each grew their own "is this path a regular file with an execute bit" check:
fn is_executable(path: &Path) -> bool {
let Ok(metadata) = std::fs::metadata(path) else { return false; };
if !metadata.is_file() { return false; }
#[cfg(unix)] { metadata.permissions().mode() & 0o111 != 0 }
#[cfg(not(unix))] { true }
}
Three copies are byte-identical. The fourth, in openwork.rs, was written differently and disagreed off unix — it answered path.is_file() where the others answered true. 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 the is_file() requirement kept (a directory carrying 0o755 is not a program) and the off-unix answer left as true, matching three of the four.
The test pins the distinction that is easy to lose rather than restating the body:
- a directory with the execute bit is not executable
- a missing path is
false, not an error - a plain file with no x bit is not executable
Dropping 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 warningsclean- Net −68/+67 across five files; the four call sites are unchanged
Note on building this branch: plain main does not link on macOS here — -nostdinc++ and its SDK operand reach cc as 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_executable helpers in the harness modules (deepsec, vvah, shannon, openwork) into a single crate::util::is_executable. The copies behaved identically on Unix but disagreed off-Unix: three answered true and openwork answered path.is_file(), a drift that nothing exercised. The shared helper keeps the is_file() guard and the true off-Unix answer, and the four call sites are unchanged.
Verification
- New test covers a directory with the execute bit (not executable), a missing path (
false, not an error), and a plain file without any x bit. cargo test --libpasses 631 tests, withcargo fmtandcargo clippy --all-targets -- -D warningsclean.
Summary by CodeRabbit
- Refactor
- Application launch eligibility is checked consistently across the supported harnesses and platforms. Missing paths and paths that do not point to regular files are not treated as launchable. On Unix, a file must also have an execute permission; on other platforms, a regular file is considered launchable.
- No user-facing features or workflows changed.