-
-
Save laurentsenta/5ed9fe9954605eefc1ed9ee2db7f66a9 to your computer and use it in GitHub Desktop.
Tests Skips with Go
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
package skips | |
import ( | |
"testing" | |
) | |
func TestAnother(t *testing.T) { | |
t.Run("a", func(t *testing.T) { | |
t.Run("b", func(t *testing.T) { | |
t.Fail() | |
}) | |
t.Run("2", func(t *testing.T) { | |
}) | |
}) | |
} | |
func TestThird(t *testing.T) { | |
t.Run("a", func(t *testing.T) { | |
t.Run("b", func(t *testing.T) { | |
t.Fail() | |
}) | |
t.Run("2", func(t *testing.T) { | |
}) | |
}) | |
} | |
func TestSkips(t *testing.T) { | |
t.Run("a", func(t *testing.T) { | |
t.Run("b", func(t *testing.T) { | |
t.Fail() | |
}) | |
t.Run("2", func(t *testing.T) { | |
}) | |
}) | |
} |
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
› go test ./skips/... -v ☹ | |
=== RUN TestAnother | |
=== RUN TestAnother/a | |
=== RUN TestAnother/a/b | |
=== RUN TestAnother/a/2 | |
--- FAIL: TestAnother (0.00s) | |
--- FAIL: TestAnother/a (0.00s) | |
--- FAIL: TestAnother/a/b (0.00s) | |
--- PASS: TestAnother/a/2 (0.00s) | |
=== RUN TestThird | |
=== RUN TestThird/a | |
=== RUN TestThird/a/b | |
=== RUN TestThird/a/2 | |
--- FAIL: TestThird (0.00s) | |
--- FAIL: TestThird/a (0.00s) | |
--- FAIL: TestThird/a/b (0.00s) | |
--- PASS: TestThird/a/2 (0.00s) | |
=== RUN TestSkips | |
=== RUN TestSkips/a | |
=== RUN TestSkips/a/b | |
=== RUN TestSkips/a/2 | |
--- FAIL: TestSkips (0.00s) | |
--- FAIL: TestSkips/a (0.00s) | |
--- FAIL: TestSkips/a/b (0.00s) | |
--- PASS: TestSkips/a/2 (0.00s) | |
FAIL | |
FAIL github.com/ipfs/gateway-conformance/skips 0.377s | |
FAIL |
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
# simple regexp, result is expected | |
› go test ./skips/... -skip "TestAnother/a/b" -v ☹ | |
=== RUN TestAnother | |
=== RUN TestAnother/a | |
=== RUN TestAnother/a/2 | |
--- PASS: TestAnother (0.00s) | |
--- PASS: TestAnother/a (0.00s) | |
--- PASS: TestAnother/a/2 (0.00s) | |
=== RUN TestThird | |
=== RUN TestThird/a | |
=== RUN TestThird/a/b | |
=== RUN TestThird/a/2 | |
--- FAIL: TestThird (0.00s) | |
--- FAIL: TestThird/a (0.00s) | |
--- FAIL: TestThird/a/b (0.00s) | |
--- PASS: TestThird/a/2 (0.00s) | |
=== RUN TestSkips | |
=== RUN TestSkips/a | |
=== RUN TestSkips/a/b | |
=== RUN TestSkips/a/2 | |
--- FAIL: TestSkips (0.00s) | |
--- FAIL: TestSkips/a (0.00s) | |
--- FAIL: TestSkips/a/b (0.00s) | |
--- PASS: TestSkips/a/2 (0.00s) | |
FAIL | |
FAIL github.com/ipfs/gateway-conformance/skips 0.106s | |
FAIL | |
( |
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
# equiv of (TestSkips) | (TestAnother/a/b) | |
› go test ./skips/... -skip "TestSkips|TestAnother/a/b" -v ☹ | |
=== RUN TestAnother | |
=== RUN TestAnother/a | |
=== RUN TestAnother/a/2 | |
--- PASS: TestAnother (0.00s) | |
--- PASS: TestAnother/a (0.00s) | |
--- PASS: TestAnother/a/2 (0.00s) | |
=== RUN TestThird | |
=== RUN TestThird/a | |
=== RUN TestThird/a/b | |
=== RUN TestThird/a/2 | |
--- FAIL: TestThird (0.00s) | |
--- FAIL: TestThird/a (0.00s) | |
--- FAIL: TestThird/a/b (0.00s) | |
--- PASS: TestThird/a/2 (0.00s) | |
FAIL | |
FAIL github.com/ipfs/gateway-conformance/skips 0.103s | |
FAIL |
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
› go test ./skips/... -skip "(TestSkips|TestAnother)/a/b" -v ☹ | |
=== RUN TestAnother | |
=== RUN TestAnother/a | |
=== RUN TestAnother/a/2 | |
--- PASS: TestAnother (0.00s) | |
--- PASS: TestAnother/a (0.00s) | |
--- PASS: TestAnother/a/2 (0.00s) | |
=== RUN TestThird | |
=== RUN TestThird/a | |
=== RUN TestThird/a/b | |
=== RUN TestThird/a/2 | |
--- FAIL: TestThird (0.00s) | |
--- FAIL: TestThird/a (0.00s) | |
--- FAIL: TestThird/a/b (0.00s) | |
--- PASS: TestThird/a/2 (0.00s) | |
=== RUN TestSkips | |
=== RUN TestSkips/a | |
=== RUN TestSkips/a/2 | |
--- PASS: TestSkips (0.00s) | |
--- PASS: TestSkips/a (0.00s) | |
--- PASS: TestSkips/a/2 (0.00s) | |
FAIL | |
FAIL github.com/ipfs/gateway-conformance/skips 0.271s | |
FAIL |
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
› go test ./skips/... -v -skip "TestSkips|.*/a/b" ☹ | |
=== RUN TestAnother | |
=== RUN TestAnother/a | |
=== RUN TestAnother/a/2 | |
--- PASS: TestAnother (0.00s) | |
--- PASS: TestAnother/a (0.00s) | |
--- PASS: TestAnother/a/2 (0.00s) | |
=== RUN TestThird | |
=== RUN TestThird/a | |
=== RUN TestThird/a/2 | |
--- PASS: TestThird (0.00s) | |
--- PASS: TestThird/a (0.00s) | |
--- PASS: TestThird/a/2 (0.00s) | |
PASS | |
ok github.com/ipfs/gateway-conformance/skips 0.295s |
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
# TestSkips is never matched, | |
# seems like this is due to golang's splitting the regexp + operator | |
# operator precedence means we are matching: | |
# [part1] against (.*) | |
# [part2] against a | |
# [part3] against (b|TestSkips) | |
# which gives a surprising results. | |
# we would use: | |
# (.*/a/b)|(TestSkips) | |
› go test ./skips/... -v -skip ".*/a/b|TestSkips" ☺ | |
=== RUN TestAnother | |
=== RUN TestAnother/a | |
=== RUN TestAnother/a/2 | |
--- PASS: TestAnother (0.00s) | |
--- PASS: TestAnother/a (0.00s) | |
--- PASS: TestAnother/a/2 (0.00s) | |
=== RUN TestThird | |
=== RUN TestThird/a | |
=== RUN TestThird/a/2 | |
--- PASS: TestThird (0.00s) | |
--- PASS: TestThird/a (0.00s) | |
--- PASS: TestThird/a/2 (0.00s) | |
=== RUN TestSkips | |
=== RUN TestSkips/a | |
--- PASS: TestSkips (0.00s) | |
--- PASS: TestSkips/a (0.00s) | |
PASS | |
ok github.com/ipfs/gateway-conformance/skips 0.100s | |
( |
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
# Equivalent of Piotr's example: | |
# https://github.com/ipfs/gateway-conformance/pull/148#discussion_r1300140500 | |
# Result is not expected, because we are matching: | |
# [part1] against (TestSkips|TestAnother/a/.*) | |
# Which means that TestSkips is skipped as expected | |
# "TestAnother/a/.*" does NOT match "TestAnother" | |
# | |
› go test ./skips/... -skip "(TestSkips|TestAnother/a/.*)" -v ☹ | |
=== RUN TestAnother | |
=== RUN TestAnother/a | |
=== RUN TestAnother/a/b | |
=== RUN TestAnother/a/2 | |
--- FAIL: TestAnother (0.00s) | |
--- FAIL: TestAnother/a (0.00s) | |
--- FAIL: TestAnother/a/b (0.00s) | |
--- PASS: TestAnother/a/2 (0.00s) | |
=== RUN TestThird | |
=== RUN TestThird/a | |
=== RUN TestThird/a/b | |
=== RUN TestThird/a/2 | |
--- FAIL: TestThird (0.00s) | |
--- FAIL: TestThird/a (0.00s) | |
--- FAIL: TestThird/a/b (0.00s) | |
--- PASS: TestThird/a/2 (0.00s) | |
FAIL | |
FAIL github.com/ipfs/gateway-conformance/skips 0.108s | |
FAIL |
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
# these two results are confusing: | |
# in the first attempt, ".*/a/b|TestSkips", TestSkips is NOT matched, (see above, how parts are split) | |
# but in the second attempt, "TestAnother/a/2|TestSkips", TestSkips is matched. | |
# It seems like the presence of a regexp syntax changes precedence? | |
› go test ./skips/... -v -skip ".*/a/b|TestSkips" ☹ | |
=== RUN TestAnother | |
=== RUN TestAnother/a | |
=== RUN TestAnother/a/2 | |
--- PASS: TestAnother (0.00s) | |
--- PASS: TestAnother/a (0.00s) | |
--- PASS: TestAnother/a/2 (0.00s) | |
=== RUN TestThird | |
=== RUN TestThird/a | |
=== RUN TestThird/a/2 | |
--- PASS: TestThird (0.00s) | |
--- PASS: TestThird/a (0.00s) | |
--- PASS: TestThird/a/2 (0.00s) | |
=== RUN TestSkips | |
=== RUN TestSkips/a | |
--- PASS: TestSkips (0.00s) | |
--- PASS: TestSkips/a (0.00s) | |
PASS | |
ok github.com/ipfs/gateway-conformance/skips 0.100s | |
in ~/dev/plabs/gateway-conformance on feat-generate-dashboard | |
› go test ./skips/... -skip "TestAnother/a/2|TestSkips" -v ☺ | |
=== RUN TestAnother | |
=== RUN TestAnother/a | |
=== RUN TestAnother/a/b | |
--- FAIL: TestAnother (0.00s) | |
--- FAIL: TestAnother/a (0.00s) | |
--- FAIL: TestAnother/a/b (0.00s) | |
=== RUN TestThird | |
=== RUN TestThird/a | |
=== RUN TestThird/a/b | |
=== RUN TestThird/a/2 | |
--- FAIL: TestThird (0.00s) | |
--- FAIL: TestThird/a (0.00s) | |
--- FAIL: TestThird/a/b (0.00s) | |
--- PASS: TestThird/a/2 (0.00s) | |
FAIL | |
FAIL github.com/ipfs/gateway-conformance/skips 0.099s | |
FAIL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment