Skip to content

Commit 9923c95

Browse files
committed
WIP omit CDDLC tests in Hydra on Windows
1 parent 2a05321 commit 9923c95

File tree

3 files changed

+57
-32
lines changed
  • nix
  • ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano
  • ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/Serialisation

3 files changed

+57
-32
lines changed

nix/haskell.nix

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,17 @@ let
3838
({ pkgs, lib, ... }: lib.mkIf pkgs.stdenv.hostPlatform.isWindows {
3939
# https://github.com/input-output-hk/haskell.nix/issues/2332
4040
packages.basement.configureFlags = [ "--hsc2hs-option=--cflag=-Wno-int-conversion" ];
41+
# We can't cross-compile the ruby gem `cddlc` so we decided to skip this
42+
# test on Windows in Hydra.
43+
packages.ouroboros-consensus-cardano.components.tests.cardano-test.preCheck = ''
44+
export DISABLE_CDDLC=1
45+
'';
4146
})
42-
({ pkgs, ... }: {
47+
({ pkgs, ... }: lib.mkIf (!pkgs.stdenv.hostPlatform.isWindows) {
4348
# Tools for CBOR/CDDL tests:
4449
packages.ouroboros-consensus-cardano.components.tests.cardano-test = {
4550
build-tools =
46-
[ pkgs.pkgsBuildBuild.cddlc pkgs.cuddle ];
51+
[ pkgs.cddlc pkgs.cuddle ];
4752
extraSrcFiles = [ "cddl/**/*" ];
4853
};
4954
})

ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/GenCDDLs.hs

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import qualified Test.Cardano.Ledger.Conway.Binary.Cddl as Conway
2525
import qualified Test.Cardano.Ledger.Mary.Binary.Cddl as Mary
2626
import qualified Test.Cardano.Ledger.Shelley.Binary.Cddl as Shelley
2727
import Test.Tasty
28+
import Test.Util.Serialisation.CDDL (isCDDLCDisabled)
2829

2930
newtype CDDLSpec = CDDLSpec {cddlSpec :: BS.ByteString} deriving Show
3031

@@ -34,32 +35,35 @@ newtype CDDLSpec = CDDLSpec {cddlSpec :: BS.ByteString} deriving Show
3435
-- each CDDL so that we know always what is available.
3536
withCDDLs :: TestTree -> TestTree
3637
withCDDLs f =
37-
withResource
38-
( do
39-
probeTools
40-
setupCDDLCEnv
41-
42-
ntnBlock <- cddlc "cddl/node-to-node/blockfetch/block.cddl"
43-
ntnBlock' <- fixupBlockCDDL ntnBlock
44-
BS.writeFile "ntnblock.cddl" . cddlSpec $ ntnBlock'
45-
46-
ntnHeader <- cddlc "cddl/node-to-node/chainsync/header.cddl"
47-
BS.writeFile "ntnheader.cddl" . cddlSpec $ ntnHeader
48-
49-
ntnTx <- cddlc "cddl/node-to-node/txsubmission2/tx.cddl"
50-
ntnTx' <- fixupBlockCDDL ntnTx
51-
BS.writeFile "ntntx.cddl" . cddlSpec $ ntnTx'
52-
53-
ntnTxId <- cddlc "cddl/node-to-node/txsubmission2/txId.cddl"
54-
BS.writeFile "ntntxid.cddl" . cddlSpec $ ntnTxId
55-
)
56-
( \() -> do
57-
D.removeFile "ntnblock.cddl"
58-
D.removeFile "ntnheader.cddl"
59-
D.removeFile "ntntx.cddl"
60-
D.removeFile "ntntxid.cddl"
61-
)
62-
(\_ -> f)
38+
if isCDDLCDisabled
39+
then f
40+
else
41+
withResource
42+
( do
43+
probeTools
44+
setupCDDLCEnv
45+
46+
ntnBlock <- cddlc "cddl/node-to-node/blockfetch/block.cddl"
47+
ntnBlock' <- fixupBlockCDDL ntnBlock
48+
BS.writeFile "ntnblock.cddl" . cddlSpec $ ntnBlock'
49+
50+
ntnHeader <- cddlc "cddl/node-to-node/chainsync/header.cddl"
51+
BS.writeFile "ntnheader.cddl" . cddlSpec $ ntnHeader
52+
53+
ntnTx <- cddlc "cddl/node-to-node/txsubmission2/tx.cddl"
54+
ntnTx' <- fixupBlockCDDL ntnTx
55+
BS.writeFile "ntntx.cddl" . cddlSpec $ ntnTx'
56+
57+
ntnTxId <- cddlc "cddl/node-to-node/txsubmission2/txId.cddl"
58+
BS.writeFile "ntntxid.cddl" . cddlSpec $ ntnTxId
59+
)
60+
( \() -> do
61+
D.removeFile "ntnblock.cddl"
62+
D.removeFile "ntnheader.cddl"
63+
D.removeFile "ntntx.cddl"
64+
D.removeFile "ntntxid.cddl"
65+
)
66+
(\_ -> f)
6367

6468
-- | The Ledger CDDL specs are not _exactly_ correct. Here we do some dirty
6569
-- sed-replace to make them able to validate blocks. See cardano-ledger#5054.

ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/Serialisation/CDDL.hs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
11
{-# LANGUAGE LambdaCase #-}
22

3-
module Test.Util.Serialisation.CDDL (cddlTestCase, cddlTest, CDDLsForNodeToNode (..)) where
3+
module Test.Util.Serialisation.CDDL
4+
( cddlTestCase
5+
, cddlTest
6+
, isCDDLCDisabled
7+
, CDDLsForNodeToNode (..)
8+
) where
49

510
import qualified Data.ByteString as BS
11+
import Data.Maybe (isJust)
612
import qualified Data.Text as T
13+
import qualified System.Environment as E
714
import System.Exit
815
import System.IO
916
import System.IO.Temp
17+
import System.IO.Unsafe (unsafePerformIO)
1018
import System.Process
1119
import Test.Tasty
1220
import Test.Tasty.HUnit
1321

22+
-- | Windows on Hydra cannot cross-compile CDDLC so we decided to skip the tests
23+
-- there.
24+
isCDDLCDisabled :: Bool
25+
isCDDLCDisabled = isJust $ unsafePerformIO (E.lookupEnv "DISABLE_CDDLC")
26+
1427
-- | A Tasty test case running the @cuddle@
1528
cddlTestCase :: IO BS.ByteString -> FilePath -> T.Text -> TestTree
1629
cddlTestCase cborM cddl rule =
1730
testCase "CDDL compliance" $
18-
cddlTest cborM cddl rule >>= \case
19-
Left err -> assertFailure err
20-
Right _ -> pure ()
31+
if isCDDLCDisabled
32+
then assertBool "Skipped" True
33+
else
34+
cddlTest cborM cddl rule >>= \case
35+
Left err -> assertFailure err
36+
Right _ -> pure ()
2137

2238
-- | Test the CDDL conformance of the given bytestring
2339
cddlTest ::

0 commit comments

Comments
 (0)