File tree Expand file tree Collapse file tree 2 files changed +40
-12
lines changed
src/System/Nix/Store/Remote Expand file tree Collapse file tree 2 files changed +40
-12
lines changed Original file line number Diff line number Diff line change 55|-}
66module System.Nix.Store.Remote.Serialize where
77
8- import Data.Text
98import Data.Serialize (Serialize (.. ))
9+ import Data.Text (Text )
10+
11+ import qualified Data.Bool
12+ import qualified Data.Text
1013
1114import System.Nix.Build (BuildMode (.. ), BuildStatus (.. ), BuildResult (.. ))
1215import System.Nix.Store.Remote.Serialize.Prim
@@ -24,13 +27,23 @@ instance Serialize BuildStatus where
2427 put = putEnum
2528
2629instance Serialize BuildResult where
27- get =
28- BuildResult
30+ get = do
31+ status <- get
32+ errorMessage <-
33+ (\ em -> Data.Bool. bool (Just em) Nothing (Data.Text. null em))
2934 <$> get
30- -- TODO(srk): fishy
31- <*> (Just <$> get)
32- <*> getInt
33- <*> getBool
34- <*> getTime
35- <*> getTime
36- put = undefined
35+ timesBuilt <- getInt
36+ isNonDeterministic <- getBool
37+ startTime <- getTime
38+ stopTime <- getTime
39+ pure $ BuildResult {.. }
40+
41+ put BuildResult {.. } = do
42+ put status
43+ case errorMessage of
44+ Just err -> putText err
45+ Nothing -> putText mempty
46+ putInt timesBuilt
47+ putBool isNonDeterministic
48+ putTime startTime
49+ putTime stopTime
Original file line number Diff line number Diff line change @@ -102,11 +102,26 @@ prop_Text = roundTripS
102102prop_buildMode :: BuildMode -> Property
103103prop_buildMode = roundTripS
104104
105+ -- ** BuildStatus
106+
105107prop_buildStatus :: BuildStatus -> Property
106108prop_buildStatus = roundTripS
107109
108- spec_buildMode :: Spec
109- spec_buildMode =
110+ -- ** BuildResult
111+
112+ prop_buildResult :: Property
113+ prop_buildResult =
114+ forAll (arbitrary `suchThat` ((/= Just " " ) . System.Nix.Build. errorMessage))
115+ $ \ br ->
116+ roundTripS
117+ $ br { System.Nix.Build. startTime = Data.Time.Clock.POSIX. posixSecondsToUTCTime 0
118+ , System.Nix.Build. stopTime = Data.Time.Clock.POSIX. posixSecondsToUTCTime 0
119+ }
120+
121+ -- ** Enums
122+
123+ spec_buildEnums :: Spec
124+ spec_buildEnums =
110125 let it' name constr value = it name $ runPut (put constr) `shouldBe` runPut (putInt value)
111126 in do
112127 describe " Build enum order matches Nix" $ do
You can’t perform that action at this time.
0 commit comments