on develop help sign in
Switch the gc test to headless chromium and sandbox it
962d419Ryan Trinkle
default.nix+1−1
@@ -1,6 +1,6 @@
1haskellPackages: nixpkgs: {
1haskellPackages: nixpkgs: {
2 reflex-dom = haskellPackages.callPackage ./reflex-dom {};
2 reflex-dom = haskellPackages.callPackage ./reflex-dom {};
3 reflex-dom-core = haskellPackages.callPackage ./reflex-dom-core {
3 reflex-dom-core = haskellPackages.callPackage ./reflex-dom-core {
4− inherit (nixpkgs) xvfb_run chromium;
4+ inherit (nixpkgs) iproute chromium;
5 };
5 };
6}
6}
reflex-dom-core/default.nix+7−4
@@ -4,12 +4,12 @@
4, exception-transformers, ghcjs-dom, hlint, jsaddle, keycode, lens
4, exception-transformers, ghcjs-dom, hlint, jsaddle, keycode, lens
5, monad-control, mtl, primitive, random, ref-tf, reflex, semigroups
5, monad-control, mtl, primitive, random, ref-tf, reflex, semigroups
6, stdenv, stm, template-haskell, temporary, text, these, time
6, stdenv, stm, template-haskell, temporary, text, these, time
7−, transformers, unbounded-delays, unix, zenc, hashable, xvfb_run
7+, transformers, unbounded-delays, unix, zenc, hashable
8−, chromium, process, jsaddle-warp
8+, chromium, process, jsaddle-warp, linux-namespaces, iproute
9}:
9}:
10let addGcTestDepends = drv: if stdenv.system != "x86_64-linux" then drv else drv // {
10let addGcTestDepends = drv: if stdenv.system != "x86_64-linux" then drv else drv // {
11− testHaskellDepends = (drv.testHaskellDepends or []) ++ [ temporary jsaddle-warp process ];
11+ testHaskellDepends = (drv.testHaskellDepends or []) ++ [ temporary jsaddle-warp process linux-namespaces ];
12− testSystemDepends = (drv.testSystemDepends or []) ++ [ xvfb_run chromium ];
12+ testSystemDepends = (drv.testSystemDepends or []) ++ [ chromium iproute ];
13 };
13 };
14in mkDerivation (addGcTestDepends {
14in mkDerivation (addGcTestDepends {
15 pname = "reflex-dom-core";
15 pname = "reflex-dom-core";
@@ -31,6 +31,9 @@ in mkDerivation (addGcTestDepends {
31 export HOME="$PWD"
31 export HOME="$PWD"
32 '';
32 '';
33
33
34+ # Show some output while running tests, so we might notice what's wrong
35+ testTarget = "--show-details=streaming";
36+
34 testHaskellDepends = [ base hlint ];
37 testHaskellDepends = [ base hlint ];
35 description = "Functional Reactive Web Apps with Reflex";
38 description = "Functional Reactive Web Apps with Reflex";
36 license = stdenv.lib.licenses.bsd3;
39 license = stdenv.lib.licenses.bsd3;
reflex-dom-core/reflex-dom-core.cabal+2
@@ -146,8 +146,10 @@ test-suite gc
146 , reflex-dom-core
146 , reflex-dom-core
147 , jsaddle
147 , jsaddle
148 , jsaddle-warp
148 , jsaddle-warp
149+ , linux-namespaces
149 , process
150 , process
150 , temporary
151 , temporary
152+ , unix
151 hs-source-dirs: test
153 hs-source-dirs: test
152 ghc-options: -rtsopts -with-rtsopts=-T -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans
154 ghc-options: -rtsopts -with-rtsopts=-T -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans
153 ghc-prof-options: -fprof-auto
155 ghc-prof-options: -fprof-auto
reflex-dom-core/test/gc.hs+7−1
@@ -10,7 +10,9 @@ import Language.Javascript.JSaddle.Warp
10import Reflex.Dom.Core
10import Reflex.Dom.Core
11import System.Exit
11import System.Exit
12import System.IO.Temp
12import System.IO.Temp
13+import System.Linux.Namespaces
13import System.Mem
14import System.Mem
15+import System.Posix
14import System.Process
16import System.Process
15
17
16-- In initial testing, the minimum live bytes count was 233128 and maximum was
18-- In initial testing, the minimum live bytes count was 233128 and maximum was
@@ -32,12 +34,16 @@ failureLimit = 0
32
34
33main :: IO ()
35main :: IO ()
34main = do
36main = do
37+ uid <- getEffectiveUserID
38+ unshare [User, Network]
39+ writeUserMappings Nothing [UserMapping 0 uid 1]
35 mainThread <- myThreadId
40 mainThread <- myThreadId
36 withSystemTempDirectory "reflex-dom-core_test_gc" $ \tmp -> do
41 withSystemTempDirectory "reflex-dom-core_test_gc" $ \tmp -> do
37− browserProcess <- spawnCommand $ "xvfb-run -a chromium --disable-gpu --user-data-dir=" ++ tmp ++ " http://localhost:3911"
42+ browserProcess <- spawnCommand $ "ip link set lo up ; ip addr ; sleep 1 ; echo 'Starting Chromium' ; chromium --headless --disable-gpu --no-sandbox --remote-debugging-port=9222 --user-data-dir=" ++ tmp ++ " http://localhost:3911 ; echo 'Chromium exited'"
38 let finishTest result = do
43 let finishTest result = do
39 interruptProcessGroupOf browserProcess
44 interruptProcessGroupOf browserProcess
40 throwTo mainThread result
45 throwTo mainThread result
46+ putStrLn "About to start the server"
41 run 3911 $ do
47 run 3911 $ do
42 -- enableLogging True
48 -- enableLogging True
43 liftIO $ putStrLn "Running..."
49 liftIO $ putStrLn "Running..."