Skip to content

Commit

Permalink
ci(test): update CI tests to cover gno test default directory behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemanya21 committed Jan 5, 2025
1 parent 28e79fe commit cf6382b
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 6 deletions.
6 changes: 0 additions & 6 deletions gnovm/cmd/gno/testdata/test/no_args.txtar

This file was deleted.

6 changes: 6 additions & 0 deletions gnovm/cmd/gno/testdata/test/no_path_empty_dir.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Run gno test without path argument on an empty dir

gno test

! stdout .+
stderr '[no test files]'
8 changes: 8 additions & 0 deletions gnovm/cmd/gno/testdata/test/no_path_empty_gno.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Test empty gno without path argument

gno test

! stdout .+
stderr '\? \. \[no test files\]'

-- empty.gno --
99 changes: 99 additions & 0 deletions gnovm/cmd/gno/testdata/test/no_path_flag_run.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Run test on gno.land/p/demo/ufmt without path argument

gno test

gno test -v

! stdout .+
stderr '=== RUN TestRun/hello'
stderr '=== RUN TestRun/hi_you'
stderr '=== RUN TestRun/hi_me'
stderr '=== RUN TestRun'
stderr '--- PASS: TestRun'

gno test -v -run .*

! stdout .+
stderr '=== RUN TestRun/hello'
stderr '=== RUN TestRun/hi_you'
stderr '=== RUN TestRun/hi_me'
stderr '=== RUN TestRun'
stderr '--- PASS: TestRun'

gno test -v -run NotExists

! stdout .+
! stderr '=== RUN TestRun'

gno test -v -run .*/hello

! stdout .+
stderr '=== RUN TestRun/hello'
! stderr '=== RUN TestRun/hi_you'
! stderr '=== RUN TestRun/hi_me'
stderr '=== RUN TestRun'
stderr '--- PASS: TestRun'

gno test -v -run .*/hi

! stdout .+
! stderr '=== RUN TestRun/hello'
stderr '=== RUN TestRun/hi_you'
stderr '=== RUN TestRun/hi_me'
stderr '=== RUN TestRun'
stderr '--- PASS: TestRun'

gno test -v -run .*/NotExists

! stdout .+
stderr '=== RUN TestRun'
stderr '--- PASS: TestRun'

gno test -v -run Run/.*

! stdout .+
stderr '=== RUN TestRun/hello'
stderr '=== RUN TestRun/hi_you'
stderr '=== RUN TestRun/hi_me'
stderr '=== RUN TestRun'
stderr '--- PASS: TestRun'

gno test -v -run Run/

! stdout .+
stderr '=== RUN TestRun/hello'
stderr '=== RUN TestRun/hi_you'
stderr '=== RUN TestRun/hi_me'
stderr '=== RUN TestRun'
stderr '--- PASS: TestRun'

gno test -v -run Run/hello

! stdout .+
stderr '=== RUN TestRun/hello'
! stderr '=== RUN TestRun/hi_you'
! stderr '=== RUN TestRun/hi_me'
stderr '=== RUN TestRun'
stderr '--- PASS: TestRun'

-- run.gno --
package run

-- run_test.gno --
package run

import (
"fmt"
"testing"
)

func TestRun(t *testing.T) {
cases := []string {
"hello",
"hi you",
"hi me",
}
for _, tc := range cases {
t.Run(tc, func(t *testing.T) {})
}
}
26 changes: 26 additions & 0 deletions gnovm/cmd/gno/testdata/test/no_path_valid_filetest.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Test with a valid _filetest.gno file

gno test

! stdout .+
stderr 'ok \. \d\.\d\ds'

gno test -v

stdout 'test'
stderr '=== RUN file/valid_filetest.gno'
stderr '--- PASS: file/valid_filetest.gno \(\d\.\d\ds\)'
stderr 'ok \. \d\.\d\ds'

-- valid.gno --
package valid

-- valid_filetest.gno --
package main

func main() {
println("test")
}

// Output:
// test
18 changes: 18 additions & 0 deletions gnovm/cmd/gno/testdata/test/no_path_valid_test.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Test with a valid _test.gno file without path argument

gno test

! stdout .+
stderr 'ok \. \d\.\d\ds'

-- valid.gno --
package valid

-- valid_test.gno --
package valid

import "testing"

func TestAlwaysValid(t *testing.T) {
// noop
}

0 comments on commit cf6382b

Please sign in to comment.