Skip to content

Commit

Permalink
Merge pull request #418 from lread/lread-windows-proc2
Browse files Browse the repository at this point in the history
Proc-test for Windows compensates for scoop
  • Loading branch information
lread authored May 17, 2022
2 parents 6b45d7f + 2c888be commit 4dde749
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions test/etaoin/proc_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@

(defn get-count-chromedriver-instances
[]
(let [process-count (->> (if proc/windows?
(sh "tasklist")
(sh "sh" "-c" "ps aux"))
:out
str/split-lines
(filter #(str/includes? % "chromedriver"))
count)]
(if proc/windows?
(/ process-count 2) ;; on Windows we seem to have 2 chromedriver.exe instances per launch
process-count)))
(if proc/windows?
(->> (sh "powershell" "-command" "(Get-Process chromedriver -ErrorAction SilentlyContinue).Path")
:out
str/split-lines
(remove #(str/includes? % "\\scoop\\shims\\")) ;; for the scoop users, exclude the shim process
(filter #(str/includes? % "chromedriver"))
count)
(->> (sh "sh" "-c" "ps aux")
:out
str/split-lines
(filter #(str/includes? % "chromedriver"))
count)))

(deftest test-prevent-process-fork
(testing "certain driver port"
Expand All @@ -40,6 +42,7 @@
(let [port 9999
process (proc/run ["chromedriver" (format "--port=%d" port)])
_ (wait-running {:port port :host "localhost"})
_driver (chrome {:host "localhost" :port port :args ["--no-sandbox"]})]
driver (chrome {:host "localhost" :port port :args ["--no-sandbox"]})]
(is (= 1 (get-count-chromedriver-instances)))
(quit driver)
(proc/kill process))))

0 comments on commit 4dde749

Please sign in to comment.