tool test: TestPython - #923
Conversation
There was a problem hiding this comment.
Review summary
This PR adds a TestPython golden-file test case (Python 3.14.8 bindings) under tool/_testc/python-3.14.8/, and refactors debug flag handling in tool/gen_test.go by moving cl.SetDebug/tool.SetDebug out of init() and into TestClang with a deferred reset.
Overall: The change is well-scoped and test-only. The SetDebug relocation is a clean isolation improvement (tests run sequentially, no t.Parallel(), so the deferred reset reliably restores state). One golden fixture appears not to compile — flagged inline.
Notes (non-blocking):
- Debug scope change: Previously
init()enabledDbgFlagAllfor every test in the package. Now onlyTestClangruns with debug on;TestSingleC,TestPython, and the LLVM/_testcpptests run with it off. SincedebugSettingsonly gateslog.Printlndiagnostics, this is a cosmetic change and looks intentional — just confirming the intent. - macOS-only validation:
TestPythonuses the full-package path (testFromDir(..., false)), which early-returns on non-darwin (only test on macOS). The committed golden files (includingpyconfig.go's macOS-specific values likeHAVE_KQUEUE,WITH_DYLD,X_PYTHONFRAMEWORK = "Python") are therefore only verified on macOS runners. This is consistent with the existing suite pattern, but it means thepythread.goissue below is not caught by non-darwin CI.
| X_isInitialized c1.Int | ||
| X_key pthread.Key |
There was a problem hiding this comment.
[P2] Generated pythread.go references c1/pthread but imports neither
The golden file imports only the unaliased c package (import "github.com/goplus/lib/c"), and uses it correctly at PyLockStatus c.Uint. However, the X_PyTssT struct body references c1.Int and pthread.Key, neither of which is imported in this file:
type X_PyTssT struct {
X_isInitialized c1.Int // c1 undefined here
X_key pthread.Key // pthread undefined here
}As written this file cannot compile (undefined: c1, undefined: pthread, and c imported but unused — the c.Uint use alone doesn't change that both other identifiers are undefined). The sibling cpython-pythread.go in the same package shows the intended import block: c1 "github.com/goplus/lib/c" (aliased) plus "github.com/goplus/lib/c/pthread". Since this is DO NOT EDIT generated output, the mismatch points to a generator import-collection bug for this file — the body emits aliased/qualified names (c1, pthread) while the import writer emitted a plain unaliased c. Recommend regenerating and confirming the import block matches the referenced identifiers rather than hand-editing the golden file.
No description provided.