Skip to content

cl: TestMockC ok - #706

Merged
xushiwei merged 1 commit into
goplus:devfrom
xushiwei:q
Sep 12, 2026
Merged

cl: TestMockC ok#706
xushiwei merged 1 commit into
goplus:devfrom
xushiwei:q

Conversation

@xushiwei

Copy link
Copy Markdown
Member

No description provided.

@xushiwei
xushiwei merged commit 1de331b into goplus:dev Sep 12, 2026
2 checks passed

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: PR #706

This PR bumps github.com/goplus/gogen v1.23.5 → v1.24.0, enables the previously-disabled mock-C test (_TestMockCTestMockC) with a new cl/_testmockc/function/ fixture, and adds a small standalone cmd/llgogen demo.

Verified locally:

  • go build ./cmd/llgogen/ succeeds; go run ./cmd/llgogen/ outputs the expected empty-body func g().
  • go.sum hashes for gogen v1.24.0 are consistent and legitimate (checked against the Go checksum DB by the security pass).
  • TestMockC itself requires the llgo/clang toolchain and can't be run in this plain-go test sandbox (relocation targets like C.clang_createIndex undefined) — build failure is an environment limitation, not a PR defect. The function fixture covers unsigned-return, void-no-arg, and variadic (__llgo_va_list ...any) cases, which is good coverage.

Overall this is a clean, low-risk change. Two minor/optional notes below; nothing blocking.

Comment thread cl/compile_test.go

func _TestMockC(t *testing.T) {
func TestMockC(t *testing.T) {
cl.SetDebug(cl.DbgFlagAll)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now that TestMockC is enabled and run on every go test, the unconditional cl.SetDebug(cl.DbgFlagAll) will emit debug log.Println output (from compileFunc / param handling in cl/compile.go) on every run, adding CI noise with no assertion value — the golden-file diff is what asserts correctness.

Also note SetDebug mutates package-level globals (debugCompileDecl/debugLoadDeps) and is never reset. It's harmless today because TestMockC is the only test in cl_test, but if another test is later added to this package it would silently inherit DbgFlagAll depending on run order. Consider dropping the call, gating it behind testing.Verbose(), and/or defer cl.SetDebug(0).

Comment thread cmd/llgogen/llgogen.go
pkg := gogen.NewPackage("", "foo", &gogen.Config{
Importer: packages.NewImporter(nil),
LoadNamed: nil,
HandleErr: nil,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: these six fields (LoadNamed, HandleErr, NewBuiltin, NodeInterpreter, CanImplicitCast, DefaultGoFile) are all set to their zero values, so they're no-ops. Trimming the literal to just Importer: packages.NewImporter(nil) makes the meaningful config clearer and avoids a needless compile break if gogen renames/removes any of these fields in a future bump. Optional.

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