mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #7579 from drinkcat/test_file_N
test_test: Simplify test_file_N
This commit is contained in:
commit
68515b5d3b
1 changed files with 19 additions and 4 deletions
|
@ -918,16 +918,31 @@ fn test_bracket_syntax_version() {
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn test_file_N() {
|
fn test_file_N() {
|
||||||
|
use std::{fs::FileTimes, time::Duration};
|
||||||
|
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
let f = at.make_file("file");
|
let f = at.make_file("file");
|
||||||
f.set_modified(std::time::UNIX_EPOCH).unwrap();
|
|
||||||
|
|
||||||
|
// Set the times so that the file is accessed _after_ being modified
|
||||||
|
// => test -N return false.
|
||||||
|
let times = FileTimes::new()
|
||||||
|
.set_accessed(std::time::UNIX_EPOCH + Duration::from_secs(123))
|
||||||
|
.set_modified(std::time::UNIX_EPOCH);
|
||||||
|
f.set_times(times).unwrap();
|
||||||
|
// TODO: stat call for debugging #7570, remove?
|
||||||
|
println!("{}", scene.cmd_shell("stat file").succeeds().stdout_str());
|
||||||
scene.ucmd().args(&["-N", "file"]).fails();
|
scene.ucmd().args(&["-N", "file"]).fails();
|
||||||
// The file will have different create/modified data
|
|
||||||
// so, test -N will return 0
|
// Set the times so that the file is modified _after_ being accessed
|
||||||
at.touch("file");
|
// => test -N return true.
|
||||||
|
let times = FileTimes::new()
|
||||||
|
.set_accessed(std::time::UNIX_EPOCH)
|
||||||
|
.set_modified(std::time::UNIX_EPOCH + Duration::from_secs(123));
|
||||||
|
f.set_times(times).unwrap();
|
||||||
|
// TODO: stat call for debugging #7570, remove?
|
||||||
|
println!("{}", scene.cmd_shell("stat file").succeeds().stdout_str());
|
||||||
scene.ucmd().args(&["-N", "file"]).succeeds();
|
scene.ucmd().args(&["-N", "file"]).succeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue