Skip to content

Commit abb8bd9

Browse files
Russoulclaude
andcommitted
bench: fix integration test data-file paths for Nix/Hydra builds
Bare relative paths broke under Hydra where the working directory is a build sandbox unrelated to the source tree. Declare the example YAML and trace files as cabal data-files and resolve their location at runtime via Paths_cardano_recon_framework.getDataDir, which cabal/Nix wire up to the correct installed path in every environment. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 86820f7 commit abb8bd9

2 files changed

Lines changed: 37 additions & 24 deletions

File tree

bench/cardano-recon-framework/cardano-recon-framework.cabal

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ maintainer: ruslan.feizerakhmanov@iohk.io
1313

1414
build-type: Simple
1515
extra-doc-files: CHANGELOG.md
16+
data-files:
17+
examples/cfgs/context.yaml
18+
examples/cfgs/formulas.yaml
19+
examples/extracts/ok-1.txt
20+
examples/extracts/ok-2.txt
21+
examples/extracts/ok-3.txt
22+
examples/extracts/ok-4.txt
23+
examples/extracts/ok-5.txt
24+
examples/extracts/fail-1.txt
25+
examples/extracts/fail-2.txt
26+
examples/extracts/fail-3.txt
27+
examples/extracts/fail-4.txt
28+
examples/extracts/fail-5.txt
29+
examples/extracts/fail-6.txt
1630
README.md
1731
recon-language-overview.md
1832
docs/*.txt
@@ -188,6 +202,9 @@ test-suite cardano-recon-integration-test
188202
main-is: Cardano/ReCon/Integration.hs
189203
other-modules:
190204
Cardano.ReCon.Integration.Suite
205+
, Paths_cardano_recon_framework
206+
autogen-modules:
207+
Paths_cardano_recon_framework
191208
build-depends:
192209
base
193210
, cardano-recon-framework

bench/cardano-recon-framework/test/Cardano/ReCon/Integration/Suite.hs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,12 @@ import Control.Monad (forM_)
1414
import qualified Data.Map as Map
1515
import Data.Text (Text)
1616
import qualified Data.Text as Text
17+
import Paths_cardano_recon_framework (getDataDir)
1718
import System.Exit (die)
1819
import System.FilePath ((</>))
1920
import Test.Tasty
2021
import Test.Tasty.HUnit
2122

22-
formulasFile :: FilePath
23-
formulasFile = "examples/cfgs/formulas.yaml"
24-
25-
contextFile :: FilePath
26-
contextFile = "examples/cfgs/context.yaml"
27-
28-
tracesDir :: FilePath
29-
tracesDir = "examples/extracts"
30-
3123
eventDuration :: Word
3224
eventDuration = 10 -- μs per event bucket (= --duration 10)
3325

@@ -36,6 +28,10 @@ second = 1_000_000 -- μs (= --timeunit second)
3628

3729
integrationTests :: IO TestTree
3830
integrationTests = do
31+
dataDir <- getDataDir
32+
let formulasFile = dataDir </> "examples" </> "cfgs" </> "formulas.yaml"
33+
let contextFile = dataDir </> "examples" </> "cfgs" </> "context.yaml"
34+
let tracesDir = dataDir </> "examples" </> "extracts"
3935
ctx <- readPropValues contextFile >>= orDie
4036
formulas <- readFormulas formulasFile
4137
(Context { interpDomain = Map.toList ctx, varKinds = Map.empty })
@@ -44,30 +40,30 @@ integrationTests = do
4440
let fs = map (interpTimeunit (\u -> u * second `div` eventDuration)) formulas
4541
pure $ testGroup "Trace integration"
4642
[ testGroup "Positive — every formula must pass"
47-
[ mkPositive fs "ok-1.txt"
48-
, mkPositive fs "ok-2.txt"
49-
, mkPositive fs "ok-3.txt"
50-
, mkPositive fs "ok-4.txt"
51-
, mkPositive fs "ok-5.txt"
43+
[ mkPositive fs tracesDir "ok-1.txt"
44+
, mkPositive fs tracesDir "ok-2.txt"
45+
, mkPositive fs tracesDir "ok-3.txt"
46+
, mkPositive fs tracesDir "ok-4.txt"
47+
, mkPositive fs tracesDir "ok-5.txt"
5248
]
5349
, testGroup "Negative — at least one formula must fail"
54-
[ mkNegative fs "fail-1.txt"
55-
, mkNegative fs "fail-2.txt"
56-
, mkNegative fs "fail-3.txt"
57-
, mkNegative fs "fail-4.txt"
58-
, mkNegative fs "fail-5.txt"
59-
, mkNegative fs "fail-6.txt"
50+
[ mkNegative fs tracesDir "fail-1.txt"
51+
, mkNegative fs tracesDir "fail-2.txt"
52+
, mkNegative fs tracesDir "fail-3.txt"
53+
, mkNegative fs tracesDir "fail-4.txt"
54+
, mkNegative fs tracesDir "fail-5.txt"
55+
, mkNegative fs tracesDir "fail-6.txt"
6056
]
6157
]
6258

63-
mkPositive :: [Formula TemporalEvent Text] -> String -> TestTree
64-
mkPositive fs name = testCase name $ do
59+
mkPositive :: [Formula TemporalEvent Text] -> FilePath -> String -> TestTree
60+
mkPositive fs tracesDir name = testCase name $ do
6561
events <- Feed.read (tracesDir </> name) eventDuration
6662
forM_ fs $ \phi ->
6763
satisfies phi events @?= Satisfied
6864

69-
mkNegative :: [Formula TemporalEvent Text] -> String -> TestTree
70-
mkNegative fs name = testCase name $ do
65+
mkNegative :: [Formula TemporalEvent Text] -> FilePath -> String -> TestTree
66+
mkNegative fs tracesDir name = testCase name $ do
7167
events <- Feed.read (tracesDir </> name) eventDuration
7268
assertBool "expected at least one Unsatisfied" $
7369
any isUnsatisfied (map (`satisfies` events) fs)

0 commit comments

Comments
 (0)