on develop help sign in
Switch the gc test to headless chromium and sandbox it
commit962d419ba72485f404757ca8f5778f062679454e authorRyan Trinkle <ryan.trinkle@gmail.com> dateSun 13 Aug 2017, 17:15 (9 years ago) parentd7b859b
4 files changed+17−6
default.nix+1−1 reflex-dom-core/default.nix+7−4 reflex-dom-core/reflex-dom-core.cabal+2 reflex-dom-core/test/gc.hs+7−1
default.nix+1−1
@@ -1,6 +1,6 @@
11haskellPackages: nixpkgs: {
22 reflex-dom = haskellPackages.callPackage ./reflex-dom {};
33 reflex-dom-core = haskellPackages.callPackage ./reflex-dom-core {
4− inherit (nixpkgs) xvfb_run chromium;
4+ inherit (nixpkgs) iproute chromium;
55 };
66}
reflex-dom-core/default.nix+7−4
@@ -4,12 +4,12 @@
44, exception-transformers, ghcjs-dom, hlint, jsaddle, keycode, lens
55, monad-control, mtl, primitive, random, ref-tf, reflex, semigroups
66, stdenv, stm, template-haskell, temporary, text, these, time
7−, transformers, unbounded-delays, unix, zenc, hashable, xvfb_run
8−, chromium, process, jsaddle-warp
7+, transformers, unbounded-delays, unix, zenc, hashable
8+, chromium, process, jsaddle-warp, linux-namespaces, iproute
99}:
1010let addGcTestDepends = drv: if stdenv.system != "x86_64-linux" then drv else drv // {
11− testHaskellDepends = (drv.testHaskellDepends or []) ++ [ temporary jsaddle-warp process ];
12− testSystemDepends = (drv.testSystemDepends or []) ++ [ xvfb_run chromium ];
11+ testHaskellDepends = (drv.testHaskellDepends or []) ++ [ temporary jsaddle-warp process linux-namespaces ];
12+ testSystemDepends = (drv.testSystemDepends or []) ++ [ chromium iproute ];
1313 };
1414in mkDerivation (addGcTestDepends {
1515 pname = "reflex-dom-core";
@@ -31,6 +31,9 @@ in mkDerivation (addGcTestDepends {
3131 export HOME="$PWD"
3232 '';
3333
34+ # Show some output while running tests, so we might notice what's wrong
35+ testTarget = "--show-details=streaming";
36+
3437 testHaskellDepends = [ base hlint ];
3538 description = "Functional Reactive Web Apps with Reflex";
3639 license = stdenv.lib.licenses.bsd3;
reflex-dom-core/reflex-dom-core.cabal+2
@@ -146,8 +146,10 @@ test-suite gc
146146 , reflex-dom-core
147147 , jsaddle
148148 , jsaddle-warp
149+ , linux-namespaces
149150 , process
150151 , temporary
152+ , unix
151153 hs-source-dirs: test
152154 ghc-options: -rtsopts -with-rtsopts=-T -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans
153155 ghc-prof-options: -fprof-auto
reflex-dom-core/test/gc.hs+7−1
@@ -10,7 +10,9 @@ import Language.Javascript.JSaddle.Warp
1010import Reflex.Dom.Core
1111import System.Exit
1212import System.IO.Temp
13+import System.Linux.Namespaces
1314import System.Mem
15+import System.Posix
1416import System.Process
1517
1618-- In initial testing, the minimum live bytes count was 233128 and maximum was
@@ -32,12 +34,16 @@ failureLimit = 0
3234
3335main :: IO ()
3436main = do
37+ uid <- getEffectiveUserID
38+ unshare [User, Network]
39+ writeUserMappings Nothing [UserMapping 0 uid 1]
3540 mainThread <- myThreadId
3641 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'"
3843 let finishTest result = do
3944 interruptProcessGroupOf browserProcess
4045 throwTo mainThread result
46+ putStrLn "About to start the server"
4147 run 3911 $ do
4248 -- enableLogging True
4349 liftIO $ putStrLn "Running..."