From b1941b95caece0c305ce4dc8d5efc9cbbfa88c1c Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Tue, 24 Sep 2024 01:29:53 +0200 Subject: [PATCH] Fix issue with paths in Hydra CI --- .gitattributes | 1 + .../Test/Golden/Governance/Action.hs | 4 ++-- .../files/input/example_anchor_data.txt | 2 ++ .../Test/Cardano/CLI/Hash.hs | 16 +++++++++++++--- .../test/cardano-cli-test/Test/Cli/Hash.hs | 14 +++++++------- 5 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/example_anchor_data.txt diff --git a/.gitattributes b/.gitattributes index e6ade18bba..eb84872b79 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ +cardano-cli/test/cardano-cli-golden/files/input/example_anchor_data.txt -text cardano-cli/test/cardano-cli-test/files/input/example_anchor_data.txt -text diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs index 46f0ec51de..1f7b05cc56 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs @@ -11,7 +11,7 @@ import Control.Monad.Catch (MonadCatch) import Control.Monad.Trans.Control (MonadBaseControl) import Test.Cardano.CLI.Hash (exampleAnchorDataHash, exampleAnchorDataIpfsHash, - exampleAnchorDataPath, serveFileWhile) + exampleAnchorDataPathGolden, serveFileWhile) import qualified Test.Cardano.CLI.Util as H import Test.Cardano.CLI.Util (execCardanoCLI, execCardanoCLIWithEnvVars, expectFailure, noteInputFile, noteTempFile, propertyOnce) @@ -216,7 +216,7 @@ base_golden_conway_governance_action_view_create_info_json_outfile hash tempDir let relativeUrl = ["ipfs", exampleAnchorDataIpfsHash] serveFileWhile relativeUrl - exampleAnchorDataPath + exampleAnchorDataPathGolden ( \port -> do void $ execCardanoCLIWithEnvVars diff --git a/cardano-cli/test/cardano-cli-golden/files/input/example_anchor_data.txt b/cardano-cli/test/cardano-cli-golden/files/input/example_anchor_data.txt new file mode 100644 index 0000000000..5d83630efd --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/example_anchor_data.txt @@ -0,0 +1,2 @@ +This is just a random file with content that is used for +testing the hashing of anchor data files. \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Hash.hs b/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Hash.hs index 7a9a48b5c9..c89005caac 100644 --- a/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Hash.hs +++ b/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Hash.hs @@ -1,6 +1,13 @@ {-# LANGUAGE FlexibleContexts #-} -module Test.Cardano.CLI.Hash (exampleAnchorDataHash, serveFileWhile, exampleAnchorDataPath, exampleAnchorDataIpfsHash) where +module Test.Cardano.CLI.Hash + ( exampleAnchorDataHash + , serveFileWhile + , exampleAnchorDataPathTest + , exampleAnchorDataPathGolden + , exampleAnchorDataIpfsHash + ) +where import Cardano.Api (MonadIO) @@ -26,8 +33,11 @@ import Hedgehog.Internal.Source (HasCallStack) exampleAnchorDataHash :: String exampleAnchorDataHash = "de38a4f5b8b9d8372386cc923bad19d1a0662298cf355bbe947e5eedf127fa9c" -exampleAnchorDataPath :: String -exampleAnchorDataPath = "test/cardano-cli-test/files/input/example_anchor_data.txt" +exampleAnchorDataPathGolden :: String +exampleAnchorDataPathGolden = "test/cardano-cli-golden/files/input/example_anchor_data.txt" + +exampleAnchorDataPathTest :: String +exampleAnchorDataPathTest = "test/cardano-cli-test/files/input/example_anchor_data.txt" exampleAnchorDataIpfsHash :: String exampleAnchorDataIpfsHash = "QmbL5EBFJLf8DdPkWAskG3Euin9tHY8naqQ2JDoHnWHHXJ" diff --git a/cardano-cli/test/cardano-cli-test/Test/Cli/Hash.hs b/cardano-cli/test/cardano-cli-test/Test/Cli/Hash.hs index adf368c82b..744e10af2e 100644 --- a/cardano-cli/test/cardano-cli-test/Test/Cli/Hash.hs +++ b/cardano-cli/test/cardano-cli-test/Test/Cli/Hash.hs @@ -10,7 +10,7 @@ import System.FilePath (dropTrailingPathSeparator) import System.FilePath.Posix (splitDirectories) import Test.Cardano.CLI.Hash (exampleAnchorDataHash, exampleAnchorDataIpfsHash, - exampleAnchorDataPath, serveFileWhile) + exampleAnchorDataPathTest, serveFileWhile) import Test.Cardano.CLI.Util import Hedgehog as H @@ -26,7 +26,7 @@ hprop_generate_anchor_data_hash_from_file = [ "hash" , "anchor-data" , "--file-binary" - , exampleAnchorDataPath + , exampleAnchorDataPathTest ] result === exampleAnchorDataHash @@ -40,7 +40,7 @@ hprop_check_anchor_data_hash_from_file = [ "hash" , "anchor-data" , "--file-binary" - , exampleAnchorDataPath + , exampleAnchorDataPathTest , "--expected-hash" , exampleAnchorDataHash ] @@ -55,7 +55,7 @@ hprop_check_anchor_data_hash_from_file_fails = [ "hash" , "anchor-data" , "--file-binary" - , exampleAnchorDataPath + , exampleAnchorDataPathTest , "--expected-hash" , 'c' : drop 1 exampleAnchorDataHash ] @@ -73,7 +73,7 @@ hprop_generate_anchor_data_hash_from_file_uri = [ "hash" , "anchor-data" , "--url" - , "file://" ++ posixCwd ++ "/" ++ exampleAnchorDataPath + , "file://" ++ posixCwd ++ "/" ++ exampleAnchorDataPathTest ] result === exampleAnchorDataHash where @@ -100,7 +100,7 @@ hprop_check_anchor_data_hash_from_http_uri = let relativeUrl = ["example", "url", "file.txt"] serveFileWhile relativeUrl - exampleAnchorDataPath + exampleAnchorDataPathTest ( \port -> do void $ execCardanoCLI @@ -121,7 +121,7 @@ hprop_check_anchor_data_hash_from_ipfs_uri = let relativeUrl = ["ipfs", exampleAnchorDataIpfsHash] serveFileWhile relativeUrl - exampleAnchorDataPath + exampleAnchorDataPathTest ( \port -> do void $ execCardanoCLIWithEnvVars