Skip to content

Commit 53ded78

Browse files
committed
Test let_readers_execute on all targets
The `let_readers_execute` function computes a new mode with `+x` set reasonably based on an old mode. It is only useful on Unix-like systems. But there may be a benefit to being able to detect more bugs affecting one platform even on another; this can help catch bugs slightly earlier in the development process. Now that `let_readers_execute` only longer depends on a type that varies across Unix-like systems and is only defined on such systems (instead representing modes as `u32` on all of them), it no longer contains anything that can't build or be tested everywhere. So this lets its tests run on all systems, even non-Unix-like ones.
1 parent 51724d1 commit 53ded78

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

gix-worktree-state/src/checkout/entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,15 @@ fn set_executable(file: &std::fs::File) -> Result<(), std::io::Error> {
311311
/// Set-user-ID and set-group-ID bits are unset for safety. The sticky bit is also unset.
312312
///
313313
/// This returns only mode bits, not file type. The return value can be used in chmod or fchmod.
314-
#[cfg(unix)]
314+
#[cfg(any(unix, test))]
315315
fn let_readers_execute(mut mode: u32) -> u32 {
316316
assert_eq!(mode & 0o170000, 0o100000, "bug in caller if not from a regular file");
317317
mode &= 0o777; // Clear type, non-rwx mode bits (setuid, setgid, sticky).
318318
mode |= (mode & 0o444) >> 2; // Let readers also execute.
319319
mode
320320
}
321321

322-
#[cfg(all(test, unix))]
322+
#[cfg(test)]
323323
mod tests {
324324
#[test]
325325
fn let_readers_execute() {

0 commit comments

Comments
 (0)