From 5ca52f3e1b9421d01548d600198c7b07c559ba2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 21 Feb 2019 13:53:05 +0100 Subject: [PATCH] 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. --- chromedp_test.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/chromedp_test.go b/chromedp_test.go index 32589ec..e687f12 100644 --- a/chromedp_test.go +++ b/chromedp_test.go @@ -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))