Skip to content

Commit 4986b03

Browse files
carbolymerpalas
authored andcommitted
Make cardano-wasm-golden test build in nix
1 parent 3c35371 commit 4986b03

File tree

6 files changed

+57
-8
lines changed

6 files changed

+57
-8
lines changed

cabal.project

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ if impl(ghc < 9.8)
2929

3030
constraints: process >= 1.6.26.1
3131

32+
-- this slows down the build plan preparation, but it seems that without it
33+
-- cabal has problems with resolving dependencies
34+
max-backjumps: 50000
35+
3236
program-options
3337
ghc-options: -Werror
3438

cardano-wasm/cardano-wasm.cabal

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ executable cardano-wasm
6262
ghc-experimental,
6363
utf8-string,
6464

65-
test-suite cardano-wasm-test
65+
test-suite cardano-wasm-golden
6666
import: project-config
6767
hs-source-dirs: test
68-
main-is: cardano-wasm-test.hs
68+
main-is: cardano-wasm-golden.hs
6969
type: exitcode-stdio-1.0
7070
build-depends:
71-
hedgehog,
72-
hedgehog-extras,
71+
hedgehog >=1.1,
72+
hedgehog-extras ^>=0.8,
7373
tasty,
7474
tasty-hedgehog,
7575

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module Test.Golden.Cardano.Wasm.TypeScript where
22

3-
import Hedgehog (Property)
4-
import Hedgehog.Extras (defaultExecConfig, exec)
3+
import Hedgehog as H
54
import Hedgehog.Extras qualified as H
65

76
hprop_cardano_wasm_typescript_declarations_match_generated :: Property
87
hprop_cardano_wasm_typescript_declarations_match_generated =
98
H.propertyOnce $ do
10-
result <- exec defaultExecConfig "cardano-wasm" []
9+
result <- H.execFlex "cardano-wasm" "CARDANO_WASM" []
1110
H.diffVsGoldenFile result "example/cardano-api.d.ts"

flake.lock

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
nixpkgs.url = "github:NixOS/nixpkgs/4284c2b73c8bce4b46a6adf23e16d9e2ec8da4bb";
1717
iohkNix.url = "github:input-output-hk/iohk-nix";
1818
flake-utils.url = "github:hamishmack/flake-utils/hkm/nested-hydraJobs";
19+
incl.url = "github:divnix/incl";
1920
# non-flake nix compatibility
2021
flake-compat = {
2122
url = "github:edolstra/flake-compat";
@@ -137,7 +138,7 @@
137138
# package customizations as needed. Where cabal.project is not
138139
# specific enough, or doesn't allow setting these.
139140
modules = [
140-
({pkgs, ...}: {
141+
({...}: {
141142
packages.cardano-api = {
142143
configureFlags = ["--ghc-option=-Werror"];
143144
components = {
@@ -149,6 +150,17 @@
149150
};
150151
};
151152
})
153+
({pkgs, config, ...}: let
154+
generatedExampleFiles = ["cardano-wasm/example/cardano-api.d.ts"];
155+
exportWasmPath = "export CARDANO_WASM=${config.hsPkgs.cardano-wasm.components.exes.cardano-wasm}/bin/cardano-wasm${pkgs.stdenv.hostPlatform.extensions.executable}";
156+
in {
157+
packages.cardano-wasm.components.tests.cardano-wasm-golden.preCheck = let
158+
filteredProjectBase = inputs.incl ./. generatedExampleFiles;
159+
in ''
160+
${exportWasmPath}
161+
cp -r ${filteredProjectBase}/* ..
162+
'';
163+
})
152164
{
153165
packages.crypton-x509-system.postPatch = ''
154166
substituteInPlace crypton-x509-system.cabal --replace 'Crypt32' 'crypt32'

0 commit comments

Comments
 (0)