on develop help sign in
Use which to find chromium path
6fb99eeLuigy Leon
reflex-dom-core/default.nix+2−2
@@ -7,7 +7,7 @@
7, process, random, ref-tf, reflex, semigroups, silently, stdenv
7, process, random, ref-tf, reflex, semigroups, silently, stdenv
8, stm, template-haskell, temporary, text, these, transformers, unix
8, stm, template-haskell, temporary, text, these, transformers, unix
9, wai, wai-websockets, warp, webdriver, websockets, zenc
9, wai, wai-websockets, warp, webdriver, websockets, zenc
10−, iproute, chromium, hashable, selenium-server-standalone
10+, iproute, chromium, hashable, selenium-server-standalone, which
11}:
11}:
12let addGcTestDepends = drv: if stdenv.system != "x86_64-linux" then drv else drv // {
12let addGcTestDepends = drv: if stdenv.system != "x86_64-linux" then drv else drv // {
13 testHaskellDepends = (drv.testHaskellDepends or []) ++ [ temporary jsaddle-warp process linux-namespaces ];
13 testHaskellDepends = (drv.testHaskellDepends or []) ++ [ temporary jsaddle-warp process linux-namespaces ];
@@ -39,7 +39,7 @@ in mkDerivation (addGcTestDepends {
39 # Show some output while running tests, so we might notice what's wrong
39 # Show some output while running tests, so we might notice what's wrong
40 testTarget = "--show-details=streaming";
40 testTarget = "--show-details=streaming";
41
41
42− testSystemDepends = [ selenium-server-standalone ];
42+ testSystemDepends = [ selenium-server-standalone which ];
43 testHaskellDepends = [
43 testHaskellDepends = [
44 aeson base bytestring containers exceptions ghcjs-dom hlint hspec
44 aeson base bytestring containers exceptions ghcjs-dom hlint hspec
45 http-types HUnit jsaddle jsaddle-warp linux-namespaces process
45 http-types HUnit jsaddle jsaddle-warp linux-namespaces process
reflex-dom-core/test/hydration.hs+5−8
@@ -54,8 +54,8 @@ import qualified Test.WebDriver as WD
54testTimeLimit :: Int
54testTimeLimit :: Int
55testTimeLimit = 1 * 1000 * 1000
55testTimeLimit = 1 * 1000 * 1000
56
56
57−chromeConfig :: FilePath -> WD.WDConfig
57+chromeConfig :: Text -> WD.WDConfig
58−chromeConfig chromePath = WD.useBrowser (WD.chrome { WD.chromeBinary = Just "/nix/store/hf9r4nmjsz03mb73c11gn4prdcf47sxa-chromium-69.0.3497.81/bin/chromium", WD.chromeOptions = ["--headless"]}) WD.defaultConfig
58+chromeConfig fp = WD.useBrowser (WD.chrome { WD.chromeBinary = Just $ T.unpack fp, WD.chromeOptions = ["--headless"] }) WD.defaultConfig
59
59
60-- TODO list
60-- TODO list
61-- use only available ports
61-- use only available ports
@@ -682,12 +682,9 @@ testWidget' beforeJS afterSwitchover bodyWidget = maybe (error "test timed out")
682 -- hSilence to get rid of ConnectionClosed logs
682 -- hSilence to get rid of ConnectionClosed logs
683 jsaddleWarp = forkIO $ Warp.runSettings settings application
683 jsaddleWarp = forkIO $ Warp.runSettings settings application
684 bracket jsaddleWarp killThread $ \_ -> do
684 bracket jsaddleWarp killThread $ \_ -> do
685− (_, Just out, Just err, _) <- createProcess $ (shell "whereis chromium") { std_out = CreatePipe }
685+ browserPath <- T.strip . T.pack <$> readProcess "which" [ "chromiium" ] ""
686− whereisRes <- liftIO $ TE.decodeUtf8 <$> BS.hGetContents out
686+ when (T.null browserPath) $ fail "No browser was not found"
687− let chromePath = case T.words whereisRes of
688− _:path:_ -> path
689− _ -> "/run/current-system/sw/bin/chromium" -- TODO: Need proper error if chrome not found
690− WD.runSession (chromeConfig (T.unpack chromePath)) . WD.finallyClose $ do
687+ WD.runSession (chromeConfig browserPath) . WD.finallyClose $ do
691 WD.openPage $ "http://localhost:" <> show port
688 WD.openPage $ "http://localhost:" <> show port
692 a <- beforeJS
689 a <- beforeJS
693 liftIO $ putMVar waitBeforeJS ()
690 liftIO $ putMVar waitBeforeJS ()