Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions cmd/go-mutesting/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ MUTATOR:

tmpDir, err := os.MkdirTemp("", "go-mutesting-")
if err != nil {
panic(err)
return exitError("Could not create tmp dir: %v", err)
}
console.Verbose(opts, "Save mutations into %q", tmpDir)

Expand Down Expand Up @@ -225,15 +225,15 @@ MUTATOR:

err = os.MkdirAll(tmpDir+"/"+filepath.Dir(file), 0755)
if err != nil {
panic(err)
return exitError("Could not create dir for mutation file: %v", err)
}

tmpFile := tmpDir + "/" + file

originalFile := fmt.Sprintf("%s.original", tmpFile)
err = osutil.CopyFile(file, originalFile)
if err != nil {
panic(err)
return exitError("Could not copy original file %q: %v", file, err)
}
console.Debug(opts, "Save original into %q", originalFile)

Expand All @@ -258,7 +258,7 @@ MUTATOR:
if !opts.General.DoNotRemoveTmpFolder {
err = os.RemoveAll(tmpDir)
if err != nil {
panic(err)
return exitError("Could not remove tmp dir %q: %v", tmpDir, err)
}
console.Debug(opts, "Remove %q", tmpDir)
}
Expand Down Expand Up @@ -532,21 +532,14 @@ func mutateExec(
execCommand.Env = append(execCommand.Env, "TEST_RECURSIVE=true")
}

err := execCommand.Start()
if err != nil {
panic(err)
}

// TODO timeout here

err = execCommand.Wait()
err := execCommand.Run()

if err == nil {
execExitCode = 0
} else if e, ok := err.(*exec.ExitError); ok {
execExitCode = e.Sys().(syscall.WaitStatus).ExitStatus()
} else {
panic(err)
return exitError("Exec command failed unexpectedly: %v", err)
}

return execExitCode
Expand Down