-
Notifications
You must be signed in to change notification settings - Fork 11
cl: TestMockC ok #706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cl: TestMockC ok #706
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package foo | ||
|
|
||
| import "github.com/goplus/lib/c" | ||
|
|
||
| func f(a c.Int) c.Uint | ||
| func g() | ||
| func xprintf(fmt *c.Char, __llgo_va_list ...any) c.Int |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Copyright (c) 2026 The XGo Authors (xgo.dev). All rights reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "go/token" | ||
| "go/types" | ||
| "log" | ||
| "os" | ||
|
|
||
| "github.com/goplus/gogen" | ||
| "github.com/goplus/gogen/packages" | ||
| ) | ||
|
|
||
| func main() { | ||
| pkg := gogen.NewPackage("", "foo", &gogen.Config{ | ||
| Importer: packages.NewImporter(nil), | ||
| LoadNamed: nil, | ||
| HandleErr: nil, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: these six fields ( |
||
| NewBuiltin: nil, | ||
| NodeInterpreter: nil, | ||
| CanImplicitCast: nil, | ||
| DefaultGoFile: "", | ||
| }) | ||
| pkg.SetRedeclarable(true) | ||
| sig := types.NewSignatureType(nil, nil, nil, nil, nil, false) | ||
| _, err := pkg.NewFuncWith(token.NoPos, "g", sig, nil) | ||
| if err != nil { | ||
| log.Panicln("compileFunc:", "g", err) | ||
| } | ||
| err = pkg.WriteTo(os.Stdout) | ||
| if err != nil { | ||
| log.Panicln("gogen.WriteTo failed:", err) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that
TestMockCis enabled and run on everygo test, the unconditionalcl.SetDebug(cl.DbgFlagAll)will emit debuglog.Printlnoutput (fromcompileFunc/ param handling incl/compile.go) on every run, adding CI noise with no assertion value — the golden-file diff is what asserts correctness.Also note
SetDebugmutates package-level globals (debugCompileDecl/debugLoadDeps) and is never reset. It's harmless today becauseTestMockCis the only test incl_test, but if another test is later added to this package it would silently inheritDbgFlagAlldepending on run order. Consider dropping the call, gating it behindtesting.Verbose(), and/ordefer cl.SetDebug(0).