Skip to content

new package cl/cltest - #702

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

new package cl/cltest#702
xushiwei merged 1 commit into
goplus:devfrom
xushiwei:q

Conversation

@xushiwei

Copy link
Copy Markdown
Member

No description provided.

@xushiwei
xushiwei merged commit 7037a71 into goplus:dev Sep 10, 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 Summary

This PR is clean, well-scoped WIP scaffolding: it renames the embedded clang.TranslationUnit in cl.Source to a named field TU, introduces a Config.NameLookup hook, and extracts the TestFromDir helper into a new reusable cl/cltest package while moving the test to an external cl_test package. Build and go vet pass for ./cl/....

Positives

  • Renaming the embedded field to TU avoids promoting all TranslationUnit methods onto Source — a real API-surface improvement.
  • Moving the helper to cl/cltest and switching to cl_test exercises the package through its public API.
  • New exported symbols carry doc comments; go.mod/go.sum correctly reflect the new github.com/qiniu/x dependency (test-only).

Notes (non-blocking)

  • No security or performance concerns found. The new github.com/qiniu/x dependency is confined to test code.
  • The main items are inline: Config.NameLookup is currently inert, and the only test covering the new path (_TestMockC) is disabled, so the rename/new package have no enforced CI coverage yet. Both are acceptable as scaffolding if a follow-up wires them in.

Comment thread cl/compile.go
*Reused

// NameLookup looks up the archive path for a given mangling name. It returns the archive path and a boolean indicating whether the lookup was successful.
NameLookup func(manglingName string) (archivePath string, ok bool)

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.

[P2] Config.NameLookup is declared but never consumed

The new NameLookup field is added to Config and documented as "looks up the archive path for a given mangling name," but nothing invokes it — loadFile discards the config via _ = conf and NewPackage only reads Reused/Importer/Fset. As a public field this can mislead consumers of the cl package into thinking it takes effect. Acceptable as scaffolding if the consumer lands in a follow-up; otherwise consider marking the doc as "reserved / not yet effective," and decide whether nil is permitted (and validated up front) when the callback is eventually wired in.

Comment thread cl/compile_test.go
}
*/

func _TestMockC(t *testing.T) {

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.

[P2] Only test of new path (_TestMockC) is disabled

_TestMockC is underscore-prefixed, so go test never runs it. It is the sole test exercising the new cl.Source{TU:} construction, Config.NameLookup, and cltest.TestFromDir. Combined with toType/goNodePos still being panic("todo"), none of the renamed/added code has enforced CI coverage. Fine as scaffolding, but consider a tracking note or enabling a minimal test once the stub panics are implemented so the refactor doesn't silently regress.

Comment thread cl/cltest/cltest.go
}
t.Run(name, func(t *testing.T) {
pkgDir := dir + "/" + name
if sel != "" && !strings.Contains(pkgDir, sel) {

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.

[P3] TestFromDir sel filter runs inside t.Run, emitting empty subtests

The sel != "" && !strings.Contains(pkgDir, sel) check is inside the t.Run(name, ...) closure, so every non-matching directory still spawns an (empty, passing) subtest and returns early rather than being skipped. The doc says "only subdirectories whose path contains sel will be tested," which reads as full exclusion. Behavior is unchanged from the original, but now that this is a shared exported helper, consider filtering before t.Run or using t.Skip to avoid noise-level subtests.

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