[#5] Add mutex to covertest
Printing coverage to file should be thread-safe Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
parent
8e4015f85f
commit
2c71079944
1 changed files with 6 additions and 0 deletions
|
@ -4,12 +4,15 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/compiler"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var mu sync.Mutex
|
||||
|
||||
type coverline struct {
|
||||
Doc string
|
||||
Opcode int
|
||||
|
@ -91,6 +94,9 @@ func countInstructions(cov []coverline, codes []InstrHash) {
|
|||
}
|
||||
|
||||
func printToFile(t testing.TB, cov []coverline, name string) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
f, err := os.OpenFile(name, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
Loading…
Reference in a new issue