mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-09 23:24:09 -08:00
[test] Call cmd.Start and cmd.Wait separately to avoid triggering race detector (#616)
* [test] Call cmd.Start and cmd.Wait separately to avoid triggering race detector * [test] Enable race detector for tests
This commit is contained in:
parent
6e82fd1c56
commit
cb14fff6c6
2
Makefile
2
Makefile
|
@ -43,7 +43,7 @@ style:
|
|||
|
||||
test: collector/fixtures/sys/.unpacked
|
||||
@echo ">> running tests"
|
||||
@$(GO) test -short $(pkgs)
|
||||
@$(GO) test -short -race $(pkgs)
|
||||
|
||||
collector/fixtures/sys/.unpacked: collector/fixtures/sys.ttar
|
||||
./ttar -C collector/fixtures -x -f collector/fixtures/sys.ttar
|
||||
|
|
|
@ -107,9 +107,13 @@ func queryExporter(address string) error {
|
|||
}
|
||||
|
||||
func runCommandAndTests(cmd *exec.Cmd, fn func(pid int) error) error {
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("failed to start command: %s", err)
|
||||
}
|
||||
|
||||
errc := make(chan error)
|
||||
go func() {
|
||||
if err := cmd.Run(); err != nil {
|
||||
if err := cmd.Wait(); err != nil {
|
||||
errc <- fmt.Errorf("execution of command failed: %s", err)
|
||||
} else {
|
||||
errc <- nil
|
||||
|
|
Loading…
Reference in a new issue