Browse Source

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

Alexey Alexandrov 7 years ago
parent
commit
e82ee9addc
3 changed files with 6 additions and 4 deletions
  1. 1
    1
      internal/driver/driver.go
  2. 4
    2
      internal/driver/webui.go
  3. 1
    1
      internal/driver/webui_test.go

+ 1
- 1
internal/driver/driver.go View File

54
 	}
54
 	}
55
 
55
 
56
 	if src.HTTPHostport != "" {
56
 	if src.HTTPHostport != "" {
57
-		return serveWebInterface(src.HTTPHostport, p, o)
57
+		return serveWebInterface(src.HTTPHostport, p, o, true)
58
 	}
58
 	}
59
 	return interactive(p, o)
59
 	return interactive(p, o)
60
 }
60
 }

+ 4
- 2
internal/driver/webui.go View File

81
 	Top      []report.TextItem
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
 	host, portStr, err := net.SplitHostPort(hostport)
85
 	host, portStr, err := net.SplitHostPort(hostport)
86
 	if err != nil {
86
 	if err != nil {
87
 		return fmt.Errorf("could not split http address: %v", err)
87
 		return fmt.Errorf("could not split http address: %v", err)
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
 	return server(args)
129
 	return server(args)
128
 }
130
 }
129
 
131
 

+ 1
- 1
internal/driver/webui_test.go View File

57
 		Obj:        fakeObjTool{},
57
 		Obj:        fakeObjTool{},
58
 		UI:         &stdUI{},
58
 		UI:         &stdUI{},
59
 		HTTPServer: creator,
59
 		HTTPServer: creator,
60
-	})
60
+	}, false)
61
 	<-serverCreated
61
 	<-serverCreated
62
 	defer server.Close()
62
 	defer server.Close()
63
 
63