Skip to content

test: add reflect upstream and ixgo type round trips - #13

Merged
MeteorsLiu merged 4 commits into
xgo-dev:mainfrom
MeteorsLiu:codex/reflect-upstream-tests
Sep 21, 2026
Merged

MeteorsLiu merged 4 commits into
xgo-dev:mainfrom
MeteorsLiu:codex/reflect-upstream-tests

Conversation

@MeteorsLiu

Copy link
Copy Markdown
Collaborator

No description provided.

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: reflect round-trip test suite

Solid, well-structured addition. The tests thoughtfully verify that host-created reflect objects survive the guest sandbox boundary with before/during/after-Run assertions, dynamic discovery of upstream reflect tests via go list + AST parsing, and a completed write-back guard proving the guest closure actually ran. Documentation/citations were verified accurate (upstream test names, license paths, even a faithfully reproduced upstream typo). No performance concerns: the reflect test binary is built once and reused, with correctly layered guest (2m) / host (3m) timeouts.

Two findings below; both are non-blocking. All command execution and temp-file handling in upstream_test.go is safe (fixed arg slices, 0600/0755 perms, regexp.QuoteMeta applied).

Comment on lines +50 to +55
field := types[10].Field(0)
if field.Name != "Count" || field.Tag.Get("json") != "count" || field.Type != types[0] {
panic("StructOf field metadata changed")
}
if !types[12].IsVariadic() || types[12].In(1) != types[5] || types[12].Out(0) != types[0] {
panic("FuncOf signature changed")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Brittle hardcoded indices couple assertions to constructor order

types[10] (StructOf) and types[12] (variadic FuncOf), plus types[0]/types[5], reach into the slice from publicReflectTypes() using magic indices that must stay manually in sync with the constructor's element order. They are correct today, but inserting or reordering a type (e.g. a new ChanOf variant) would silently retarget these checks at the wrong element without any compile-time or test-time signal. Consider binding the interesting types to named locals and asserting against the names, or at minimum add a comment mapping each index to its constructor line.

Comment on lines +32 to +34
{Type: "bind", Source: "/", Target: "/", Options: []string{"ro"}},
{Type: "tmpfs", Target: "/tmp"},
{Type: "proc", Target: "/proc"},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Full-root / and /proc mounts widen the guest trust boundary

The sandbox bind-mounts all of host / (read-only) and mounts a full proc. Even read-only, this lets sandboxed test code read any file the process uid can (~/.ssh, cloud creds, CI tokens) and, via /proc/*/environ and /proc/*/cmdline, secrets from sibling processes. For a harness that only needs the Go toolchain and the compiled test binary, this is broader than necessary. If this only ever runs in an ephemeral, secret-free CI container it is acceptable, but consider narrowing the bind to runtime.GOROOT() (plus required dirs) and dropping/masking /proc if the reflect tests don't need it.

@MeteorsLiu
MeteorsLiu force-pushed the codex/reflect-upstream-tests branch from 6a17ced to 4d7c18f Compare September 18, 2026 04:04
@MeteorsLiu
MeteorsLiu force-pushed the codex/reflect-upstream-tests branch from 4d7c18f to 82b08c3 Compare September 21, 2026 07:32
@MeteorsLiu
MeteorsLiu merged commit 6db7c8b into xgo-dev:main Sep 21, 2026
7 checks passed
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