diff --git a/.github/workflows/llgo.yml b/.github/workflows/llgo.yml index 08fe6249..50756e0e 100644 --- a/.github/workflows/llgo.yml +++ b/.github/workflows/llgo.yml @@ -165,6 +165,7 @@ jobs: - name: run llgo test run: | + llgo test ./... cd _demo llgo test -v ./runtest diff --git a/compiler/chore/llgen/llgen_test.go b/compiler/chore/llgen/llgen_test.go index c24bdb70..5972943b 100644 --- a/compiler/chore/llgen/llgen_test.go +++ b/compiler/chore/llgen/llgen_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + package main import ( diff --git a/compiler/chore/llpyg/pysig/parse_test.go b/compiler/chore/llpyg/pysig/parse_test.go index 2f60944a..dbcde340 100644 --- a/compiler/chore/llpyg/pysig/parse_test.go +++ b/compiler/chore/llpyg/pysig/parse_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + /* * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. * diff --git a/compiler/cl/blocks/block_test.go b/compiler/cl/blocks/block_test.go index 8a6d9c8b..32366b9a 100644 --- a/compiler/cl/blocks/block_test.go +++ b/compiler/cl/blocks/block_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + /* * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. * diff --git a/compiler/cl/builtin_test.go b/compiler/cl/builtin_test.go index 657bc6b2..50996dee 100644 --- a/compiler/cl/builtin_test.go +++ b/compiler/cl/builtin_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + /* * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. * diff --git a/compiler/cl/compile_test.go b/compiler/cl/compile_test.go index 5922f66f..77bc0543 100644 --- a/compiler/cl/compile_test.go +++ b/compiler/cl/compile_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + /* * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. * diff --git a/compiler/cmd/llgo/llgo_test.go b/compiler/cmd/llgo/llgo_test.go index 943a3994..490147af 100644 --- a/compiler/cmd/llgo/llgo_test.go +++ b/compiler/cmd/llgo/llgo_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + package main import ( diff --git a/compiler/internal/build/build.go b/compiler/internal/build/build.go index a338dfd3..eda0d286 100644 --- a/compiler/internal/build/build.go +++ b/compiler/internal/build/build.go @@ -175,6 +175,14 @@ func Do(args []string, conf *Config) ([]Package, error) { } case ModeRun: return nil, fmt.Errorf("cannot run multiple packages") + case ModeTest: + newInitial := make([]*packages.Package, 0, len(initial)) + for _, pkg := range initial { + if needLink(pkg, mode) { + newInitial = append(newInitial, pkg) + } + } + initial = newInitial } } diff --git a/compiler/internal/build/build_test.go b/compiler/internal/build/build_test.go index 80d8db18..07c451e0 100644 --- a/compiler/internal/build/build_test.go +++ b/compiler/internal/build/build_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + package build import ( diff --git a/compiler/internal/buildtags/buildtags_test.go b/compiler/internal/buildtags/buildtags_test.go index 70d7c37d..1dffee77 100644 --- a/compiler/internal/buildtags/buildtags_test.go +++ b/compiler/internal/buildtags/buildtags_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + package buildtags import ( diff --git a/compiler/internal/env/env_test.go b/compiler/internal/env/env_test.go index 823edeeb..788c45a0 100644 --- a/compiler/internal/env/env_test.go +++ b/compiler/internal/env/env_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + package env import ( diff --git a/compiler/ssa/cl_test.go b/compiler/ssa/cl_test.go index 6aee3271..649d92cf 100644 --- a/compiler/ssa/cl_test.go +++ b/compiler/ssa/cl_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + /* * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. * diff --git a/compiler/ssa/package.go b/compiler/ssa/package.go index 323a4499..015b1fd6 100644 --- a/compiler/ssa/package.go +++ b/compiler/ssa/package.go @@ -387,14 +387,13 @@ func (p Program) NewPackage(name, pkgPath string) Package { pyobjs := make(map[string]PyObjRef) pymods := make(map[string]Global) strs := make(map[string]llvm.Value) - goStrs := make(map[string]llvm.Value) chkabi := make(map[types.Type]bool) glbDbgVars := make(map[Expr]bool) // Don't need reset p.needPyInit here // p.needPyInit = false ret := &aPackage{ mod: mod, vars: gbls, fns: fns, stubs: stubs, - pyobjs: pyobjs, pymods: pymods, strs: strs, goStrs: goStrs, + pyobjs: pyobjs, pymods: pymods, strs: strs, chkabi: chkabi, Prog: p, di: nil, cu: nil, glbDbgVars: glbDbgVars, } diff --git a/compiler/ssa/ssa_test.go b/compiler/ssa/ssa_test.go index fa0a58ca..2f88a7fa 100644 --- a/compiler/ssa/ssa_test.go +++ b/compiler/ssa/ssa_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + /* * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. * diff --git a/compiler/ssa/ssatest/ssautil_test.go b/compiler/ssa/ssatest/ssautil_test.go index 36eb6685..34913c15 100644 --- a/compiler/ssa/ssatest/ssautil_test.go +++ b/compiler/ssa/ssatest/ssautil_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + package ssatest import ( diff --git a/runtime/abi/map_test.go b/runtime/abi/map_test.go index fd300eba..5ff9acc0 100644 --- a/runtime/abi/map_test.go +++ b/runtime/abi/map_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + package abi import ( diff --git a/test/c_test.go b/test/c_test.go new file mode 100644 index 00000000..4802d6d1 --- /dev/null +++ b/test/c_test.go @@ -0,0 +1,21 @@ +//go:build llgo +// +build llgo + +package test + +import ( + "testing" + + "github.com/goplus/llgo/c" +) + +// Can't put it in c/ package because it is marked as 'decl' +func TestCstr(t *testing.T) { + cstr := c.Str("foo") + if cstr == nil { + t.Fatal("cstr() returned nil") + } + if c.Strlen(cstr) != 3 { + t.Fatal("cstr() returned invalid length") + } +} diff --git a/xtool/clang/_types/parser/_parser_test.go b/xtool/clang/_types/parser/_parser_test.go index 44ca0de3..be1a722e 100644 --- a/xtool/clang/_types/parser/_parser_test.go +++ b/xtool/clang/_types/parser/_parser_test.go @@ -1,3 +1,6 @@ +//go:build !llgo +// +build !llgo + /* * Copyright (c) 2022 The GoPlus Authors (goplus.org). All rights reserved. *