mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
neotest: gracefully report about coverage setup error
Don't use panic when we can use t.Fatal. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
2dc588ea95
commit
49f2e1dc64
2 changed files with 6 additions and 6 deletions
|
@ -48,7 +48,7 @@ func NewExecutor(t testing.TB, bc *core.Blockchain, validator, committee Signer)
|
|||
Validator: validator,
|
||||
Committee: committee,
|
||||
CommitteeHash: committee.ScriptHash(),
|
||||
collectCoverage: isCoverageEnabled(),
|
||||
collectCoverage: isCoverageEnabled(t),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,8 +452,8 @@ func (e *Executor) GetTxExecResult(t testing.TB, h util.Uint256) *state.AppExecR
|
|||
}
|
||||
|
||||
// EnableCoverage enables coverage collection for this executor, but only when `go test` is running with coverage enabled.
|
||||
func (e *Executor) EnableCoverage() {
|
||||
e.collectCoverage = isCoverageEnabled()
|
||||
func (e *Executor) EnableCoverage(t testing.TB) {
|
||||
e.collectCoverage = isCoverageEnabled(t)
|
||||
}
|
||||
|
||||
// DisableCoverage disables coverage collection for this executor until enabled explicitly through EnableCoverage.
|
||||
|
|
|
@ -70,7 +70,7 @@ type coverBlock struct {
|
|||
// documentName makes it clear when a `string` maps path to the script file.
|
||||
type documentName = string
|
||||
|
||||
func isCoverageEnabled() bool {
|
||||
func isCoverageEnabled(t testing.TB) bool {
|
||||
coverageLock.Lock()
|
||||
defer coverageLock.Unlock()
|
||||
|
||||
|
@ -83,7 +83,7 @@ func isCoverageEnabled() bool {
|
|||
if v, ok := os.LookupEnv(disableNeotestCover); ok {
|
||||
disabled, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("coverage: error when parsing environment variable '%s', expected bool, but got '%s'", disableNeotestCover, v))
|
||||
t.Fatalf("coverage: error when parsing environment variable '%s', expected bool, but got '%s'", disableNeotestCover, v)
|
||||
}
|
||||
disabledByEnvironment = disabled
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ func isCoverageEnabled() bool {
|
|||
// the file with our coverage when all tests are done.
|
||||
err := flag.Set(goCoverProfileFlag, "")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
t.Fatalf("coverage: failed to overwrite coverprofile flag: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue