Skip to content

Feat test n option#1317

Open
Mohamed-Moumni wants to merge 2 commits intomvdan:masterfrom
Mohamed-Moumni:feat-test-N-Option
Open

Feat test n option#1317
Mohamed-Moumni wants to merge 2 commits intomvdan:masterfrom
Mohamed-Moumni:feat-test-N-Option

Conversation

@Mohamed-Moumni
Copy link
Copy Markdown

Summary

  • Implement the -N file test operator (TsModif), which was previously unsupported and returned an error
  • Add interp/actime package with platform-specific GetAtime() functions (darwin, linux, windows) to retrieve file access time, as access time retrieval differs across platforms
  • Tested GetAtime() across all supported platforms, including Windows

Implemented #1316

Add platform-specific access time retrieval via the new actime package
(darwin, linux, windows) and use it to check if a file was modified
since it was last read (mtime > atime).
Add test cases for the -N operator covering modified-after-read,
non-existent file, and read-after-modification scenarios.
@mvdan
Copy link
Copy Markdown
Owner

mvdan commented Apr 9, 2026

We can't just support the three main GOOSes; e.g. CI also covers js and plan9 because some users care about less widespread platforms. At least there should be a fallback file for other platforms that acts as a no-op by returning the mod time.

We need the type assertions to use the _, ok syntax and fall back to the mod time if the type doesn't match, because a custom handler may return an implementation of fs.FileInfo that doesn't contain this type in Sys.

Finally, name these files consistently with os_unix.go, i.e. os_linux.go, os_darwin.go, and so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants