-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cmd/gno): allow gno test to default to the current directory (#3453
) This PR resolves #3420 by enhancing the gno test command. The command now assumes the current directory (.) as the default path when no directory is specified, aligning its behavior with go test. Changes to CI: - Removed the no_args test. - Added new tests to cover the following scenarios: - Valid test execution. - Valid file-based test. - Test with flags. - Empty directory. - Empty test file. This PR is a repost of #3429 with a cleaner commit history. CC @notJoon @moul --------- Co-authored-by: Nemanya21 <[email protected]> Co-authored-by: Leon Hudak <[email protected]>
- Loading branch information
1 parent
90ff3e4
commit 8cca690
Showing
5 changed files
with
117 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) {}) | ||
} | ||
} |