Skip to content

Commit 53aa611

Browse files
committed
Ensure proper handling of data files needed for testing
1 parent 676998d commit 53aa611

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

cuddle.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ test-suite cuddle-test
137137
import: warnings
138138
default-language: GHC2021
139139
other-modules:
140+
Paths_cuddle
140141
Test.Codec.CBOR.Cuddle.CDDL.Examples
141142
Test.Codec.CBOR.Cuddle.CDDL.Gen
142143
Test.Codec.CBOR.Cuddle.CDDL.Parser

test/Test/Codec/CBOR/Cuddle/CDDL/Examples.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ import Codec.CBOR.Cuddle.CDDL.Resolve (
1313
)
1414
import Codec.CBOR.Cuddle.Parser (pCDDL)
1515
import Data.Text.IO qualified as T
16+
import Paths_cuddle (getDataFileName)
1617
import Test.HUnit (assertFailure)
1718
import Test.Hspec
1819
import Text.Megaparsec (parse)
1920
import Text.Megaparsec.Error (errorBundlePretty)
2021

2122
tryValidateFile :: FilePath -> IO (Either NameResolutionFailure (CTreeRoot MonoReferenced))
2223
tryValidateFile filePath = do
23-
contents <- T.readFile filePath
24+
absoluteFilePath <- getDataFileName filePath
25+
contents <- T.readFile absoluteFilePath
2426
cddl <- case parse pCDDL "" contents of
2527
Right x -> pure $ prependPrelude x
2628
Left x -> fail $ "Failed to parse the file:\n" <> errorBundlePretty x

0 commit comments

Comments
 (0)