[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:
Jerome Froelich 2017-07-08 14:15:40 -04:00 committed by Ben Kochie
parent 6e82fd1c56
commit cb14fff6c6
2 changed files with 6 additions and 2 deletions

View file

@ -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

View file

@ -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