on develop help sign in
wip: start selenium server before running hydration tests
7df7145Luigy Leon
reflex-dom-core/default.nix+2−1
@@ -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
10+, iproute, chromium, hashable, selenium-server-standalone
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,6 +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 testHaskellDepends = [
43 testHaskellDepends = [
43 aeson base bytestring containers exceptions ghcjs-dom hlint hspec
44 aeson base bytestring containers exceptions ghcjs-dom hlint hspec
44 http-types HUnit jsaddle jsaddle-warp linux-namespaces process
45 http-types HUnit jsaddle jsaddle-warp linux-namespaces process
reflex-dom-core/reflex-dom-core.cabal+2−1
@@ -168,6 +168,7 @@ test-suite hydration
168 , random
168 , random
169 , reflex == 0.5.*
169 , reflex == 0.5.*
170 , reflex-dom-core
170 , reflex-dom-core
171+ , process
171 , silently
172 , silently
172 , temporary
173 , temporary
173 , text
174 , text
@@ -177,7 +178,7 @@ test-suite hydration
177 , webdriver
178 , webdriver
178 , websockets
179 , websockets
179 hs-source-dirs: test
180 hs-source-dirs: test
180− ghc-options: -rtsopts -with-rtsopts=-T -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans
181+ ghc-options: -threaded -rtsopts -with-rtsopts=-T -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans
181 ghc-prof-options: -fprof-auto -optP-DPROFILING
182 ghc-prof-options: -fprof-auto -optP-DPROFILING
182 main-is: hydration.hs
183 main-is: hydration.hs
183 type: exitcode-stdio-1.0
184 type: exitcode-stdio-1.0
reflex-dom-core/test/hydration.hs+11−1
@@ -27,6 +27,7 @@ import Network.Wai
27import Network.WebSockets
27import Network.WebSockets
28import Reflex.Dom.Core
28import Reflex.Dom.Core
29import Reflex.Dom.Builder.Immediate (GhcjsDomSpace)
29import Reflex.Dom.Builder.Immediate (GhcjsDomSpace)
30+import System.Process
30import System.Random
31import System.Random
31import System.Timeout
32import System.Timeout
32import Test.Hspec
33import Test.Hspec
@@ -59,7 +60,7 @@ chromeConfig = WD.useBrowser (WD.chrome { WD.chromeBinary = Just "/run/current-s
59-- parallel (requires port fix)
60-- parallel (requires port fix)
60
61
61main :: IO ()
62main :: IO ()
62−main = hspec $ parallel $ do
63+main = hspec $ parallel $ beforeAll startSeleniumServer $ do
63
64
64 describe "text" $ parallel $ do
65 describe "text" $ parallel $ do
65 it "works" $ do
66 it "works" $ do
@@ -591,6 +592,15 @@ main = hspec $ parallel $ do
591 (traverse_ elementShouldBeRemoved)
592 (traverse_ elementShouldBeRemoved)
592 (el "span" $ prerender (text "One") (text "Two"))
593 (el "span" $ prerender (text "One") (text "Two"))
593
594
595+startSeleniumServer :: IO ()
596+startSeleniumServer = do
597+ (_,_,_,ph) <- createProcess $ (proc "selenium-server" [])
598+ { std_in = NoStream
599+ , std_out = NoStream
600+ }
601+ _ <- forkIO $ print =<< waitForProcess ph
602+ threadDelay $ 1000 * 1000 * 2 -- TODO poll or wait on a a signal to block on
603+
594assertAttr :: WD.Element -> Text -> Maybe Text -> WD ()
604assertAttr :: WD.Element -> Text -> Maybe Text -> WD ()
595assertAttr e k v = liftIO . assertEqual "Incorrect attribute value" v =<< WD.attr e k
605assertAttr e k v = liftIO . assertEqual "Incorrect attribute value" v =<< WD.attr e k
596
606