feat(clock): add time and sleep accessor module - #375
Merged
Conversation
Zig 0.16 removes std.time's timestamp functions and std.Thread.sleep in favor of std.Io clock operations that require an io context. Centralizing the 27 sites now keeps that change out of every caller.
run() ignores stdin because 0.16's std.process.run hardcodes that; landing it now means the change is tested under the current toolchain.
Zig 0.16 removes Child.init, spawn, spawnAndWait, and collectOutput, replacing them with std.process.spawn/run, which need an io context. proc.Term uses 0.16's lowercase tag names so caller switches are final.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Complete Task 4 of the staged Zig 0.16 migration plan: centralize the 13 timestamp reads and 14 sleep calls while retaining Zig 0.15.2 compatibility.
Continue the same Prep 3 PR with Task 5: centralize subprocess execution while retaining Zig 0.15.2 compatibility.
Solution
src/clock.zigwith wall-clock and sleep accessors plus focused tests.src/main.zig.clock.build.zig, required becausesrc/app/control.zigimports../clock.zigand is compiled as its own module.src/proc.zigwithrunandspawnDetachedwrappers, focused subprocess tests, and the lowercaseproc.Termrepresentation required by the Zig 0.16 migration.proc.zigin the test registry and route URL opening, config-editor launch, PR listing, diff execution, and shell terminfo compilation through it.Context
This is the third prep commit sequence for the migration. The wrappers intentionally retain
std.timeandstd.Thread.sleepinternals until the later Zig 0.16std.Ioconversion. No behavior change is intended.The subprocess wrapper intentionally sets
stdin_behavior = .Ignore, matching the behavior hardcoded by Zig 0.16std.process.run; neithergh pr listnorgit diffreads stdin.Test plan
zig build— passed with directly installed Zig 0.15.2.zig build test— passed unpiped with directly installed Zig 0.15.2.just lint— passed, including test registry validation.zig fmt src/andgit diff --check— passed.src/clock.zig.std.process.Childcall sites remain outsidesrc/proc.zig, and no uppercase term tags remain at callers.zig build runin a repository with open pull requests and confirm ⌘P populates the PR dropdown; open the diff overlay and confirm the diff renders; click a terminal URL and confirm it opens in the browser; trigger open config and confirm the editor launches; and removeghfromPATHto confirm the PR dropdown shows its missing-ghstate.