Skip to content

Errorf not finishes test execution #150

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

Closed
DifferentialOrange opened this issue Mar 24, 2022 · 0 comments · Fixed by #160
Closed

Errorf not finishes test execution #150

DifferentialOrange opened this issue Mar 24, 2022 · 0 comments · Fixed by #160
Labels
bug Something isn't working code health Improve code readability, simplify maintenance and so on

Comments

@DifferentialOrange
Copy link
Member

DifferentialOrange commented Mar 24, 2022

We use t.Errorf in tests, for example

t.Errorf("Failed to connect: %s", err.Error())

It seems that by design t.Errorf do not stops test function execution, but it is expected in tests:

package main

import (
	"testing"
)

func TestEverything(t *testing.T) {
	a := "sdf"
	if a == "sdf" {
		t.Errorf("end")
	}
	t.Errorf("end 2")
}
=== RUN   TestEverything
    prog.go:10: end
    prog.go:12: end 2
--- FAIL: TestEverything (0.00s)
FAIL

Program exited.

Documentation says:

Errorf is equivalent to Logf followed by Fail.
Fail marks the function as having failed but continues execution.

We should use Fatalf(doc) or explicit returns where it's expected.

@DifferentialOrange DifferentialOrange added bug Something isn't working teamE code health Improve code readability, simplify maintenance and so on labels Mar 24, 2022
@DifferentialOrange DifferentialOrange self-assigned this Mar 24, 2022
@DifferentialOrange DifferentialOrange changed the title Errorf is not finishes test execution Errorf not finishes test execution Mar 24, 2022
@DifferentialOrange DifferentialOrange changed the title Errorf not finishes test execution Errorf not finishes a test execution Mar 24, 2022
@DifferentialOrange DifferentialOrange changed the title Errorf not finishes a test execution Errorf not finishes test execution Mar 24, 2022
@DifferentialOrange DifferentialOrange removed their assignment Apr 21, 2022
This was referenced Apr 21, 2022
vr009 added a commit that referenced this issue Apr 26, 2022
Changed error's suppression in check.yaml. The suppression of rule
`errcheck` may be removed after fixing errors check in all methods
with calling encodeXxx inside. See details below.
The rules `structcheck` and `unused` highlight the 'hack' with using
_msgpack struct{} `msgpack:",asArray"`. The workaround with `//nolint`
is not the best way to suppress it, cause this comment gets rendered
by godoc and there is no way to make it invisible. For details see
golang/go#20925.

Suppressed the highlighting of error check in all methods,
having encodeXxx inside. For now these methods are not able to
return any error cause of internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely'.

Fixed the use of time package API, all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests. That change
prevents nil dereferences below in the code and stops test function
execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions
(Rules structcheck,unused in golangci-lint).

Fixed calling of Fatalf from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 26, 2022
Changed error's suppression in check.yaml. The suppression of rule
`errcheck` may be removed after fixing errors check in all methods
with calling encodeXxx inside. See details below.
The rules `structcheck` and `unused` highlight the 'hack' with using
_msgpack struct{} `msgpack:",asArray"`. The workaround with `//nolint`
is not the best way to suppress it, cause this comment gets rendered
by godoc and there is no way to make it invisible. For details see
golang/go#20925.

Suppressed the highlighting of error check in all methods,
having encodeXxx inside. For now these methods are not able to
return any error cause of internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely'.

Fixed the use of time package API, all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests. That change
prevents nil dereferences below in the code and stops test function
execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions
(Rules structcheck,unused in golangci-lint).

Fixed calling of Fatalf from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 26, 2022
Changed error's suppression in check.yaml. The suppression of rule
`errcheck` may be removed after fixing errors check in all methods
with calling encodeXxx inside. See details below.
The rules `structcheck` and `unused` highlight the 'hack' with using
_msgpack struct{} `msgpack:",asArray"`. The workaround with `//nolint`
is not the best way to suppress it, cause this comment gets rendered
by godoc and there is no way to make it invisible. For details see
golang/go#20925.

Suppressed the highlighting of error check in all methods,
having encodeXxx inside. For now these methods are not able to
return any error cause of internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely'.

Fixed the use of time package API, all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests. That change
prevents nil dereferences below in the code and stops test function
execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions
(Rules structcheck,unused in golangci-lint).

Fixed calling of Fatalf from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 26, 2022
Changed error's suppression in check.yaml. The suppression of rule
`errcheck` may be removed after fixing errors check in all methods
with calling encodeXxx inside. See details below.
The rules `structcheck` and `unused` highlight the 'hack' with using
_msgpack struct{} `msgpack:",asArray"`. The workaround with `//nolint`
is not the best way to suppress it, cause this comment gets rendered
by godoc and there is no way to make it invisible. For details see
golang/go#20925.

Suppressed the highlighting of error check in all methods,
having encodeXxx inside. For now these methods are not able to
return any error cause of internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely'.

Fixed the use of time package API, all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests. That change
prevents nil dereferences below in the code and stops test function
execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions
(Rules structcheck,unused in golangci-lint).

Fixed calling of Fatalf from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 26, 2022
Changed error's suppression in check.yaml. The suppression of rule
`errcheck` may be removed after fixing errors check in all methods
with calling encodeXxx inside. See details below.
The rules `structcheck` and `unused` highlight the 'hack' with using
_msgpack struct{} `msgpack:",asArray"`. The workaround with `//nolint`
is not the best way to suppress it, cause this comment gets rendered
by godoc and there is no way to make it invisible. For details see
golang/go#20925.

Suppressed the highlighting of error check in all methods,
having encodeXxx inside. For now these methods are not able to
return any error cause of internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely'.

Fixed the use of time package API, all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests. That change
prevents nil dereferences below in the code and stops test function
execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions
(Rules structcheck,unused in golangci-lint).

Fixed calling of Fatalf from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Added instructions to CONTRIBUTING.md how to run CI-linter locally.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 26, 2022
Changed error's suppression in check.yaml. The suppression of rule
`errcheck` may be removed after adding errors check in all methods
with calling encodeXxx inside. See details below.

Suppressed the highlighting of error check in all methods,
having encodeXxx inside. For now these methods are not able to
return any error cause of internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely'.

Fixed the use of time package API, all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests. That change
prevents nil dereferences below in the code and stops test function
execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions

Fixed calling of Fatalf from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Added instructions to CONTRIBUTING.md how to run CI-linter locally.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 26, 2022
Changed error's suppression in check.yaml. The suppression of rule
`errcheck` may be removed after adding errors check in all methods
with calling encodeXxx inside. See details below.

Suppressed the highlighting of error check in all methods,
having encodeXxx inside. For now these methods are not able to
return any error cause of internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely'.

Fixed the use of time package API, all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests. That change
prevents nil dereferences below in the code and stops test function
execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions

Fixed calling of Fatalf from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Added instructions to CONTRIBUTING.md how to run CI-linter locally.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 28, 2022
Changed error's suppression in check.yaml. The suppression of rule
`errcheck` may be removed after adding errors check in all methods
with calling encodeXxx inside. See details below.

Suppressed the highlighting of error check in all methods,
having encodeXxx inside. For now these methods are not able to
return any error cause of internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely'.

Fixed the use of time package API, all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests. That change
prevents nil dereferences below in the code and stops test function
execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions

Fixed calling of Fatalf from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Added instructions to CONTRIBUTING.md how to run CI-linter locally.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 28, 2022
Changed error's suppression in check.yaml. The suppression of rule
`errcheck` may be removed after adding the errors check in all methods
with calling encodeXxx inside. See details below.

Suppressed the highlighting of the error check in all methods,
having encodeXxx inside. For now those methods are not able to
return any error cause of internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of the writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely'.

Fixed the use of time package API in all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of the Errorf() with Fatalf() in tests, where it is
needed. That change prevents nil dereferences below in the code and
stops the test execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions

Fixed the calling of Fatalf() from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed the gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Added instructions to CONTRIBUTING.md how to run CI-linter locally.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 28, 2022
Changed the warning's suppression in check.yaml. The suppression of rule
errcheck may be removed after adding the errors check in all methods
with calling encodeXxx inside. See details below.

Suppressed the highlighting lacks of error's check in all methods,
having encodeXxx inside. For now those methods are not able to
return any error due to internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of the writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely' for saving performance
(If there will be any affect on it).

Fixed the use of time package API in all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of the Errorf() with Fatalf() in tests, where it is
needed. That change prevents nil dereferences below in the code and
stops the test execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions

Fixed the calling of Fatalf() from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed the gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Added instructions to CONTRIBUTING.md how to run CI-linter locally.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 28, 2022
Changed the warning's suppression in check.yaml. The suppression of rule
errcheck may be removed after adding errors check in all methods
with calling encodeXxx inside. See details below.

Suppressed the highlighting lacks of error's check in all methods,
having encodeXxx inside. For now those methods are not able to
return any error due to internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of the writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely' for saving performance
(If there will be any affect on it).

Fixed the use of time package API in all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of the Errorf() with Fatalf() in tests, where it is
needed. That change prevents nil dereferences below in the code and
stops the test execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions

Fixed the calling of Fatalf() from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed the gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Added instructions to CONTRIBUTING.md how to run CI-linter locally.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 28, 2022
Changed the warning's suppression in check.yaml. The suppression
of the rule errcheck may be removed after adding errors check
in all methods calling encodeXxx inside. See details below.

Suppressed the highlighting lacks of error's check in all methods,
having encodeXxx inside. For now those methods are not able to
return any error due to internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of the writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely' for keeping performance
(If there will be any affect on it).

Fixed the use of time package API in all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests, where it is
needed. That change prevents nil dereferences below in the code and
stops the test execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions with //nolint comment.

Fixed the calling of Fatalf() from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed the gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Added instructions to CONTRIBUTING.md how to run CI-linter locally.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 28, 2022
Changed the warning's suppression in check.yaml. The suppression
of the rule errcheck may be removed after adding errors check
in all methods calling encodeXxx inside. See details below.

Suppressed the highlighting lacks of error's check in all methods,
having encodeXxx inside. For now those methods are not able to
return any error due to internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of the writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely' for keeping performance
(If there will be any affect on it).

Fixed the use of time package API in all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests, where it is
needed. That change prevents nil dereferences below in the code and
stops the test execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions with //nolint comment.

Fixed the calling of Fatalf() from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed the gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Added instructions to CONTRIBUTING.md how to run CI-linter locally.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 28, 2022
Changed the warning's suppression in check.yaml. The suppression
of the rule errcheck may be removed after adding errors check
in all methods calling encodeXxx inside. See details below.

Suppressed the highlighting lacks of error's check in all methods,
having encodeXxx inside. For now those methods are not able to
return any error due to internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of the writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely' for keeping performance
(If there will be any affect on it).

Fixed the use of time package API in all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests, where it is
needed. That change prevents nil dereferences below in the code and
stops the test execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions with //nolint comment.

Fixed the calling of Fatalf() from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed the gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Added instructions to CONTRIBUTING.md how to run CI-linter locally.

Closes #142
Closes #150
vr009 added a commit that referenced this issue Apr 28, 2022
Changed the warning's suppression in check.yaml. The suppression
of the rule errcheck may be removed after adding errors check
in all methods calling encodeXxx inside. See details below.

Suppressed the highlighting lacks of error's check in all methods,
having encodeXxx inside. For now those methods are not able to
return any error due to internal implementation of writer
interface (see smallbuf.go). For future, if the implementation of the writer
will be changed, and there will be a need to check errors, we must think
about how to say to compiler that the error check is 'unlikely' for keeping performance
(If there will be any affect on it).

Fixed the use of time package API in all places with calls of
time.Now().Sub(). Now time package propose the explicit time.Until().

Replaced all calls of Errorf() with Fatalf() in tests, where it is
needed. That change prevents nil dereferences below in the code and
stops the test execution, where it is expected in tests.

Suppressed the highlighting of all unused constants and functions with //nolint comment.

Fixed the calling of Fatalf() from non-testing goroutine in queue tests.
It is not a valid way to stop test from another goroutine.

Fixed the gofmt-highlighted places in test_helpers/pool_helper.go and
connection_pool/const.go.

Added instructions to CONTRIBUTING.md how to run CI-linter locally.

Closes #142
Closes #150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working code health Improve code readability, simplify maintenance and so on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant