Skip to content

build:exit when test fail#1128

Merged
xushiwei merged 1 commit intogoplus:mainfrom
luoliwoshang:test/exit
May 21, 2025
Merged

build:exit when test fail#1128
xushiwei merged 1 commit intogoplus:mainfrom
luoliwoshang:test/exit

Conversation

@luoliwoshang
Copy link
Member

@luoliwoshang luoliwoshang commented May 21, 2025

with test fail,expect exit with no zero exit code.

package test_test

import "testing"

func TestExample(t *testing.T) {
	if 1 != 2 {
		t.Fatal("1 is not equal to 2")
	}
}
❯ go test     
echo $?
--- FAIL: TestExample (0.00s)
    test_test.go:7: 1 is not equal to 2
FAIL
exit status 1
FAIL    github.com/goplus/llgo/_xtool/tt        0.723s
1

but got

❯ llgo test
echo $?
--- FAIL: TestExample (0.00s)
    ???:1: 1 is not equal to 2
FAIL
/Users/zhangzhiyang/go/bin/tt.test: exit code 1
0

after update

FAIL
/Users/zhangzhiyang/go/bin/tt.test: exit code 1
1

@codecov
Copy link

codecov bot commented May 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.64%. Comparing base (44e1435) to head (0463230).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1128   +/-   ##
=======================================
  Coverage   86.64%   86.64%           
=======================================
  Files          29       29           
  Lines        7343     7343           
=======================================
  Hits         6362     6362           
  Misses        914      914           
  Partials       67       67           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cmd.Run()
if s := cmd.ProcessState; s != nil {
fmt.Fprintf(os.Stderr, "%s: exit code %d\n", app, s.ExitCode())
mockable.Exit(s.ExitCode())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't call s.ExitCode() twice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #1129

@xushiwei xushiwei requested a review from cpunion May 21, 2025 21:28
@@ -513,6 +513,7 @@ func linkMainPkg(ctx *context, pkg *packages.Package, pkgs []*aPackage, conf *Co
cmd.Run()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check error result:

err = cmd.Run()
if err != nil {
    panic(err)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's maybe a expect error ignore,because with the err check with the cmd.Run() will throw some note releated error stack.

--- FAIL: TestExample (0.00s)
    ???:1: 1 is not equal to 2
FAIL
panic: exit status 1

goroutine 1 [running]:
github.com/goplus/llgo/internal/build.linkMainPkg(0x1400af224b0, 0x1400009dba0, {0x1400bf28008, 0x70, 0x102c05020?}, 0x140001f4360, 0x3, 0x0)
        /Users/zhangzhiyang/Documents/Code/goplus/llgo/internal/build/build.go:515 +0x8d4
github.com/goplus/llgo/internal/build.Do({0x102ff8820, 0x0, 0x0}, 0x140001f4360)
        /Users/zhangzhiyang/Documents/Code/goplus/llgo/internal/build/build.go:271 +0xee4
github.com/goplus/llgo/cmd/internal/test.runCmd(0x22?, {0x102ff8820?, 0x14000076ae8?, 0x1027ba4d4?})
        /Users/zhangzhiyang/Documents/Code/goplus/llgo/cmd/internal/test/test.go:34 +0x8c
main.(*Cmd_test).Main.func1({0x102ff8820?, 0x1027ba4c4?, 0x14000206a00?})
        cmd/llgo/test_cmd.gox:27 +0x40
main.(*Cmd_test).Main.(*Command).Run__1.func2(0x14000206a00?, {0x102ff8820?, 0x4?, 0x102a91864?})
        /Users/zhangzhiyang/go/pkg/mod/github.com/goplus/cobra@v1.9.12/xcmd/classfile.go:87 +0x34
github.com/goplus/cobra.(*Command).execute(0x1400021b508, {0x102ff8820, 0x0, 0x0})
        /Users/zhangzhiyang/go/pkg/mod/github.com/goplus/cobra@v1.9.12/command.go:1019 +0x810
github.com/goplus/cobra.(*Command).ExecuteC(0x1400021a008)
        /Users/zhangzhiyang/go/pkg/mod/github.com/goplus/cobra@v1.9.12/command.go:1148 +0x350
github.com/goplus/cobra.(*Command).Execute(...)
        /Users/zhangzhiyang/go/pkg/mod/github.com/goplus/cobra@v1.9.12/command.go:1071

@xushiwei xushiwei merged commit 254db35 into goplus:main May 21, 2025
34 checks passed
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.

2 participants