Ver código fonte

Do not attempt to open the browser in tests. (#259)

Alexey Alexandrov 7 anos atrás
pai
commit
e82ee9addc

+ 1
- 1
internal/driver/driver.go Ver arquivo

@@ -54,7 +54,7 @@ func PProf(eo *plugin.Options) error {
54 54
 	}
55 55
 
56 56
 	if src.HTTPHostport != "" {
57
-		return serveWebInterface(src.HTTPHostport, p, o)
57
+		return serveWebInterface(src.HTTPHostport, p, o, true)
58 58
 	}
59 59
 	return interactive(p, o)
60 60
 }

+ 4
- 2
internal/driver/webui.go Ver arquivo

@@ -81,7 +81,7 @@ type webArgs struct {
81 81
 	Top      []report.TextItem
82 82
 }
83 83
 
84
-func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options) error {
84
+func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options, wantBrowser bool) error {
85 85
 	host, portStr, err := net.SplitHostPort(hostport)
86 86
 	if err != nil {
87 87
 		return fmt.Errorf("could not split http address: %v", err)
@@ -123,7 +123,9 @@ func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options) e
123 123
 		},
124 124
 	}
125 125
 
126
-	go openBrowser("http://"+args.Hostport, o)
126
+	if wantBrowser {
127
+		go openBrowser("http://"+args.Hostport, o)
128
+	}
127 129
 	return server(args)
128 130
 }
129 131
 

+ 1
- 1
internal/driver/webui_test.go Ver arquivo

@@ -57,7 +57,7 @@ func TestWebInterface(t *testing.T) {
57 57
 		Obj:        fakeObjTool{},
58 58
 		UI:         &stdUI{},
59 59
 		HTTPServer: creator,
60
-	})
60
+	}, false)
61 61
 	<-serverCreated
62 62
 	defer server.Close()
63 63