Skip to content
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

feat(cmd/gno): perform type checking before test #3887

Merged
merged 5 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions gnovm/cmd/gno/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,20 @@ func execTest(cfg *testCfg, args []string, io commands.IO) error {

memPkg := gno.MustReadMemPackage(pkg.Dir, gnoPkgPath)

var hasError bool

startedAt := time.Now()
hasError := catchRuntimeError(gnoPkgPath, io.Err(), func() {
runtimeError := catchRuntimeError(gnoPkgPath, io.Err(), func() {
foundErr, lintErr := lintTypeCheck(io, memPkg, opts.TestStore)
if lintErr != nil {
io.ErrPrintln(lintErr)
hasError = true
} else if foundErr {
hasError = true
}
err = test.Test(memPkg, pkg.Dir, opts)
})
hasError = hasError || runtimeError

duration := time.Since(startedAt)
dstr := fmtDuration(duration)
Expand All @@ -242,9 +252,7 @@ func execTest(cfg *testCfg, args []string, io commands.IO) error {
if err != nil {
io.ErrPrintfln("%s: test pkg: %v", pkg.Dir, err)
}
io.ErrPrintfln("FAIL")
io.ErrPrintfln("FAIL %s \t%s", pkg.Dir, dstr)
io.ErrPrintfln("FAIL")
testErrCount++
} else {
io.ErrPrintfln("ok %s \t%s", pkg.Dir, dstr)
Expand Down
25 changes: 25 additions & 0 deletions gnovm/cmd/gno/testdata/test/lint_error.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Test with a valid _test.gno file

! gno test -v .

stdout 'hello123'
stderr 'PASS: TestAlwaysValid'
stderr 'declared and not used: x'
stderr 'FAIL'

-- valid.gno --
package valid

func fn() {
x := 1
println("hello123")
}

-- valid_test.gno --
package valid

import "testing"

func TestAlwaysValid(t *testing.T) {
fn()
}
Loading