use runner.LookChromeNames in TestMain

It supports alternative names for Chrome such as chromium, as well as
extra names to look for like headless-shell.

Also swap the os.Getenv logic, so that we only do the exec.LookPath work
if the env var is unset.
This commit is contained in:
Daniel Martí 2019-02-21 13:53:05 +01:00
parent 5dc1e0f3af
commit 5ca52f3e1b

View File

@ -4,7 +4,6 @@ import (
"context"
"log"
"os"
"os/exec"
"path"
"testing"
"time"
@ -78,16 +77,9 @@ func TestMain(m *testing.M) {
// its worth noting that newer versions of chrome (64+) run much faster
// than older ones -- same for headless_shell ...
execPath := runner.DefaultChromePath
if testRunner := os.Getenv("CHROMEDP_TEST_RUNNER"); testRunner != "" {
execPath = testRunner
} else {
// use headless_shell, if on path
var hsPath string
hsPath, err = exec.LookPath("headless_shell")
if err == nil {
execPath = hsPath
}
execPath := os.Getenv("CHROMEDP_TEST_RUNNER")
if execPath == "" {
execPath = runner.LookChromeNames("headless_shell")
}
cliOpts = append(cliOpts, runner.ExecPath(execPath))