Skip to content

Conversation

@cpunion
Copy link
Contributor

@cpunion cpunion commented Oct 21, 2025

Summary

  • add a portable doc/_readme/scripts/check_std_cover.sh helper that auto-discovers test/std suites
  • expand stdlib coverage and update docs/workflows/TODO guidance

Validation

  • go test ./test/std/...
  • doc/_readme/scripts/check_std_cover.sh
  • ./llgo.sh test ./test/std/...

15s llgo sweep (Dec 12 2025): temporarily stripped //go:build !llgo, compiled each suite with ./llgo.sh test -c -o /tmp/llgo_<pkg>.test (15s cap) and ran with -test.timeout=15s. Only hash/maphash and log passed; all other failures/compiles noted below and in test/TODO.md.

Coverage Status

Core Collections & Strings

  • bytes — 95/95
  • cmp — 4/4
  • ⚠️ iter — 4/4 (fails under llgo runtime - depens coro)
  • maps — 10/10
  • slices — 40/40
  • sort — 36/36
  • strings — 80/80
  • strconv — 40/40

Math & Numerics

  • math — 97/97
  • math/big — 154/154
  • ⚠️ math/bits — 50/50 (llgo test fails in 15s sweep: expected panic on division by zero)
  • math/rand — 37/37
  • math/rand/v2 — 54/54

Containers & Utilities

  • container/heap — 6/6
  • container/list — 19/19

Archives & Compression

  • ⚠️ archive/tar — 33/33 (llgo test fails: ErrInsecurePath )
  • ⚠️ archive/zip — 36/36 (llgo test fails: exit code -1)
  • ⚠️ compress/flate — 22/22 (llgo test fails in 15s sweep)
  • ⚠️ compress/gzip — 18/18 (llgo test fails in 15s sweep)
  • ⚠️ compress/zlib — 16/16 (llgo test fails in 15s sweep)

I/O & Filesystems

  • bufio — 51/51
  • ⚠️ embed — 4/4 (llgo test fails in 15s sweep)
  • ⚠️ io — 59/59 (llgo test timed out in 15s sweep)
  • ⚠️ io/fs — 22/22 (llgo test fails in 15s sweep)
  • ⚠️ io/ioutil — 8/8 (llgo compile fails in 15s sweep)
  • ⚠️ os — 157/157 (llgo compile fails in 15s sweep)
  • ⚠️ os/exec — 7/7 (llgo test fails: todo File.WriteString)
  • ⚠️ os/signal — 6/6 (llgo test fails: signal_enable not implemented)
  • ⚠️ os/user — 11/11 (llgo test fails: exit code -1)
  • path — 9/9
  • ⚠️ path/filepath — 27/27 (llgo test timed out in 15s sweep)

Encoding & Serialization

  • encoding — 6/6
  • ⚠️ encoding/asn1 — 42/42 (llgo compile fails: undefined symbol reflect.Copy)
  • encoding/base64 — 21/21
  • encoding/binary — 22/22
  • encoding/csv — 17/17
  • ⚠️ encoding/hex — 15/15 (llgo test fails in 15s sweep)
  • ⚠️ encoding/json — 48/48 (llgo test fails in 15s sweep)
  • encoding/pem — 3/3

Text & Unicode

Time & Scheduling

  • time — 101/101

Crypto & Security

  • crypto — 13/13
  • ⚠️ crypto/aes — 4/4 (llgo compile fails)
  • ⚠️ crypto/cipher — 9/9 (llgo compile fails)
  • ⚠️ crypto/des — 5/5 (llgo compile fails)
  • ⚠️ crypto/dsa — 9/9 (llgo compile fails)
  • ⚠️ crypto/ecdh — 12/12 (llgo compile fails)
  • ⚠️ crypto/ecdsa — 12/12 (llgo compile fails)
  • ⚠️ crypto/ed25519 — 17/17 (llgo compile fails)
  • ⚠️ crypto/elliptic — 13/13 (llgo compile fails)
  • ⚠️ crypto/hmac — 2/2 (llgo test fails: hmac.New unsupported)
  • crypto/md5 — 4/4
  • ⚠️ crypto/rand — 5/5 (llgo compile fails)
  • ⚠️ crypto/rc4 — 5/5 (llgo compile fails)
  • ⚠️ crypto/rsa — 30/30 (llgo compile fails)
  • crypto/sha1 — 4/4
  • ⚠️ crypto/sha256 — 7/7 (llgo test fails: hash length = 32, want 28)
  • ⚠️ crypto/sha3 — 23/23 (llgo compile fails: missing fips140 symbols)
  • ⚠️ crypto/sha512 — 13/13 (llgo test fails: hash length = 64, want 48)
  • ⚠️ crypto/subtle — 8/8 (llgo compile fails: missing runtime.* and XORBytes)
  • ⚠️ crypto/tls — 113/113 (llgo compile fails; runtime gap — see llgo cannot compile unique.Make demo #1358)
  • ⚠️ crypto/x509 — 76/76 (llgo compile fails)
  • crypto/x509/pkix — 15/15

Hashing

  • hash — 11/11
  • hash/adler32 — 10/10
  • hash/crc32 — 11/11
  • hash/maphash — 16/16

Networking & HTTP

Concurrency & Context

  • ⚠️ context — 13/13 (llgo test fails in 15s sweep)
  • ⚠️ sync — 40/40 (llgo compile fails in 15s sweep)
  • sync/atomic — 94/94

Language Tooling

  • go/ast — 0/?
  • go/build — 16/16
  • go/build/constraint — 19/19
  • go/constant — 14/14
  • go/doc — 0/?
  • go/doc/comment — 0/?
  • go/importer — 0/?
  • ⚠️ go/parser — 5/5 (llgo test timed out in 15s sweep)
  • go/scanner — 18/18
  • go/token — 45/45
  • go/types — 0/?
  • go/version — 3/3

Runtime & System

  • ⚠️ runtime — 62/62 (llgo test fails: TestTypeAssertionError/TestCleanup)
  • ⚠️ runtime/debug — 18/18 (llgo compile fails in 15s sweep)
  • ⚠️ runtime/pprof — 15/15 (llgo compile fails in 15s sweep)
  • ⚠️ runtime/trace — 10/10 (llgo compile fails in 15s sweep)
  • syscall — 0/? SKIP
  • unsafe — 8/8
  • weak — 2/2

Testing & Benchmarks

  • ⚠️ testing — 108/108 (llgo test timed out in 15s sweep)
  • ⚠️ testing/fstest — 9/9 (llgo test fails in 15s sweep)
  • testing/iotest — 10/10

Application & Formatting

  • errors — 6/6
  • flag — 74/74
  • fmt — 29/29
  • log — 41/41
  • mime — 13/13
  • ⚠️ mime/multipart — 7/7 (llgo compile fails in 15s sweep)
  • mime/quotedprintable — 5/5
  • ⚠️ reflect — 106/106 (llgo compile fails in 15s sweep; missing ChanDir.String, Copy, Swapper)
  • regexp — 45/45
  • regexp/syntax — 10/10

@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 enhances the testing infrastructure for the llgo compiler's compatibility with the Go standard library. It introduces a new chore utility to ensure comprehensive test coverage of exported symbols, establishes clear guidelines for writing and organizing standard library tests, and provides initial, extensive test suites for the math and strings packages. These changes are crucial for validating llgo's adherence to Go's standard library specifications and facilitating future contributions to test coverage.

Highlights

  • Standard Library Test Coverage Tool: Introduced chore/check_std_symbols/main.go, a new Go program designed to verify that all exported symbols of a specified standard library package are covered by tests in a given directory. It leverages go doc and go/packages for symbol and usage analysis, and explicitly disallows dot imports in test files for clarity.
  • Standard Library Test Documentation: Added test/TODO.md and test/std/README.md. test/TODO.md serves as a tracker for standard library package test coverage status, outlining priorities and contribution guidelines. test/std/README.md provides detailed instructions on how to structure, write, and run compatibility tests for Go standard library packages within the llgo project, including naming conventions, build tags, and documenting unsupported features.
  • Initial math Package Tests: Comprehensive test files (math_test.go, math_bench_test.go, math_go124_test.go) were added for the math standard library package, covering a wide range of unary and binary float functions, constants, bit conversions, and benchmarks.
  • Initial strings Package Tests: A new test file (strings_test.go) was added for the strings standard library package, providing extensive coverage for basic string manipulation, sequence functions, strings.Builder, strings.Reader, and strings.Replacer.
  • Gamma Function Refactoring: The Gamma and Gammaf functions in runtime/internal/clite/math/math.go and runtime/internal/lib/math/math.go were modified to delegate their implementation to Tgamma and Tgammaf (or cTgamma/cTgammaf via go:linkname), aligning with C library implementations for these gamma functions.
  • Test Directory Restructuring: The test/c_test.go file was moved to test/c/c_test.go, indicating a minor reorganization of the test suite.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/go.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.

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 introduces a new tool for checking standard library symbol coverage, adds comprehensive tests for the math and strings packages, and fixes an issue with math.Gamma. The new tooling is a valuable addition for maintaining test coverage. The approach of parsing go doc output is reasonable for an internal tool, though it can be fragile. I've identified a bug in the identifier parsing logic and an area where error handling could be improved. The new tests and the math.Gamma fix are well-implemented.

Comment on lines 319 to 251
func parseIdentifier(input string) string {
for i, r := range input {
if !(unicode.IsLetter(r) || unicode.IsDigit(r)) {
if i == 0 {
return ""
}
return input[:i]
}
}
return input
}

Choose a reason for hiding this comment

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

high

The current implementation of parseIdentifier does not correctly handle identifiers containing underscores (_). It will truncate the identifier at the first underscore. For example, an identifier like My_Func would be incorrectly parsed as My. This could lead to inaccurate coverage reports for symbols with underscores.

To fix this, the loop condition should also allow underscores.

Suggested change
func parseIdentifier(input string) string {
for i, r := range input {
if !(unicode.IsLetter(r) || unicode.IsDigit(r)) {
if i == 0 {
return ""
}
return input[:i]
}
}
return input
}
func parseIdentifier(input string) string {
for i, r := range input {
if !(unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_') {
if i == 0 {
return ""
}
return input[:i]
}
}
return input
}

@xgopilot
Copy link

xgopilot bot commented Oct 21, 2025

Code Review Summary

Excellent work on the stdlib testing infrastructure! The test organization is well-structured and the coverage checker is a valuable addition.

Key Strengths:

  • Comprehensive test coverage for math/strings packages (97 and 80 functions respectively)
  • Clear documentation and contributing guidelines
  • Good use of build tags for version-specific APIs
  • Proper CI integration

Priority Issues to Address

🔴 Security Issues

1. Command Injection Risk (chore/check_std_symbols/main.go:157)

  • User-controlled pkgPath passed to exec.Command without validation
  • Recommendation: Validate package paths with regex pattern ^[a-zA-Z0-9_/.-]+$

2. Path Traversal Risk (chore/check_std_symbols/main.go:98)

  • testDir not validated to stay within workspace
  • Recommendation: Verify resolved path has workspace as prefix

⚡ Performance Issues

3. Redundant File Parsing (chore/check_std_symbols/main.go:342-351)

  • Files parsed twice: once in ensureNoDotImports(), again in packages.Load()
  • Impact: O(n) redundant I/O for n test files
  • Recommendation: Check dot imports using loaded package data

4. Repeated filepath.Abs() in Hot Loop (chore/check_std_symbols/main.go:419-436)

  • Called for every identifier, but same dir value
  • Recommendation: Pre-compute absolute path once

5. Redundant CI Runs (.github/workflows/go.yml:48-58)

  • Coverage check runs on both Ubuntu and macOS, but is OS-independent
  • Recommendation: Run only on ubuntu-latest to save CI time

📝 Code Quality Issues

6. Complex Monolithic Function (chore/check_std_symbols/main.go:156-309)

  • 153-line function with high cyclomatic complexity
  • Recommendation: Extract parsing logic into separate functions per section

7. Incorrect Identifier Parsing (chore/check_std_symbols/main.go:319-329)

  • Doesn't handle underscores in Go identifiers
  • Recommendation: Update regex to include _ character

8. Global Mutable State (chore/check_std_symbols/main.go:69)

  • Global verbose variable makes testing difficult
  • Recommendation: Pass as parameter or use config struct

📚 Documentation Issues

9. Non-existent Directory Reference (test/std/README.md:80)

  • References test/py/ which doesn't exist (only test/c/ exists)
  • Recommendation: Remove or clarify as planned for future

10. Benchmark Quality (test/std/math/math_bench_test.go:7-12)

  • Constant inputs may be optimized away by compiler
  • Recommendation: Vary inputs and prevent dead code elimination

Overall Assessment: This PR adds valuable infrastructure with good test organization. The main concerns are security validations in the checker tool and some performance optimizations. The testing approach is solid and well-documented.

@cpunion cpunion changed the title Std test test: expand stdlib coverage (path/sort/text) ⚠️ Oct 21, 2025
@cpunion cpunion changed the title test: expand stdlib coverage (path/sort/text) ⚠️ test: expand stdlib coverage (path/sort/text/*) ⚠️ Oct 21, 2025
@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.58%. Comparing base (18f5f0b) to head (32a1613).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1365   +/-   ##
=======================================
  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 test: expand stdlib coverage (path/sort/text/*) ⚠️ test: expand stdlib coverage (math/strings/slices/path/sort/text/*) ⚠️ Oct 21, 2025
@cpunion cpunion changed the title test: expand stdlib coverage (math/strings/slices/path/sort/text/*) ⚠️ test: expand stdlib coverage suites Oct 21, 2025
@cpunion cpunion force-pushed the std-test branch 4 times, most recently from 3430f66 to 570888c Compare October 23, 2025 04:07
@cpunion cpunion force-pushed the std-test branch 3 times, most recently from d4ba40a to aafafe2 Compare October 23, 2025 09:29
@xgopilot xgopilot bot force-pushed the std-test branch 2 times, most recently from c7ac17a to 14d2dde Compare October 23, 2025 09:49
@cpunion cpunion force-pushed the std-test branch 8 times, most recently from bff585e to ec87b98 Compare October 24, 2025 15:41
- Add darwin and generic unix signal backends for os/signal\n- Route clite/signal through a C sigaction helper for ABI safety\n- Fix syscall.Kill to use libc kill(2)\n- Mark os/signal std suite green
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.

1 participant