Skip to content

Commit

Permalink
Do not attempt to open the browser in tests. (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
aalexand authored and nolanmar511 committed Nov 10, 2017
1 parent 9e20b5b commit e82ee9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func PProf(eo *plugin.Options) error {
}

if src.HTTPHostport != "" {
return serveWebInterface(src.HTTPHostport, p, o)
return serveWebInterface(src.HTTPHostport, p, o, true)
}
return interactive(p, o)
}
Expand Down
6 changes: 4 additions & 2 deletions internal/driver/webui.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type webArgs struct {
Top []report.TextItem
}

func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options) error {
func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options, wantBrowser bool) error {
host, portStr, err := net.SplitHostPort(hostport)
if err != nil {
return fmt.Errorf("could not split http address: %v", err)
Expand Down Expand Up @@ -123,7 +123,9 @@ func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options) e
},
}

go openBrowser("http://"+args.Hostport, o)
if wantBrowser {
go openBrowser("http://"+args.Hostport, o)
}
return server(args)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/driver/webui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestWebInterface(t *testing.T) {
Obj: fakeObjTool{},
UI: &stdUI{},
HTTPServer: creator,
})
}, false)
<-serverCreated
defer server.Close()

Expand Down

0 comments on commit e82ee9a

Please sign in to comment.