on develop help sign in
Merge remote-tracking branch 'origin/develop' into cg-fix-requestert-prerender

* origin/develop: Reindent Fix overriding mkDerivation Revert "reflex-dom-core: Allow superfluous nix arguments" reflex-dom-core: Allow superfluous nix arguments Support newly split these/semialign packages Extend base version bounds Add note to changelog about base version bump Ignore list comprehension hlint suggestion Update hydration tests based on new hlint errors and changes to WD Bump base and stm versions

commit65185eef3f960fc54549b33b7bc7f04b7896ad19 authorAli Abrar <aliabrar@gmail.com> dateThu 14 Nov 2019, 14:04 (7 years ago) parent66c31c58b0dfd5
5 files changed+84−71
default.nix+42−48 reflex-dom-core/ChangeLog.md+2 reflex-dom-core/reflex-dom-core.cabal+14−3 reflex-dom-core/test/hlint.hs+1 reflex-dom-core/test/hydration.hs+25−20
default.nix+42−48
@@ -3,57 +3,51 @@ haskellPackages: let
33 inherit (pkgs) stdenv;
44 haskellLib = pkgs.haskell.lib;
55in {
6− reflex-dom-core = haskellPackages.callPackage
7− ({ temporary, jsaddle-warp, process, chrome-test-utils
8− , selenium-server-standalone, which, fontconfig, chromium, pkgs
9− }: let
10− inherit (haskellPackages) ghc;
11− noGcTest = stdenv.hostPlatform.system != "x86_64-linux"
12− || stdenv.hostPlatform != stdenv.buildPlatform
13− || (ghc.isGhcjs or false);
14− in haskellLib.overrideCabal
15− (haskellPackages.callCabal2nix "reflex-dom-core" ./reflex-dom-core { })
16− (drv: {
17− #TODO: Get hlint working for cross-compilation
18− doCheck = stdenv.hostPlatform == stdenv.buildPlatform && !(ghc.isGhcjs or false);
6+ reflex-dom-core = let
7+ inherit (haskellPackages) ghc;
8+ noGcTest = stdenv.hostPlatform.system != "x86_64-linux"
9+ || stdenv.hostPlatform != stdenv.buildPlatform
10+ || (ghc.isGhcjs or false);
11+ in haskellLib.overrideCabal
12+ (haskellPackages.callCabal2nix "reflex-dom-core" ./reflex-dom-core { })
13+ (drv: {
14+ #TODO: Get hlint working for cross-compilation
15+ doCheck = stdenv.hostPlatform == stdenv.buildPlatform && !(ghc.isGhcjs or false);
1916
20− # The headless browser run as part of the tests will exit without this
21− preBuild = ''
22− export HOME="$PWD"
23− '';
17+ # The headless browser run as part of the tests will exit without this
18+ preBuild = ''
19+ export HOME="$PWD"
20+ '';
2421
25− # Show some output while running tests, so we might notice what's wrong
26− testTarget = "--show-details=streaming";
22+ # Show some output while running tests, so we might notice what's wrong
23+ testTarget = "--show-details=streaming";
2724
28− testHaskellDepends = (drv.testHaskellDepends or []) ++ stdenv.lib.optionals (!noGcTest) [
29− temporary
30− jsaddle-warp
31− process
32− chrome-test-utils
33− ];
25+ testHaskellDepends = with haskellPackages; (drv.testHaskellDepends or []) ++ stdenv.lib.optionals (!noGcTest) [
26+ temporary
27+ jsaddle-warp
28+ process
29+ chrome-test-utils
30+ ];
3431
35− testSystemDepends = (drv.testSystemDepends or []) ++ [
36− selenium-server-standalone which
37− ] ++ stdenv.lib.optionals (!noGcTest) [
38− chromium
39− pkgs.iproute
40− ];
41− } // stdenv.lib.optionalAttrs (!noGcTest) {
42− # The headless browser run as part of gc tests would hang/crash without this
43− preCheck = ''
44− export FONTCONFIG_PATH=${fontconfig.out}/etc/fonts
45− '';
46− }))
47− {};
48− reflex-dom = haskellPackages.callPackage
49− ({ android-activity }: haskellLib.overrideCabal
50− (haskellPackages.callCabal2nix "reflex-dom" ./reflex-dom { })
51− (drv: {
52− # Hack until https://github.com/NixOS/cabal2nix/pull/432 lands
53− libraryHaskellDepends = (drv.libraryHaskellDepends or []) ++ stdenv.lib.optionals (with stdenv.hostPlatform; isAndroid && is32bit) [
54− android-activity
55− ];
56− }))
57− {};
32+ testSystemDepends = with pkgs; (drv.testSystemDepends or []) ++ [
33+ selenium-server-standalone which
34+ ] ++ stdenv.lib.optionals (!noGcTest) [
35+ chromium
36+ pkgs.iproute
37+ ];
38+ } // stdenv.lib.optionalAttrs (!noGcTest) {
39+ # The headless browser run as part of gc tests would hang/crash without this
40+ preCheck = ''
41+ export FONTCONFIG_PATH=${pkgs.fontconfig.out}/etc/fonts
42+ '';
43+ });
44+ reflex-dom = haskellLib.overrideCabal
45+ (haskellPackages.callCabal2nix "reflex-dom" ./reflex-dom { })
46+ (drv: {
47+ # Hack until https://github.com/NixOS/cabal2nix/pull/432 lands
48+ libraryHaskellDepends = (drv.libraryHaskellDepends or []) ++ stdenv.lib.optionals (with stdenv.hostPlatform; isAndroid && is32bit) [
49+ haskellPackages.android-activity
50+ ];
51+ });
5852 chrome-test-utils = haskellPackages.callCabal2nix "chrome-test-utils" ./chrome-test-utils {};
5953}
reflex-dom-core/ChangeLog.md+2
@@ -5,6 +5,8 @@
55## 0.5.2
66
77* Update to use new dependent-sum/map packages and drop dependency on `*Tag` classes (e.g., `ShowTag`).
8+* Update version bounds of base, containers, and stm
9+* Update to use the newly split `these`/`semialign` packages. To use the pre-split `these` package, set the `split-these` flag to false.
810* Reintroduce "data-ssr": elements without this attribute are skipped during
911 hydration.
1012* Fix an issue in the hydration tests that prevented the test from finding the chromium executable
reflex-dom-core/reflex-dom-core.cabal+14−3
@@ -39,6 +39,11 @@ flag profile-reflex
3939 default: False
4040 manual: True
4141
42+flag split-these
43+ description: Use split these/semialign packages
44+ manual: False
45+ default: True
46+
4247library
4348 hs-source-dirs: src
4449 build-depends:
@@ -48,7 +53,7 @@ library
4853 bimap >= 0.3 && < 0.4,
4954 blaze-builder,
5055 bytestring == 0.10.*,
51− containers >= 0.5 && < 0.7,
56+ containers >= 0.6 && < 0.7,
5257 constraints >= 0.9 && < 0.12,
5358 contravariant >= 1.4 && < 1.6,
5459 data-default >= 0.5 && < 0.8,
@@ -68,11 +73,9 @@ library
6873 random,
6974 ref-tf == 0.4.*,
7075 reflex >= 0.6.2,
71− semialign == 1.*,
7276 semigroups >= 0.16 && < 0.19,
7377 stm >= 2.4 && < 2.6,
7478 text == 1.2.*,
75− these >= 0.4 && < 1.1,
7679 transformers >= 0.3 && < 0.6,
7780 network-uri >= 2.6.1 && < 2.7,
7881 zenc == 0.1.*
@@ -87,6 +90,14 @@ library
8790 if !os(windows)
8891 build-depends: unix == 2.7.*
8992
93+ if flag(split-these)
94+ build-depends:
95+ semialign >= 1 && < 1.1,
96+ these >= 1 && < 1.1
97+ else
98+ build-depends:
99+ these >= 0.4 && < 0.9
100+
90101 exposed-modules:
91102 Foreign.JavaScript.TH
92103 Foreign.JavaScript.Orphans
reflex-dom-core/test/hlint.hs+1
@@ -16,6 +16,7 @@ main = do
1616 , "--ignore=Use unless"
1717 , "--ignore=Use if"
1818 , "--ignore=Use fewer imports"
19+ , "--ignore=Use list comprehension"
1920 , "--ignore=Unnecessary hiding" -- Interferes with cross-version compatibility
2021 , "--ignore=Use <$>"
2122 , "--ignore=Reduce duplication" --TODO: Re-enable this test
reflex-dom-core/test/hydration.hs+25−20
@@ -20,9 +20,11 @@
2020{-# LANGUAGE TypeApplications #-}
2121{-# LANGUAGE TypeFamilies #-}
2222
23+import Prelude hiding (fail)
2324import Control.Concurrent
24−import Control.Monad
25+import Control.Monad hiding (fail)
2526import Control.Monad.Catch
27+import Control.Monad.Fail
2628import Control.Monad.Fix
2729import Control.Monad.IO.Class
2830import Control.Monad.Ref
@@ -60,6 +62,7 @@ import Test.Hspec (xit)
6062import Test.Hspec.WebDriver hiding (runWD, click, uploadFile, WD)
6163import qualified Test.Hspec.WebDriver as WD
6264import Test.WebDriver (WD(..))
65+import Test.WebDriver.Exceptions (ServerError(..))
6366
6467import qualified Data.ByteString.Lazy as LBS
6568import qualified Data.Dependent.Map as DMap
@@ -121,6 +124,8 @@ deriveGEq ''DKey
121124deriveGCompare ''DKey
122125deriveGShow ''DKey
123126
127+deriving instance MonadFail WD
128+
124129main :: IO ()
125130main = do
126131 unshareNetork
@@ -741,9 +746,9 @@ tests withDebugging wdConfig caps _selenium = do
741746 pb <- getPostBuild
742747 performEvent_ $ liftIO (putMVar lock ()) <$ pb
743748 it "result Dynamic is updated *after* switchover" $ runWD $ do
744− let static = checkBodyText "PostBuild"
749+ let preSwitchover = checkBodyText "PostBuild"
745750 check = checkBodyText "Client"
746− testWidget static check $ void $ do
751+ testWidget preSwitchover check $ void $ do
747752 d <- prerender (pure "Initial") (pure "Client")
748753 pb <- getPostBuild
749754 initial <- sample $ current d
@@ -751,16 +756,16 @@ tests withDebugging wdConfig caps _selenium = do
751756 -- This essentially checks that the client IO runs *after* switchover/postBuild,
752757 -- thus can't create conflicting DOM
753758 it "can't exploit IO to break hydration" $ runWD $ do
754− let static = checkBodyText "Initial"
755− testWidgetStatic static $ void $ do
759+ let preSwitchover = checkBodyText "Initial"
760+ testWidgetStatic preSwitchover $ void $ do
756761 ref <- liftIO $ newRef "Initial"
757762 prerender_ (pure ()) (liftIO $ writeRef ref "Client")
758763 text <=< liftIO $ readRef ref
759764 -- As above, so below
760765 it "can't exploit triggerEvent to break hydration" $ runWD $ do
761− let static = checkBodyText "Initial"
766+ let preSwitchover = checkBodyText "Initial"
762767 check = checkBodyText "Client"
763− testWidget static check $ void $ do
768+ testWidget preSwitchover check $ void $ do
764769 (e, trigger) <- newTriggerEvent
765770 prerender_ (pure ()) (liftIO $ trigger "Client")
766771 textNode $ TextNodeConfig "Initial" $ Just e
@@ -949,26 +954,26 @@ tests withDebugging wdConfig caps _selenium = do
949954 postBuildPatch = PatchDMap $ DMap.fromList [Key_Char :=> ComposeMaybe Nothing, Key_Bool :=> ComposeMaybe (Just $ Identity True)]
950955 it "doesn't replace elements at switchover, can delete/update/insert" $ runWD $ do
951956 chan <- liftIO newChan
952− let static :: WD [WD.Element]
953− static = getAndCheckInitialItems keyMap
957+ let preSwitchover :: WD [WD.Element]
958+ preSwitchover = getAndCheckInitialItems keyMap
954959 check :: [WD.Element] -> WD ()
955960 check xs = do
956961 checkInitialItems keyMap xs
957962 checkRemoval chan Key_Int
958963 checkReplace chan Key_Char 'B'
959964 checkInsert chan Key_Bool True
960− testWidget' static check $ do
965+ testWidget' preSwitchover check $ do
961966 (dmap, _evt) <- traverseDMapWithKeyWithAdjust widget keyMap =<< triggerEventWithChan chan
962967 liftIO $ dmap `H.shouldBe` keyMap
963968 it "handles postBuild correctly" $ runWD $ do
964969 chan <- liftIO newChan
965− let static = getAndCheckInitialItems $ applyAlways postBuildPatch keyMap
970+ let preSwitchover = getAndCheckInitialItems $ applyAlways postBuildPatch keyMap
966971 check xs = do
967972 withRetry $ checkInitialItems (applyAlways postBuildPatch keyMap) xs
968973 checkRemoval chan Key_Int
969974 checkInsert chan Key_Char 'B'
970975 checkReplace chan Key_Bool True
971− testWidget' static check $ void $ do
976+ testWidget' preSwitchover check $ void $ do
972977 pb <- getPostBuild
973978 replace <- triggerEventWithChan chan
974979 (dmap, _evt) <- traverseDMapWithKeyWithAdjust widget keyMap $ leftmost [postBuildPatch <$ pb, replace]
@@ -1058,24 +1063,24 @@ tests withDebugging wdConfig caps _selenium = do
10581063 postBuildPatch = PatchIntMap $ IntMap.fromList [(2, Nothing), (3, Just "trois"), (4, Just "four")]
10591064 xit "doesn't replace elements at switchover, can delete/update/insert" $ runWD $ do
10601065 chan <- liftIO newChan
1061− let static = getAndCheckInitialItems intMap
1066+ let preSwitchover = getAndCheckInitialItems intMap
10621067 check xs = do
10631068 checkInitialItems intMap xs
10641069 checkRemoval chan 1
10651070 checkReplace chan 2 "deux"
10661071 checkInsert chan 4 "four"
1067− testWidget' static check $ void $ do
1072+ testWidget' preSwitchover check $ void $ do
10681073 (im, _evt) <- traverseIntMapWithKeyWithAdjust widget intMap =<< triggerEventWithChan chan
10691074 liftIO $ im `H.shouldBe` intMap
10701075 xit "handles postBuild correctly" $ runWD $ do
10711076 chan <- liftIO newChan
1072− let static = getAndCheckInitialItems $ applyAlways postBuildPatch intMap
1077+ let preSwitchover = getAndCheckInitialItems $ applyAlways postBuildPatch intMap
10731078 check xs = do
10741079 withRetry $ checkInitialItems (applyAlways postBuildPatch intMap) xs
10751080 checkRemoval chan 1
10761081 checkInsert chan 2 "deux"
10771082 checkReplace chan 3 "trois"
1078− testWidget' static check $ void $ do
1083+ testWidget' preSwitchover check $ void $ do
10791084 pb <- getPostBuild
10801085 replace <- triggerEventWithChan chan
10811086 (dmap, _evt) <- traverseIntMapWithKeyWithAdjust widget intMap $ leftmost [postBuildPatch <$ pb, replace]
@@ -1170,12 +1175,12 @@ tests withDebugging wdConfig caps _selenium = do
11701175
11711176 describe "hydration" $ moveSpec $ \initMap test -> do
11721177 chan <- liftIO newChan
1173− let static = getAndCheckInitialItems initMap
1178+ let preSwitchover = getAndCheckInitialItems initMap
11741179 check xs = do
11751180 checkInitialItems initMap xs
11761181 body <- getBody
11771182 test body chan
1178− testWidget' static check $ void $ do
1183+ testWidget' preSwitchover check $ void $ do
11791184 (dmap, _evt) <- traverseDMapWithKeyWithAdjustWithMove widget initMap =<< triggerEventWithChan chan
11801185 liftIO $ assertEqual "DMap" initMap dmap
11811186
@@ -1201,7 +1206,7 @@ tests withDebugging wdConfig caps _selenium = do
12011206
12021207 describe "hydrating invalid HTML" $ session' $ do
12031208 it "can hydrate list in paragraph" $ runWD $ do
1204− let static = do
1209+ let preSwitchover = do
12051210 checkBodyText "before\ninner\nafter"
12061211 -- Two <p> tags should be present
12071212 (p1, p2) <- WD.findElems (WD.ByTag "p") >>= \case
@@ -1217,7 +1222,7 @@ tests withDebugging wdConfig caps _selenium = do
12171222 shouldContainText "before\ninner\nafter" p1
12181223 elementShouldBeRemoved ol
12191224 elementShouldBeRemoved p2
1220− testWidget' static check $ do
1225+ testWidget' preSwitchover check $ do
12211226 -- This is deliberately invalid HTML, the browser will interpret it as
12221227 -- <p>before</p><ol>inner</ol>after<p></p>
12231228 el "p" $ do