@@ -7,11 +7,23 @@ import (
77)
88
99func BuildBinary (path string ) (string , error ) {
10- cmd := exec .Command ("go" , "install" , "-race" , path )
10+ // Install a version with race condition checking enabled and one without.
11+ cmd := exec .Command ("go" , "install" , path )
12+ race_cmd := exec .Command ("go" , "install" , "-race" , path )
1113 cmd .Env = os .Environ ()
1214 cmd .Env = append (cmd .Env , "GOBIN=/tmp" )
15+ race_cmd .Env = cmd .Env
16+ race_out , race_err := race_cmd .CombinedOutput ()
17+ // Rename the race binary.
18+ os .Rename (GetAutoRoutePath (false ), GetAutoRoutePath (true ))
1319 out , err := cmd .CombinedOutput ()
14- return string (out ), err
20+ ret_err := race_err
21+ ret_out := race_out
22+ if err != nil {
23+ ret_err = err
24+ ret_out = out
25+ }
26+ return string (ret_out ), ret_err
1527}
1628
1729func init () {
@@ -21,6 +33,16 @@ func init() {
2133 }
2234}
2335
24- func GetAutoRoutePath () string {
25- return "/tmp/autoroute"
36+ // Gets the path for the version of the autoroute binary.
37+ // Args:
38+ // race: Whether to use the version with race checking.
39+ // Returns:
40+ // The path requested.
41+ func GetAutoRoutePath (race bool ) string {
42+ path := "/tmp/autoroute"
43+ if race {
44+ path += "_race"
45+ }
46+
47+ return path
2648}
0 commit comments