Skip to content

time: add time tests and add std symbol coverage checks#1466

Merged
xushiwei merged 2 commits intogoplus:mainfrom
cpunion:fix-ticker
Dec 21, 2025
Merged

time: add time tests and add std symbol coverage checks#1466
xushiwei merged 2 commits intogoplus:mainfrom
cpunion:fix-ticker

Conversation

@cpunion
Copy link
Collaborator

@cpunion cpunion commented Dec 13, 2025

This PR contains two commits:

1) time: add time tests and fix timer semantics

  • Adds/updates the test/std/time suite.
  • Updates runtime/internal/lib/time so timers/tickers match Go semantics (e.g. Timer.Reset return value behavior).
  • Adds missing runtime helper runtime.AssertDivideByZero needed by the updated code.

2) chore: add check_std_symbols std coverage checks

  • Adds chore/check_std_symbols (with tests) to enforce std exported-symbol coverage.
  • Adds doc/_readme/scripts/check_std_cover.sh.
  • Wires the check into CI via:
    • .github/workflows/stdlib-coverage.yml
    • an extra step in .github/workflows/go.yml

Testing strategy

The test/std/time suite is exercised in two ways:

  • go test ./test/std/time validates the test harness and expected behavior against the Go toolchain.
  • ./llgo.sh test ./test/std/time validates LLGo’s runtime/stdlib implementation matches those expectations.

Verification

  • go test ./test/std/time
  • ./llgo.sh test ./test/std/time
  • go test ./chore/check_std_symbols
  • bash doc/_readme/scripts/check_std_cover.sh

@gemini-code-assist
Copy link

Summary of Changes

Hello @cpunion, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly updates the time package by synchronizing its test suite and runtime implementation with the standard library, thereby improving its robustness and feature set. It also introduces a new static analysis tool to ensure comprehensive test coverage for exported symbols, reinforcing code quality and maintainability. These changes collectively bring the time package closer to full stdlib compatibility and enhance its utility.

Highlights

  • Standard Library time Package Sync: The time test suite and LLGo time runtime shim have been synchronized with the upstream std-test branch, ensuring greater compatibility and up-to-date functionality.
  • New Symbol Coverage Checker: A new tool, chore/check_std_symbols, has been introduced to verify that all exported standard library symbols are covered by tests. This tool is integrated into the CI pipeline.
  • Runtime Symbol Fix: The missing runtime.AssertDivideByZero symbol, required by the synchronized code, has been added to the runtime.
  • Expanded time.Time Functionality: Several new methods have been added to the time.Time type, including Unix(), UnixMilli(), UnixMicro(), In(), Location(), Zone(), ZoneBounds(), AddDate(), Truncate(), and various serialization methods (Binary, Gob, JSON, Text).
  • Enhanced Time Zone Handling: The time package now includes LoadLocation() for loading time zone information by name and improved internal Location.lookup mechanisms.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/go.yml
    • .github/workflows/stdlib-coverage.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@xgopilot
Copy link
Contributor

xgopilot bot commented Dec 13, 2025

Code Review Summary

This PR adds a well-structured stdlib symbol coverage checker and syncs the time runtime implementation. The code demonstrates good engineering practices overall. Below are the key findings from comprehensive review:

Highlights:

  • Clean separation of concerns between symbol collection and usage tracking
  • Proper path traversal protection with pathWithin/pathWithinAbs
  • Secure shell script with proper quoting and error handling
  • Good use of Go's packages API for AST analysis

Key Issues to Address:

  • Missing package-level documentation for the new tool
  • Performance: serial package loading should be batched
  • Security: strengthen package path validation to reject .. sequences
  • Add comprehensive test coverage beyond the basic tests

See inline comments for specific recommendations.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request synchronizes the time package implementation and its test suite with the standard library, which includes several bug fixes and new features like support for periodic timers and additional time formatting/parsing capabilities. It also introduces a new tool, check_std_symbols, to verify test coverage of exported symbols in standard library packages.

My main feedback is regarding the implementation of the new coverage checker tool. It currently parses the output of go doc to find exported symbols, which is a fragile approach. I've suggested a more robust implementation using the go/packages library.

The rest of the changes, primarily syncing the time package, look solid and bring important improvements.

@codecov
Copy link

codecov bot commented Dec 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.58%. Comparing base (5627fb3) to head (9771b45).
⚠️ Report is 26 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1466   +/-   ##
=======================================
  Coverage   90.58%   90.58%           
=======================================
  Files          43       43           
  Lines       11429    11429           
=======================================
  Hits        10353    10353           
  Misses        914      914           
  Partials      162      162           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cpunion cpunion changed the title time: sync std suite and add std symbol coverage checks time: add time tests and add std symbol coverage checks Dec 13, 2025
@xushiwei xushiwei merged commit d748b83 into goplus:main Dec 21, 2025
43 checks passed
@cpunion cpunion deleted the fix-ticker branch March 6, 2026 02:33
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