diff --git a/.github/workflows/llgo.yml b/.github/workflows/llgo.yml index f3f4ed7b..1c5cbb9b 100644 --- a/.github/workflows/llgo.yml +++ b/.github/workflows/llgo.yml @@ -137,8 +137,7 @@ jobs: go-version: ${{matrix.go}} - name: run llgo test - run: | - llgo test ./... + run: bash .github/workflows/llgo_test.sh hello: continue-on-error: true diff --git a/.github/workflows/llgo_test.sh b/.github/workflows/llgo_test.sh new file mode 100644 index 00000000..6137fd37 --- /dev/null +++ b/.github/workflows/llgo_test.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +output=$(llgo test ./... 2>&1) +echo "$output" + +pass_count=$(echo "$output" | grep -c "^PASS$") +echo "llgo test pass count: $pass_count" + +if [ "$pass_count" -gt 1 ]; then + echo "llgo test ./... passed" + exit 0 +else + echo "llgo test ./... failed: PASS count is not greater than 1" + exit 1 +fi diff --git a/internal/build/build_test.go b/internal/build/build_test.go index e7e599fd..a7d3cf38 100644 --- a/internal/build/build_test.go +++ b/internal/build/build_test.go @@ -58,6 +58,7 @@ func TestRun(t *testing.T) { } func TestTest(t *testing.T) { + // fixme:with builtin package test in a llgo test ./... will cause duplicate symbol error mockRun([]string{"../../cl/_testgo/runtest"}, &Config{Mode: ModeTest}) } diff --git a/test/bar/bar.go b/test/bar/bar.go new file mode 100644 index 00000000..5730a5c5 --- /dev/null +++ b/test/bar/bar.go @@ -0,0 +1,5 @@ +package bar + +func Bar() int { + return 2 +} diff --git a/test/bar/bar_test.go b/test/bar/bar_test.go new file mode 100644 index 00000000..b3e25c2f --- /dev/null +++ b/test/bar/bar_test.go @@ -0,0 +1,13 @@ +package bar_test + +import ( + "testing" + + "github.com/goplus/llgo/test/bar" +) + +func TestBar(t *testing.T) { + if bar.Bar() != 2 { + t.Fatal("Bar() != 2") + } +} diff --git a/test/bar/barinner/barinner.go b/test/bar/barinner/barinner.go new file mode 100644 index 00000000..b37a5d6d --- /dev/null +++ b/test/bar/barinner/barinner.go @@ -0,0 +1,5 @@ +package barinner + +func BarInner() int { + return 2 +} diff --git a/test/bar/barinner/barinner_test.go b/test/bar/barinner/barinner_test.go new file mode 100644 index 00000000..d2d79d03 --- /dev/null +++ b/test/bar/barinner/barinner_test.go @@ -0,0 +1,13 @@ +package barinner_test + +import ( + "testing" + + "github.com/goplus/llgo/test/bar/barinner" +) + +func TestBarInner(t *testing.T) { + if barinner.BarInner() != 2 { + t.Fatal("BarInner() != 2") + } +} diff --git a/test/foo/foo.go b/test/foo/foo.go new file mode 100644 index 00000000..96b79fa4 --- /dev/null +++ b/test/foo/foo.go @@ -0,0 +1,5 @@ +package foo + +func Foo() int { + return 1 +} diff --git a/test/foo/foo_test.go b/test/foo/foo_test.go new file mode 100644 index 00000000..aa11438a --- /dev/null +++ b/test/foo/foo_test.go @@ -0,0 +1,13 @@ +package foo_test + +import ( + "testing" + + "github.com/goplus/llgo/test/foo" +) + +func TestFoo(t *testing.T) { + if foo.Foo() != 1 { + t.Fatal("Foo() != 1") + } +}