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

add t.Parallel() to speed up tests #81

Closed
wants to merge 1 commit into from

Conversation

alexandear
Copy link
Contributor

Fixes #75

The vgt tool is used to analyze tests execution:

$ go test -json -count=1 ./... | vgt

Before:

image

After:

image

See https://threedots.tech/post/go-test-parallelism/

@alexandear alexandear closed this Dec 2, 2024
@alexandear
Copy link
Contributor Author

Tests can't run in parallel:

Details

❯ make test
go test -count=1 ./...
?       github.com/nishanths/exhaustive/cmd/exhaustive  [no test files]
--- FAIL: TestExhaustive (0.00s)
    --- FAIL: TestExhaustive/default-signifies-exhaustive/default-absent/... (0.17s)
        analysistest.go:524: default-signifies-exhaustive/default-absent/default_absent.go:6:2: diagnostic "missing default case in switch of type dse.T" does not match pattern `^missing cases in switch of type dse.T: dse.B$`
        analysistest.go:588: default-signifies-exhaustive/default-absent/default_absent.go:6: no diagnostic was reported matching `^missing cases in switch of type dse.T: dse.B$`
    --- FAIL: TestExhaustive/duplicate-enum-value/... (0.17s)
        analysistest.go:524: duplicate-enum-value/duplicate_enum_value.go:34:2: diagnostic "missing default case in switch of type duplicateenumvalue.Chart" does not match pattern `^missing cases in switch of type duplicateenumvalue.Chart: duplicateenumvalue.Pie\|duplicateenumvalue.circle$`
        analysistest.go:588: duplicate-enum-value/duplicate_enum_value.go:34: no diagnostic was reported matching `^missing cases in switch of type duplicateenumvalue.Chart: duplicateenumvalue.Pie\|duplicateenumvalue.circle$`
        analysistest.go:522: duplicate-enum-value/otherpkg/otherpkg.go:11:2: unexpected diagnostic: missing default case in switch of type duplicateenumvalue.River
        analysistest.go:522: duplicate-enum-value/otherpkg/otherpkg.go:16:2: unexpected diagnostic: missing default case in switch of type duplicateenumvalue.River
        analysistest.go:522: duplicate-enum-value/otherpkg/otherpkg.go:39:2: unexpected diagnostic: missing default case in switch of type duplicateenumvalue.State
        analysistest.go:524: duplicate-enum-value/otherpkg/otherpkg.go:56:2: diagnostic "missing default case in switch of type duplicateenumvalue.River" does not match pattern `^missing cases in switch of type duplicateenumvalue.River: duplicateenumvalue.DefaultRiver\|duplicateenumvalue.Ganga, duplicateenumvalue.Kaveri$`
        analysistest.go:524: duplicate-enum-value/otherpkg/otherpkg.go:61:2: diagnostic "missing default case in switch of type duplicateenumvalue.State" does not match pattern `^missing cases in switch of type duplicateenumvalue.State: duplicateenumvalue.TamilNadu\|duplicateenumvalue.DefaultState, duplicateenumvalue.Kerala$`
        analysistest.go:524: duplicate-enum-value/otherpkg/otherpkg.go:75:2: diagnostic "missing default case in switch of type duplicateenumvalue.Chart" does not match pattern `^missing cases in switch of type duplicateenumvalue.Chart: duplicateenumvalue.Pie$`
        analysistest.go:588: duplicate-enum-value/otherpkg/otherpkg.go:56: no diagnostic was reported matching `^missing cases in switch of type duplicateenumvalue.River: duplicateenumvalue.DefaultRiver\|duplicateenumvalue.Ganga, duplicateenumvalue.Kaveri$`
        analysistest.go:588: duplicate-enum-value/otherpkg/otherpkg.go:61: no diagnostic was reported matching `^missing cases in switch of type duplicateenumvalue.State: duplicateenumvalue.TamilNadu\|duplicateenumvalue.DefaultState, duplicateenumvalue.Kerala$`
        analysistest.go:588: duplicate-enum-value/otherpkg/otherpkg.go:75: no diagnostic was reported matching `^missing cases in switch of type duplicateenumvalue.Chart: duplicateenumvalue.Pie$`
    --- FAIL: TestExhaustive/scope/pkgscope/... (0.18s)
        analysistest.go:522: scope/pkgscope/pkgscope.go:30:2: unexpected diagnostic: missing cases in switch of type pkgscope.T: pkgscope.D
        analysistest.go:522: scope/pkgscope/pkgscope.go:46:2: unexpected diagnostic: missing cases in switch of type pkgscope.Q: pkgscope.Y
        analysistest.go:522: scope/pkgscope/pkgscope.go:64:6: unexpected diagnostic: missing keys in map of key type pkgscope.T: pkgscope.D
        analysistest.go:522: scope/pkgscope/pkgscope.go:80:6: unexpected diagnostic: missing keys in map of key type pkgscope.Q: pkgscope.Y
        analysistest.go:522: scope/pkgscope/pkgscope.go:18:7: unexpected fact: C,D
        analysistest.go:522: scope/pkgscope/pkgscope.go:34:7: unexpected fact: X,Y
        analysistest.go:522: scope/pkgscope/pkgscope.go:52:7: unexpected fact: C,D
        analysistest.go:522: scope/pkgscope/pkgscope.go:68:7: unexpected fact: X,Y
    --- FAIL: TestExhaustive/default-case-required/default-required/... (0.05s)
        analysistest.go:588: default-case-required/default-required/default_required.go:7: no diagnostic was reported matching `^missing default case in switch of type dcr.T$`
    --- FAIL: TestExhaustive/default-signifies-exhaustive/default-present/... (0.06s)
        analysistest.go:522: default-signifies-exhaustive/default-present/default_present.go:9:2: unexpected diagnostic: missing cases in switch of type dse.T: dse.B
    --- FAIL: TestExhaustive/generated-file/check-generated-on/... (0.07s)
        analysistest.go:588: generated-file/check-generated-on/generated_0.go:11: no diagnostic was reported matching `^missing keys in map of key type generated.Direction: generated.E, generated.S, generated.W, generated.directionInvalid$`
        analysistest.go:588: generated-file/check-generated-on/generated_0.go:7: no diagnostic was reported matching `^missing cases in switch of type generated.Direction: generated.E, generated.S, generated.W, generated.directionInvalid$`
        analysistest.go:588: generated-file/check-generated-on/generated_3.go:13: no diagnostic was reported matching `^missing keys in map of key type generated.Direction: generated.E, generated.S, generated.W, generated.directionInvalid$`
        analysistest.go:588: generated-file/check-generated-on/generated_3.go:9: no diagnostic was reported matching `^missing cases in switch of type generated.Direction: generated.E, generated.S, generated.W, generated.directionInvalid$`
        analysistest.go:588: generated-file/check-generated-on/generated_4.go:11: no diagnostic was reported matching `^missing cases in switch of type generated.Direction: generated.E, generated.S, generated.W, generated.directionInvalid$`
        analysistest.go:588: generated-file/check-generated-on/generated_4.go:15: no diagnostic was reported matching `^missing keys in map of key type generated.Direction: generated.E, generated.S, generated.W, generated.directionInvalid$`
        analysistest.go:588: generated-file/check-generated-on/generated_doc_0.go:10: no diagnostic was reported matching `^missing cases in switch of type generated.Direction: generated.E, generated.S, generated.W, generated.directionInvalid$`
        analysistest.go:588: generated-file/check-generated-on/generated_doc_0.go:14: no diagnostic was reported matching `^missing keys in map of key type generated.Direction: generated.E, generated.S, generated.W, generated.directionInvalid$`
        analysistest.go:588: generated-file/check-generated-on/generated_doc_1.go:10: no diagnostic was reported matching `^missing keys in map of key type generated.Direction: generated.E, generated.S, generated.W, generated.directionInvalid$`
        analysistest.go:588: generated-file/check-generated-on/generated_doc_1.go:6: no diagnostic was reported matching `^missing cases in switch of type generated.Direction: generated.E, generated.S, generated.W, generated.directionInvalid$`
    --- FAIL: TestExhaustive/ignore-pattern/... (0.73s)
        analysistest.go:524: ignore-pattern/ignore_constant.go:15:2: diagnostic "missing cases in switch of type ignorepattern.Graph: ignorepattern.Graph_GRAPH_UNSPECIFIED, ignorepattern.Graph_GRAPH_PIE" does not match pattern `^missing cases in switch of type ignorepattern.Graph: ignorepattern.Graph_GRAPH_PIE$`
        analysistest.go:524: ignore-pattern/ignore_constant.go:26:2: diagnostic "missing cases in switch of type bar.Phylum: bar.Echinodermata, bar.Mollusca" does not match pattern `^missing cases in switch of type bar.Phylum: bar.Mollusca$`
        analysistest.go:522: ignore-pattern/ignore_type.go:18:2: unexpected diagnostic: missing cases in switch of type ignorepattern.label: ignorepattern.home, ignorepattern.other
        analysistest.go:522: ignore-pattern/ignore_type.go:29:2: unexpected diagnostic: missing cases in switch of type time.Duration: time.Microsecond, time.Millisecond, time.Second, time.Minute, time.Hour
        analysistest.go:522: ignore-pattern/ignore_type.go:41:2: unexpected diagnostic: missing cases in switch of type reflect.Kind: reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128, reflect.Array, reflect.Chan, reflect.Func, reflect.Map, reflect.Pointer|reflect.Ptr, reflect.Slice, reflect.String, reflect.Struct, reflect.UnsafePointer
        analysistest.go:524: ignore-pattern/ignore_type.go:67:2: diagnostic "missing cases in switch of type ignorepattern.Graph: ignorepattern.Graph_GRAPH_UNSPECIFIED, ignorepattern.Graph_GRAPH_PIE" does not match pattern `^missing cases in switch of type ignorepattern.Graph: ignorepattern.Graph_GRAPH_PIE$`
        analysistest.go:524: ignore-pattern/same_value.go:16:2: diagnostic "missing cases in switch of type ignorepattern.Access: ignorepattern.Standard|ignorepattern.User, ignorepattern.Group" does not match pattern `^missing cases in switch of type ignorepattern.Access: ignorepattern.Standard, ignorepattern.Group$`
        analysistest.go:524: ignore-pattern/ignore_constant.go:19:6: diagnostic "missing keys in map of key type ignorepattern.Graph: ignorepattern.Graph_GRAPH_UNSPECIFIED, ignorepattern.Graph_GRAPH_PIE" does not match pattern `^missing keys in map of key type ignorepattern.Graph: ignorepattern.Graph_GRAPH_PIE$`
        analysistest.go:524: ignore-pattern/ignore_constant.go:30:6: diagnostic "missing keys in map of key type bar.Phylum: bar.Echinodermata, bar.Mollusca" does not match pattern `^missing keys in map of key type bar.Phylum: bar.Mollusca$`
        analysistest.go:522: ignore-pattern/ignore_type.go:22:6: unexpected diagnostic: missing keys in map of key type ignorepattern.label: ignorepattern.work, ignorepattern.other
        analysistest.go:522: ignore-pattern/ignore_type.go:34:6: unexpected diagnostic: missing keys in map of key type time.Duration: time.Nanosecond, time.Microsecond, time.Millisecond, time.Second, time.Minute
        analysistest.go:522: ignore-pattern/ignore_type.go:49:6: unexpected diagnostic: missing keys in map of key type reflect.Kind: reflect.Invalid, reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128, reflect.Array, reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer|reflect.Ptr, reflect.Slice, reflect.String, reflect.Struct, reflect.UnsafePointer
        analysistest.go:524: ignore-pattern/ignore_type.go:71:6: diagnostic "missing keys in map of key type ignorepattern.Graph: ignorepattern.Graph_GRAPH_UNSPECIFIED, ignorepattern.Graph_GRAPH_PIE" does not match pattern `^missing keys in map of key type ignorepattern.Graph: ignorepattern.Graph_GRAPH_PIE$`
        analysistest.go:524: ignore-pattern/same_value.go:19:6: diagnostic "missing keys in map of key type ignorepattern.Access: ignorepattern.Standard|ignorepattern.User, ignorepattern.Group" does not match pattern `^missing keys in map of key type ignorepattern.Access: ignorepattern.Standard, ignorepattern.Group$`
        analysistest.go:588: ignore-pattern/ignore_constant.go:15: no diagnostic was reported matching `^missing cases in switch of type ignorepattern.Graph: ignorepattern.Graph_GRAPH_PIE$`
        analysistest.go:588: ignore-pattern/ignore_constant.go:19: no diagnostic was reported matching `^missing keys in map of key type ignorepattern.Graph: ignorepattern.Graph_GRAPH_PIE$`
        analysistest.go:588: ignore-pattern/ignore_constant.go:26: no diagnostic was reported matching `^missing cases in switch of type bar.Phylum: bar.Mollusca$`
        analysistest.go:588: ignore-pattern/ignore_constant.go:30: no diagnostic was reported matching `^missing keys in map of key type bar.Phylum: bar.Mollusca$`
        analysistest.go:588: ignore-pattern/ignore_type.go:67: no diagnostic was reported matching `^missing cases in switch of type ignorepattern.Graph: ignorepattern.Graph_GRAPH_PIE$`
        analysistest.go:588: ignore-pattern/ignore_type.go:71: no diagnostic was reported matching `^missing keys in map of key type ignorepattern.Graph: ignorepattern.Graph_GRAPH_PIE$`
        analysistest.go:588: ignore-pattern/same_value.go:16: no diagnostic was reported matching `^missing cases in switch of type ignorepattern.Access: ignorepattern.Standard, ignorepattern.Group$`
        analysistest.go:588: ignore-pattern/same_value.go:19: no diagnostic was reported matching `^missing keys in map of key type ignorepattern.Access: ignorepattern.Standard, ignorepattern.Group$`
FAIL
FAIL    github.com/nishanths/exhaustive 1.623s
FAIL
make: *** [Makefile:14: test] Error 1

@alexandear alexandear deleted the test-speed-up-test branch December 2, 2024 15:52
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.

go test ./... takes 35–45 seconds to complete
1 participant