From 7e97e4ba0e9b580f194c02131cd598037567355d Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 26 Mar 2025 10:52:53 +0000 Subject: [PATCH 01/24] done --- nix/outputs.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nix/outputs.nix b/nix/outputs.nix index 4fa0d80eb39..a5724e0f46f 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -64,6 +64,9 @@ let [ "devShells" ]; # Won't build on Windows }; + project-code-coverage = + project.projectVariants.ghc96-coverage.projectCodeCoverage; + extra-artifacts = { inherit unraveling-recursion-paper; } // { inherit metatheory-site; } // @@ -110,6 +113,7 @@ let (project-variants-hydra-jobs) // (windows-packages) // (packages) // + { inherit project-code-coverage; } // { devShells = non-profiled-shells; } // { required = hydra-required-job; }; "x86_64-darwin" = @@ -141,11 +145,13 @@ let inherit build-latex-doc; inherit build-latex; inherit extra-artifacts; + inherit windows-packages; inherit static-haskell-packages; inherit exposed-haskell-packages; inherit flattened-ci-jobs; inherit nested-ci-jobs; inherit metatheory-agda-library; + inherit project-code-coverage; }; in From 89ce31008c3c528d497ac5b94bcc46511fcf4e10 Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 26 Mar 2025 10:54:18 +0000 Subject: [PATCH 02/24] done --- nix/outputs.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nix/outputs.nix b/nix/outputs.nix index a5724e0f46f..1932b6b5bc0 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -64,8 +64,8 @@ let [ "devShells" ]; # Won't build on Windows }; - project-code-coverage = - project.projectVariants.ghc96-coverage.projectCodeCoverage; + project-coverage-report = + project.projectVariants.ghc96-coverage.projectCoverageReport; extra-artifacts = { inherit unraveling-recursion-paper; } // @@ -113,7 +113,7 @@ let (project-variants-hydra-jobs) // (windows-packages) // (packages) // - { inherit project-code-coverage; } // + { inherit project-coverage-report; } // { devShells = non-profiled-shells; } // { required = hydra-required-job; }; "x86_64-darwin" = @@ -151,7 +151,7 @@ let inherit flattened-ci-jobs; inherit nested-ci-jobs; inherit metatheory-agda-library; - inherit project-code-coverage; + inherit project-coverage-report; }; in From 00eb170ed83d1a725dfe049c60b167531aecff72 Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 26 Mar 2025 11:04:30 +0000 Subject: [PATCH 03/24] wip --- nix/project.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nix/project.nix b/nix/project.nix index c3445c1b359..19b531a7cf0 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -19,7 +19,16 @@ let enableLibraryProfiling = true; }]; ghc96-coverage.modules = [{ - doCoverage = true; + packages.cardano-constitution.doCoverage = true; + packages.plutus-benchmark.doCoverage = true; + packages.plutus-conformance.doCoverage = true; + packages.plutus-core.doCoverage = true; + packages.plutus-executables.doCoverage = true; + packages.plutus-ledger-api.doCoverage = true; + packages.plutus-metatheory.doCoverage = true; + packages.plutus-tx.doCoverage = true; + packages.plutus-tx-plugin.doCoverage = true; + packages.plutus-tx-test-util.doCoverage = true; }]; ghc810.compiler-nix-name = "ghc810"; ghc98.compiler-nix-name = "ghc98"; From 1b2aaa6846eee19fed0c8044f86605a83a997cf3 Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 26 Mar 2025 13:57:12 +0000 Subject: [PATCH 04/24] test --- .../testlib/Evaluation/Builtins/Definition.hs | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs index 8f37c3c7e96..6841538d64f 100644 --- a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs @@ -500,29 +500,31 @@ test_TrackCostsRestricting = test_TrackCostsRetaining :: TestTree test_TrackCostsRetaining = #if MIN_VERSION_base(4,15,0) - test_TrackCostsWith "retaining" 10000 $ \term -> do - let -- An 'ExBudgetMode' that retains all the individual budgets by sticking them into a - -- 'DList'. - retaining = monoidalBudgeting $ const DList.singleton - typecheckAndRunRetainer = typecheckAnd def $ \params term' -> - let (getRes, budgets) = runCekNoEmit params retaining term' - in (getRes >>= readKnownSelf, budgets) - case typecheckAndRunRetainer () term of - Left err -> fail $ displayPlc err - Right (Left err, _) -> fail $ displayPlc err - Right (Right (res :: [Integer]), budgets) -> do - -- @length budgets@ is for retaining @budgets@ for as long as possible just in case. - -- @3@ is just for giving us room to handle erratic GC behavior. It really should be - -- @1@. - let expected = min 5 (length budgets) - actual = length res - err = concat - [ "Too many elements picked up by GC\n" - , "Expected at most: " ++ show expected ++ "\n" - , "But got: " ++ show actual ++ "\n" - , "The result was: " ++ show res - ] - assertBool err $ expected > actual + testCase "TrackCosts: retaining" $ do + assertBool "dummy" $ not . null $ DList.singleton 'x' -- Avoid 'redundant-imports' warning + -- test_TrackCostsWith "retaining" 10000 $ \term -> do + -- let -- An 'ExBudgetMode' that retains all the individual budgets by sticking them into a + -- -- 'DList'. + -- retaining = monoidalBudgeting $ const DList.singleton + -- typecheckAndRunRetainer = typecheckAnd def $ \params term' -> + -- let (getRes, budgets) = runCekNoEmit params retaining term' + -- in (getRes >>= readKnownSelf, budgets) + -- case typecheckAndRunRetainer () term of + -- Left err -> fail $ displayPlc err + -- Right (Left err, _) -> fail $ displayPlc err + -- Right (Right (res :: [Integer]), budgets) -> do + -- -- @length budgets@ is for retaining @budgets@ for as long as possible just in case. + -- -- @3@ is just for giving us room to handle erratic GC behavior. It really should be + -- -- @1@. + -- let expected = min 5 (length budgets) + -- actual = length res + -- err = concat + -- [ "Too many elements picked up by GC\n" + -- , "Expected at most: " ++ show expected ++ "\n" + -- , "But got: " ++ show actual ++ "\n" + -- , "The result was: " ++ show res + -- ] + -- assertBool err $ expected > actual #else -- FIXME: @effectfully -- broken only for darwin :x86_64-darwin.ghc810 From e1f2850423e6ef93d75662a57bafdf4e7f14a83c Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 3 Apr 2025 12:55:48 +0100 Subject: [PATCH 05/24] wip --- nix/project.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nix/project.nix b/nix/project.nix index 19b531a7cf0..eff3436c4ea 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -19,16 +19,16 @@ let enableLibraryProfiling = true; }]; ghc96-coverage.modules = [{ - packages.cardano-constitution.doCoverage = true; - packages.plutus-benchmark.doCoverage = true; - packages.plutus-conformance.doCoverage = true; + # packages.cardano-constitution.doCoverage = true; + # packages.plutus-benchmark.doCoverage = true; + # packages.plutus-conformance.doCoverage = true; packages.plutus-core.doCoverage = true; - packages.plutus-executables.doCoverage = true; - packages.plutus-ledger-api.doCoverage = true; - packages.plutus-metatheory.doCoverage = true; - packages.plutus-tx.doCoverage = true; - packages.plutus-tx-plugin.doCoverage = true; - packages.plutus-tx-test-util.doCoverage = true; + # packages.plutus-executables.doCoverage = true; + # packages.plutus-ledger-api.doCoverage = true; + # packages.plutus-metatheory.doCoverage = true; + # packages.plutus-tx.doCoverage = true; + # packages.plutus-tx-plugin.doCoverage = true; + # packages.plutus-tx-test-util.doCoverage = true; }]; ghc810.compiler-nix-name = "ghc810"; ghc98.compiler-nix-name = "ghc98"; From 80f934364d6f072f3649edf2885fbb27e87e7ff1 Mon Sep 17 00:00:00 2001 From: zeme Date: Fri, 4 Apr 2025 10:56:38 +0100 Subject: [PATCH 06/24] wip --- plutus-ledger-api/test/Spec/Data/Eval.hs | 6 +++--- plutus-ledger-api/test/Spec/Eval.hs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plutus-ledger-api/test/Spec/Data/Eval.hs b/plutus-ledger-api/test/Spec/Data/Eval.hs index 6f9ed5a0118..1f1e4d31a74 100644 --- a/plutus-ledger-api/test/Spec/Data/Eval.hs +++ b/plutus-ledger-api/test/Spec/Data/Eval.hs @@ -118,8 +118,8 @@ failIfThunk mbThunkInfo = assertFailure $ "Unexpected thunk: " <> show thunk -- | Ensure that no 'EvaluationContext' has thunks in it for all language versions. -evaluationContextNoThunks :: TestTree -evaluationContextNoThunks = +_evaluationContextNoThunks :: TestTree +_evaluationContextNoThunks = testGroup "NoThunks in EvaluationContext" $ enumerate <&> \ll -> testCase (show ll) $ do !evalCtx <- mkEvaluationContextV ll @@ -130,6 +130,6 @@ tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete - , evaluationContextNoThunks +-- , evaluationContextNoThunks ] diff --git a/plutus-ledger-api/test/Spec/Eval.hs b/plutus-ledger-api/test/Spec/Eval.hs index 9fad9b0546c..ba4963fea92 100644 --- a/plutus-ledger-api/test/Spec/Eval.hs +++ b/plutus-ledger-api/test/Spec/Eval.hs @@ -118,8 +118,8 @@ failIfThunk mbThunkInfo = assertFailure $ "Unexpected thunk: " <> show thunk -- | Ensure that no 'EvaluationContext' has thunks in it for all language versions. -evaluationContextNoThunks :: TestTree -evaluationContextNoThunks = +_evaluationContextNoThunks :: TestTree +_evaluationContextNoThunks = testGroup "NoThunks in EvaluationContext" $ enumerate <&> \ll -> testCase (show ll) $ do !evalCtx <- mkEvaluationContextV ll @@ -130,6 +130,6 @@ tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete - , evaluationContextNoThunks +-- , evaluationContextNoThunks ] From 18de52e6cae8cdc2fe694af71a8f2994594c6b6e Mon Sep 17 00:00:00 2001 From: zeme Date: Fri, 4 Apr 2025 16:45:53 +0100 Subject: [PATCH 07/24] wipg --- nix/project.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nix/project.nix b/nix/project.nix index eff3436c4ea..4397de03df2 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -19,16 +19,16 @@ let enableLibraryProfiling = true; }]; ghc96-coverage.modules = [{ - # packages.cardano-constitution.doCoverage = true; - # packages.plutus-benchmark.doCoverage = true; - # packages.plutus-conformance.doCoverage = true; + # packages.cardano-constitution.doCoverage = true; # Broken + # packages.plutus-benchmark.doCoverage = true; # Broken + packages.plutus-conformance.doCoverage = true; packages.plutus-core.doCoverage = true; - # packages.plutus-executables.doCoverage = true; - # packages.plutus-ledger-api.doCoverage = true; - # packages.plutus-metatheory.doCoverage = true; - # packages.plutus-tx.doCoverage = true; - # packages.plutus-tx-plugin.doCoverage = true; - # packages.plutus-tx-test-util.doCoverage = true; + packages.plutus-executables.doCoverage = true; + # packages.plutus-ledger-api.doCoverage = true; # Broken + # packages.plutus-metatheory.doCoverage = true; # Broken + # packages.plutus-tx.doCoverage = true; # Broken + # packages.plutus-tx-plugin.doCoverage = true; # Broken + packages.plutus-tx-test-util.doCoverage = true; }]; ghc810.compiler-nix-name = "ghc810"; ghc98.compiler-nix-name = "ghc98"; From ddefd9071b1c6e89d39f3b5cec45722605c0aaef Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 8 Apr 2025 10:31:30 +0200 Subject: [PATCH 08/24] done --- nix/project.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nix/project.nix b/nix/project.nix index 4397de03df2..6c3a3bb2b4b 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -19,15 +19,13 @@ let enableLibraryProfiling = true; }]; ghc96-coverage.modules = [{ - # packages.cardano-constitution.doCoverage = true; # Broken - # packages.plutus-benchmark.doCoverage = true; # Broken + # NOTE: Enabling coverage for some packages breaks tests due to HPC + # (Haskell Program Coverage) instrumentation. The packages listed + # below represent the largest subset that can be enabled without + # breaking tests. packages.plutus-conformance.doCoverage = true; packages.plutus-core.doCoverage = true; packages.plutus-executables.doCoverage = true; - # packages.plutus-ledger-api.doCoverage = true; # Broken - # packages.plutus-metatheory.doCoverage = true; # Broken - # packages.plutus-tx.doCoverage = true; # Broken - # packages.plutus-tx-plugin.doCoverage = true; # Broken packages.plutus-tx-test-util.doCoverage = true; }]; ghc810.compiler-nix-name = "ghc810"; From 75884a5cd34cd8a0aaad5c2abdf97c98b04c39fa Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 8 Apr 2025 10:42:30 +0200 Subject: [PATCH 09/24] wip --- .github/workflows/project-coverage-report.yml | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/project-coverage-report.yml diff --git a/.github/workflows/project-coverage-report.yml b/.github/workflows/project-coverage-report.yml new file mode 100644 index 00000000000..c80e92156ed --- /dev/null +++ b/.github/workflows/project-coverage-report.yml @@ -0,0 +1,36 @@ +# On push to master, this workflow builds and publishes the project's coverage +# report to: https://plutus.cardano.intersectmbo.org/dev/coverage + +name: "📊 Code Coverage Report" + +on: + push: + branches: + - master + workflow_dispatch: + pull_request: + branches: + - test-coverage # TODO remove me before merging + +jobs: + deploy: + name: Deploy + runs-on: [self-hosted, plutus-ci] + permissions: + contents: write + environment: + name: github-pages + steps: + - name: Checkout + uses: actions/checkout@main + + - name: Build Report + run: | + nix build --no-warn-dirty --accept-flake-config .#project-coverage-report + + - name: Deploy Report + uses: JamesIves/github-pages-deploy-action@v4.7.3 + with: + folder: result/share/hpc/vanilla/html + target-folder: dev/coverage + single-commit: true \ No newline at end of file From 84524f81c0efec7819d90e788c69802c817c2133 Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 8 Apr 2025 11:11:55 +0200 Subject: [PATCH 10/24] wip --- .../{project-coverage-report.yml => code-coverage-report.yml} | 0 .github/workflows/slack-message-broker.yml | 1 + 2 files changed, 1 insertion(+) rename .github/workflows/{project-coverage-report.yml => code-coverage-report.yml} (100%) diff --git a/.github/workflows/project-coverage-report.yml b/.github/workflows/code-coverage-report.yml similarity index 100% rename from .github/workflows/project-coverage-report.yml rename to .github/workflows/code-coverage-report.yml diff --git a/.github/workflows/slack-message-broker.yml b/.github/workflows/slack-message-broker.yml index 602d5fd3cf5..c78b4a4bab4 100644 --- a/.github/workflows/slack-message-broker.yml +++ b/.github/workflows/slack-message-broker.yml @@ -21,6 +21,7 @@ on: - "🌘 Nightly Testsuite" - "📝 Papers & Specs" - "🏛️ Plinth Template" + - "📊 Code Coverage Report" jobs: Send: From 73e208d8bc9ee33bd380396b0f82b038facc148b Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 8 Apr 2025 12:53:55 +0200 Subject: [PATCH 11/24] Add USING_HPC flag --- nix/project.nix | 2 + .../testlib/Evaluation/Builtins/Definition.hs | 51 +++++++++---------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/nix/project.nix b/nix/project.nix index 6c3a3bb2b4b..cdc1ecef1af 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -19,12 +19,14 @@ let enableLibraryProfiling = true; }]; ghc96-coverage.modules = [{ + # NOTE: Enabling coverage for some packages breaks tests due to HPC # (Haskell Program Coverage) instrumentation. The packages listed # below represent the largest subset that can be enabled without # breaking tests. packages.plutus-conformance.doCoverage = true; packages.plutus-core.doCoverage = true; + packages.plutus-core.configureFlags = [ "--ghc-option=-D__USING_HPC__" ]; packages.plutus-executables.doCoverage = true; packages.plutus-tx-test-util.doCoverage = true; }]; diff --git a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs index 6841538d64f..6b85959342e 100644 --- a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs @@ -499,32 +499,31 @@ test_TrackCostsRestricting = test_TrackCostsRetaining :: TestTree test_TrackCostsRetaining = -#if MIN_VERSION_base(4,15,0) - testCase "TrackCosts: retaining" $ do - assertBool "dummy" $ not . null $ DList.singleton 'x' -- Avoid 'redundant-imports' warning - -- test_TrackCostsWith "retaining" 10000 $ \term -> do - -- let -- An 'ExBudgetMode' that retains all the individual budgets by sticking them into a - -- -- 'DList'. - -- retaining = monoidalBudgeting $ const DList.singleton - -- typecheckAndRunRetainer = typecheckAnd def $ \params term' -> - -- let (getRes, budgets) = runCekNoEmit params retaining term' - -- in (getRes >>= readKnownSelf, budgets) - -- case typecheckAndRunRetainer () term of - -- Left err -> fail $ displayPlc err - -- Right (Left err, _) -> fail $ displayPlc err - -- Right (Right (res :: [Integer]), budgets) -> do - -- -- @length budgets@ is for retaining @budgets@ for as long as possible just in case. - -- -- @3@ is just for giving us room to handle erratic GC behavior. It really should be - -- -- @1@. - -- let expected = min 5 (length budgets) - -- actual = length res - -- err = concat - -- [ "Too many elements picked up by GC\n" - -- , "Expected at most: " ++ show expected ++ "\n" - -- , "But got: " ++ show actual ++ "\n" - -- , "The result was: " ++ show res - -- ] - -- assertBool err $ expected > actual +#if MIN_VERSION_base(4,15,0) && !defined(__USING_HPC__) + -- HPC instrumentation breaks this test, hence the __USING_HPC__ check + test_TrackCostsWith "retaining" 10000 $ \term -> do + let -- An 'ExBudgetMode' that retains all the individual budgets by sticking them into a + -- 'DList'. + retaining = monoidalBudgeting $ const DList.singleton + typecheckAndRunRetainer = typecheckAnd def $ \params term' -> + let (getRes, budgets) = runCekNoEmit params retaining term' + in (getRes >>= readKnownSelf, budgets) + case typecheckAndRunRetainer () term of + Left err -> fail $ displayPlc err + Right (Left err, _) -> fail $ displayPlc err + Right (Right (res :: [Integer]), budgets) -> do + -- @length budgets@ is for retaining @budgets@ for as long as possible just in case. + -- @3@ is just for giving us room to handle erratic GC behavior. It really should be + -- @1@. + let expected = min 5 (length budgets) + actual = length res + err = concat + [ "Too many elements picked up by GC\n" + , "Expected at most: " ++ show expected ++ "\n" + , "But got: " ++ show actual ++ "\n" + , "The result was: " ++ show res + ] + assertBool err $ expected > actual #else -- FIXME: @effectfully -- broken only for darwin :x86_64-darwin.ghc810 From 7b17f1d3ff18d5b28296b002996d8385ad687041 Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 8 Apr 2025 13:40:48 +0200 Subject: [PATCH 12/24] wi --- .../testlib/Evaluation/Builtins/Definition.hs | 6 ++++-- plutus-ledger-api/test/Spec/Data/Eval.hs | 11 ++++++++--- plutus-ledger-api/test/Spec/Eval.hs | 11 ++++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs index 6b85959342e..6843d72e3f5 100644 --- a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs @@ -499,8 +499,10 @@ test_TrackCostsRestricting = test_TrackCostsRetaining :: TestTree test_TrackCostsRetaining = -#if MIN_VERSION_base(4,15,0) && !defined(__USING_HPC__) - -- HPC instrumentation breaks this test, hence the __USING_HPC__ check +#if defined(__USING_HPC__) + testCase "TrackCosts: retaining" $ do + assertBool "dummy" True +#elif MIN_VERSION_base(4,15,0) test_TrackCostsWith "retaining" 10000 $ \term -> do let -- An 'ExBudgetMode' that retains all the individual budgets by sticking them into a -- 'DList'. diff --git a/plutus-ledger-api/test/Spec/Data/Eval.hs b/plutus-ledger-api/test/Spec/Data/Eval.hs index 1f1e4d31a74..e2f849f7ff8 100644 --- a/plutus-ledger-api/test/Spec/Data/Eval.hs +++ b/plutus-ledger-api/test/Spec/Data/Eval.hs @@ -118,18 +118,23 @@ failIfThunk mbThunkInfo = assertFailure $ "Unexpected thunk: " <> show thunk -- | Ensure that no 'EvaluationContext' has thunks in it for all language versions. -_evaluationContextNoThunks :: TestTree -_evaluationContextNoThunks = +evaluationContextNoThunks :: TestTree +evaluationContextNoThunks = testGroup "NoThunks in EvaluationContext" $ +#if !defined(__USING_HPC__) enumerate <&> \ll -> testCase (show ll) $ do !evalCtx <- mkEvaluationContextV ll failIfThunk =<< noThunks [] evalCtx +#else + [] +#endif + tests :: TestTree tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete --- , evaluationContextNoThunks + , evaluationContextNoThunks ] diff --git a/plutus-ledger-api/test/Spec/Eval.hs b/plutus-ledger-api/test/Spec/Eval.hs index ba4963fea92..2737c71b668 100644 --- a/plutus-ledger-api/test/Spec/Eval.hs +++ b/plutus-ledger-api/test/Spec/Eval.hs @@ -118,18 +118,23 @@ failIfThunk mbThunkInfo = assertFailure $ "Unexpected thunk: " <> show thunk -- | Ensure that no 'EvaluationContext' has thunks in it for all language versions. -_evaluationContextNoThunks :: TestTree -_evaluationContextNoThunks = +evaluationContextNoThunks :: TestTree +evaluationContextNoThunks = testGroup "NoThunks in EvaluationContext" $ +#if !defined(__USING_HPC__) enumerate <&> \ll -> testCase (show ll) $ do !evalCtx <- mkEvaluationContextV ll failIfThunk =<< noThunks [] evalCtx +#else + [] +#endif + tests :: TestTree tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete --- , evaluationContextNoThunks + , evaluationContextNoThunks ] From 7ddac89633cfbb7fd4457f9dfd1d2c6b89d41f01 Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 8 Apr 2025 13:55:14 +0200 Subject: [PATCH 13/24] wip --- .../testlib/Evaluation/Builtins/Definition.hs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs index 6843d72e3f5..21e29960acb 100644 --- a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs @@ -499,10 +499,7 @@ test_TrackCostsRestricting = test_TrackCostsRetaining :: TestTree test_TrackCostsRetaining = -#if defined(__USING_HPC__) - testCase "TrackCosts: retaining" $ do - assertBool "dummy" True -#elif MIN_VERSION_base(4,15,0) +#if MIN_VERSION_base(4,15,0) && !defined(__USING_HPC__) test_TrackCostsWith "retaining" 10000 $ \term -> do let -- An 'ExBudgetMode' that retains all the individual budgets by sticking them into a -- 'DList'. From e008443dc3dd904aa39baef1c6201b67cfcb6127 Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 8 Apr 2025 15:24:34 +0200 Subject: [PATCH 14/24] wip --- plutus-ledger-api/test/Spec/Data/Eval.hs | 1 + plutus-ledger-api/test/Spec/Eval.hs | 1 + 2 files changed, 2 insertions(+) diff --git a/plutus-ledger-api/test/Spec/Data/Eval.hs b/plutus-ledger-api/test/Spec/Data/Eval.hs index e2f849f7ff8..6298762ddd9 100644 --- a/plutus-ledger-api/test/Spec/Data/Eval.hs +++ b/plutus-ledger-api/test/Spec/Data/Eval.hs @@ -1,6 +1,7 @@ -- editorconfig-checker-disable-file -- TODO: merge this module to Versions.hs ? {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} module Spec.Data.Eval (tests) where diff --git a/plutus-ledger-api/test/Spec/Eval.hs b/plutus-ledger-api/test/Spec/Eval.hs index 2737c71b668..c7fc8fdb36f 100644 --- a/plutus-ledger-api/test/Spec/Eval.hs +++ b/plutus-ledger-api/test/Spec/Eval.hs @@ -1,6 +1,7 @@ -- editorconfig-checker-disable-file -- TODO: merge this module to Versions.hs ? {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} module Spec.Eval (tests) where From 0d5e1f39ddb6cb1e70728338756454c9603c5b9d Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 8 Apr 2025 16:02:42 +0200 Subject: [PATCH 15/24] wip --- nix/project.nix | 4 +++- plutus-ledger-api/test/Spec/Data/Eval.hs | 2 +- plutus-ledger-api/test/Spec/Eval.hs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nix/project.nix b/nix/project.nix index cdc1ecef1af..42b69ca75df 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -26,9 +26,11 @@ let # breaking tests. packages.plutus-conformance.doCoverage = true; packages.plutus-core.doCoverage = true; - packages.plutus-core.configureFlags = [ "--ghc-option=-D__USING_HPC__" ]; packages.plutus-executables.doCoverage = true; packages.plutus-tx-test-util.doCoverage = true; + + packages.plutus-core.configureFlags = [ "--ghc-option=-D__USING_HPC__" ]; + packages.plutus-ledger-api.configureFlags = [ "--ghc-option=-D__USING_HPC__" ]; }]; ghc810.compiler-nix-name = "ghc810"; ghc98.compiler-nix-name = "ghc98"; diff --git a/plutus-ledger-api/test/Spec/Data/Eval.hs b/plutus-ledger-api/test/Spec/Data/Eval.hs index 6298762ddd9..42edf65ad5a 100644 --- a/plutus-ledger-api/test/Spec/Data/Eval.hs +++ b/plutus-ledger-api/test/Spec/Data/Eval.hs @@ -127,7 +127,7 @@ evaluationContextNoThunks = !evalCtx <- mkEvaluationContextV ll failIfThunk =<< noThunks [] evalCtx #else - [] + [failIfThunk Nothing] -- To prevent -Wunused-top-binds #endif diff --git a/plutus-ledger-api/test/Spec/Eval.hs b/plutus-ledger-api/test/Spec/Eval.hs index c7fc8fdb36f..35e4bfeb686 100644 --- a/plutus-ledger-api/test/Spec/Eval.hs +++ b/plutus-ledger-api/test/Spec/Eval.hs @@ -127,7 +127,7 @@ evaluationContextNoThunks = !evalCtx <- mkEvaluationContextV ll failIfThunk =<< noThunks [] evalCtx #else - [] + [failIfThunk Nothing] -- To prevent -Wunused-top-binds #endif From 889fe12b9fcfb04c163fdb09d305038b93261a7a Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 8 Apr 2025 16:59:35 +0200 Subject: [PATCH 16/24] wip --- .../testlib/Evaluation/Builtins/Definition.hs | 5 +++++ plutus-ledger-api/test/Spec/Data/Eval.hs | 9 +++++---- plutus-ledger-api/test/Spec/Eval.hs | 9 +++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs index 21e29960acb..9cad641b17f 100644 --- a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs @@ -72,6 +72,7 @@ import Hedgehog.Gen qualified as Gen import Hedgehog.Range qualified as Range import Prettyprinter (vsep) import Test.Tasty (TestTree, testGroup) +import Test.Tasty.ExpectedFailure (ignoreTest) import Test.Tasty.Hedgehog (testPropertyNamed) import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase, (@=?), (@?=)) import Test.Tasty.QuickCheck qualified as QC @@ -1248,7 +1249,11 @@ test_definition = , test_SwapEls , test_IdBuiltinData , test_TrackCostsRestricting +#ifdef __USING_HPC__ + , ignoreTest test_TrackCostsRetaining +#else , test_TrackCostsRetaining +#endif , test_SerialiseDataImpossible , test_fixId , runTestNestedHere diff --git a/plutus-ledger-api/test/Spec/Data/Eval.hs b/plutus-ledger-api/test/Spec/Data/Eval.hs index 42edf65ad5a..f2c9d67e0f0 100644 --- a/plutus-ledger-api/test/Spec/Data/Eval.hs +++ b/plutus-ledger-api/test/Spec/Data/Eval.hs @@ -33,6 +33,7 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty +import Test.Tasty.ExpectedFailure (ignoreTest) import Test.Tasty.HUnit {- Note [Direct UPLC code] @@ -122,13 +123,9 @@ failIfThunk mbThunkInfo = evaluationContextNoThunks :: TestTree evaluationContextNoThunks = testGroup "NoThunks in EvaluationContext" $ -#if !defined(__USING_HPC__) enumerate <&> \ll -> testCase (show ll) $ do !evalCtx <- mkEvaluationContextV ll failIfThunk =<< noThunks [] evalCtx -#else - [failIfThunk Nothing] -- To prevent -Wunused-top-binds -#endif tests :: TestTree @@ -136,6 +133,10 @@ tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete +#ifdef __USING_HPC__ + , ignoreTest evaluationContextNoThunks +#else , evaluationContextNoThunks +#endif ] diff --git a/plutus-ledger-api/test/Spec/Eval.hs b/plutus-ledger-api/test/Spec/Eval.hs index 35e4bfeb686..fbb158e57dc 100644 --- a/plutus-ledger-api/test/Spec/Eval.hs +++ b/plutus-ledger-api/test/Spec/Eval.hs @@ -33,6 +33,7 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty +import Test.Tasty.ExpectedFailure (ignoreTest) import Test.Tasty.HUnit {- Note [Direct UPLC code] @@ -122,13 +123,9 @@ failIfThunk mbThunkInfo = evaluationContextNoThunks :: TestTree evaluationContextNoThunks = testGroup "NoThunks in EvaluationContext" $ -#if !defined(__USING_HPC__) enumerate <&> \ll -> testCase (show ll) $ do !evalCtx <- mkEvaluationContextV ll failIfThunk =<< noThunks [] evalCtx -#else - [failIfThunk Nothing] -- To prevent -Wunused-top-binds -#endif tests :: TestTree @@ -136,6 +133,10 @@ tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete +#ifdef __USING_HPC__ + , ignoreTest evaluationContextNoThunks +#else , evaluationContextNoThunks +#endif ] From f8d3a62892d7d23c44c9f2e2cad06fcf2e49848c Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 8 Apr 2025 17:13:02 +0200 Subject: [PATCH 17/24] wip --- plutus-core/plutus-core.cabal | 1 + plutus-ledger-api/plutus-ledger-api.cabal | 1 + 2 files changed, 2 insertions(+) diff --git a/plutus-core/plutus-core.cabal b/plutus-core/plutus-core.cabal index 83d8f1b5251..45835b2cd85 100644 --- a/plutus-core/plutus-core.cabal +++ b/plutus-core/plutus-core.cabal @@ -481,6 +481,7 @@ library untyped-plutus-core-testlib , serialise , split , tasty + , tasty-expected-failure , tasty-golden , tasty-hedgehog , tasty-hunit diff --git a/plutus-ledger-api/plutus-ledger-api.cabal b/plutus-ledger-api/plutus-ledger-api.cabal index 544fe3c5e78..9297481b4e1 100644 --- a/plutus-ledger-api/plutus-ledger-api.cabal +++ b/plutus-ledger-api/plutus-ledger-api.cabal @@ -200,6 +200,7 @@ test-suite plutus-ledger-api-test , prettyprinter , serialise , tasty + , tasty-expected-failure , tasty-hedgehog , tasty-hunit , tasty-quickcheck From 506a7c3cf9e7d1b5ad14a35637a9b07cd98895a4 Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 9 Apr 2025 10:55:09 +0200 Subject: [PATCH 18/24] wip --- .../testlib/Evaluation/Builtins/Definition.hs | 4 ++-- plutus-ledger-api/test/Spec/Data/Eval.hs | 4 ++-- plutus-ledger-api/test/Spec/Eval.hs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs index 9cad641b17f..1ea2a34cf7c 100644 --- a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs @@ -72,7 +72,7 @@ import Hedgehog.Gen qualified as Gen import Hedgehog.Range qualified as Range import Prettyprinter (vsep) import Test.Tasty (TestTree, testGroup) -import Test.Tasty.ExpectedFailure (ignoreTest) +import Test.Tasty.ExpectedFailure qualified as Tasty import Test.Tasty.Hedgehog (testPropertyNamed) import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase, (@=?), (@?=)) import Test.Tasty.QuickCheck qualified as QC @@ -1250,7 +1250,7 @@ test_definition = , test_IdBuiltinData , test_TrackCostsRestricting #ifdef __USING_HPC__ - , ignoreTest test_TrackCostsRetaining + , Tasty.ignoreTest test_TrackCostsRetaining #else , test_TrackCostsRetaining #endif diff --git a/plutus-ledger-api/test/Spec/Data/Eval.hs b/plutus-ledger-api/test/Spec/Data/Eval.hs index f2c9d67e0f0..e0a6224d85e 100644 --- a/plutus-ledger-api/test/Spec/Data/Eval.hs +++ b/plutus-ledger-api/test/Spec/Data/Eval.hs @@ -33,7 +33,7 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty -import Test.Tasty.ExpectedFailure (ignoreTest) +import Test.Tasty.ExpectedFailure qualified as Tasty import Test.Tasty.HUnit {- Note [Direct UPLC code] @@ -134,7 +134,7 @@ tests = testGroup "eval" -- , testUnlifting , evaluationContextCacheIsComplete #ifdef __USING_HPC__ - , ignoreTest evaluationContextNoThunks + , Tasty.ignoreTest evaluationContextNoThunks #else , evaluationContextNoThunks #endif diff --git a/plutus-ledger-api/test/Spec/Eval.hs b/plutus-ledger-api/test/Spec/Eval.hs index fbb158e57dc..ee613147b34 100644 --- a/plutus-ledger-api/test/Spec/Eval.hs +++ b/plutus-ledger-api/test/Spec/Eval.hs @@ -33,7 +33,7 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty -import Test.Tasty.ExpectedFailure (ignoreTest) +import Test.Tasty.ExpectedFailure qualified as Tasty import Test.Tasty.HUnit {- Note [Direct UPLC code] @@ -134,7 +134,7 @@ tests = testGroup "eval" -- , testUnlifting , evaluationContextCacheIsComplete #ifdef __USING_HPC__ - , ignoreTest evaluationContextNoThunks + , Tasty.ignoreTest evaluationContextNoThunks #else , evaluationContextNoThunks #endif From 47c32e108222c193e2a9e565d5fa9d3bdcda67aa Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 9 Apr 2025 12:33:07 +0200 Subject: [PATCH 19/24] wip --- nix/project.nix | 1 + .../testlib/Evaluation/Builtins/Definition.hs | 6 ++++-- plutus-ledger-api/test/Spec/Data/Eval.hs | 6 ++++-- plutus-ledger-api/test/Spec/Eval.hs | 6 ++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/nix/project.nix b/nix/project.nix index 42b69ca75df..d218e424423 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -28,6 +28,7 @@ let packages.plutus-core.doCoverage = true; packages.plutus-executables.doCoverage = true; packages.plutus-tx-test-util.doCoverage = true; + # packages.plutus-ledger-api.doCoverage = true; packages.plutus-core.configureFlags = [ "--ghc-option=-D__USING_HPC__" ]; packages.plutus-ledger-api.configureFlags = [ "--ghc-option=-D__USING_HPC__" ]; diff --git a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs index 1ea2a34cf7c..69b6401787a 100644 --- a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs @@ -72,7 +72,9 @@ import Hedgehog.Gen qualified as Gen import Hedgehog.Range qualified as Range import Prettyprinter (vsep) import Test.Tasty (TestTree, testGroup) -import Test.Tasty.ExpectedFailure qualified as Tasty +#ifdef __USING_HPC__ +import Test.Tasty.ExpectedFailure (ignoreTest) +#endif import Test.Tasty.Hedgehog (testPropertyNamed) import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase, (@=?), (@?=)) import Test.Tasty.QuickCheck qualified as QC @@ -1250,7 +1252,7 @@ test_definition = , test_IdBuiltinData , test_TrackCostsRestricting #ifdef __USING_HPC__ - , Tasty.ignoreTest test_TrackCostsRetaining + , ignoreTest test_TrackCostsRetaining #else , test_TrackCostsRetaining #endif diff --git a/plutus-ledger-api/test/Spec/Data/Eval.hs b/plutus-ledger-api/test/Spec/Data/Eval.hs index e0a6224d85e..ea3b5ac0761 100644 --- a/plutus-ledger-api/test/Spec/Data/Eval.hs +++ b/plutus-ledger-api/test/Spec/Data/Eval.hs @@ -33,7 +33,9 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty -import Test.Tasty.ExpectedFailure qualified as Tasty +#ifdef __USING_HPC__ +import Test.Tasty.ExpectedFailure (ignoreTest) +#endif import Test.Tasty.HUnit {- Note [Direct UPLC code] @@ -134,7 +136,7 @@ tests = testGroup "eval" -- , testUnlifting , evaluationContextCacheIsComplete #ifdef __USING_HPC__ - , Tasty.ignoreTest evaluationContextNoThunks + , ignoreTest evaluationContextNoThunks #else , evaluationContextNoThunks #endif diff --git a/plutus-ledger-api/test/Spec/Eval.hs b/plutus-ledger-api/test/Spec/Eval.hs index ee613147b34..87660f55c81 100644 --- a/plutus-ledger-api/test/Spec/Eval.hs +++ b/plutus-ledger-api/test/Spec/Eval.hs @@ -33,7 +33,9 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty -import Test.Tasty.ExpectedFailure qualified as Tasty +#ifdef __USING_HPC__ +import Test.Tasty.ExpectedFailure (ignoreTest) +#endif import Test.Tasty.HUnit {- Note [Direct UPLC code] @@ -134,7 +136,7 @@ tests = testGroup "eval" -- , testUnlifting , evaluationContextCacheIsComplete #ifdef __USING_HPC__ - , Tasty.ignoreTest evaluationContextNoThunks + , ignoreTest evaluationContextNoThunks #else , evaluationContextNoThunks #endif From 7295e989b7117597fc6b7d668414fa5d17c1c25a Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 9 Apr 2025 14:46:58 +0200 Subject: [PATCH 20/24] wip --- .../Constitution/Validator/GoldenTests.hs | 9 +++++---- nix/project.nix | 6 +++--- plutus-core/plutus-core.cabal | 2 +- plutus-core/testlib/Test/Tasty/Extras.hs | 16 ++++++++++++++++ .../testlib/Evaluation/Builtins/Definition.hs | 12 +++--------- plutus-ledger-api/test/Spec/Data/Eval.hs | 5 +---- plutus-ledger-api/test/Spec/Eval.hs | 10 ++-------- 7 files changed, 31 insertions(+), 29 deletions(-) diff --git a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs index 8e7572ec59b..a7aa1cfa28b 100644 --- a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs +++ b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs @@ -22,6 +22,7 @@ import Data.Maybe import Data.String import System.FilePath import Test.Tasty +import Test.Tasty.Extras (ignoreTestIfHpcEnabled) import Test.Tasty.Golden import Helpers.Guardrail @@ -67,11 +68,11 @@ test_readable_uplc = testGroup "ReadableUplc" $ M.elems $ tests :: TestTreeWithTestState tests = testGroup' "Golden" $ fmap const - [ test_cbor - , test_budget_large - , test_budget_small + [ ignoreTestIfHpcEnabled test_cbor + , ignoreTestIfHpcEnabled test_budget_large + , ignoreTestIfHpcEnabled test_budget_small , test_readable_pir - , test_readable_uplc + , ignoreTestIfHpcEnabled test_readable_uplc ] -- HELPERS diff --git a/nix/project.nix b/nix/project.nix index d218e424423..717d62404db 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -28,10 +28,10 @@ let packages.plutus-core.doCoverage = true; packages.plutus-executables.doCoverage = true; packages.plutus-tx-test-util.doCoverage = true; - # packages.plutus-ledger-api.doCoverage = true; + packages.plutus-ledger-api.doCoverage = true; - packages.plutus-core.configureFlags = [ "--ghc-option=-D__USING_HPC__" ]; - packages.plutus-ledger-api.configureFlags = [ "--ghc-option=-D__USING_HPC__" ]; + packages.plutus-core.configureFlags = [ "--ghc-option=-D__HPC_ENABLED__" ]; + packages.plutus-ledger-api.configureFlags = [ "--ghc-option=-D__HPC_ENABLED__" ]; }]; ghc810.compiler-nix-name = "ghc810"; ghc98.compiler-nix-name = "ghc98"; diff --git a/plutus-core/plutus-core.cabal b/plutus-core/plutus-core.cabal index 45835b2cd85..658ff2c9f78 100644 --- a/plutus-core/plutus-core.cabal +++ b/plutus-core/plutus-core.cabal @@ -481,7 +481,6 @@ library untyped-plutus-core-testlib , serialise , split , tasty - , tasty-expected-failure , tasty-golden , tasty-hedgehog , tasty-hunit @@ -836,6 +835,7 @@ library plutus-core-testlib , Stream , tagged , tasty + , tasty-expected-failure , tasty-golden , tasty-hedgehog , tasty-hunit diff --git a/plutus-core/testlib/Test/Tasty/Extras.hs b/plutus-core/testlib/Test/Tasty/Extras.hs index 60f8d6a2686..2caa2190ebe 100644 --- a/plutus-core/testlib/Test/Tasty/Extras.hs +++ b/plutus-core/testlib/Test/Tasty/Extras.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BlockArguments #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} @@ -33,6 +34,7 @@ module Test.Tasty.Extras , assertEqualPretty , (%=?) , (%?=) + , ignoreTestIfHpcEnabled ) where import PlutusPrelude hiding (toList) @@ -51,6 +53,7 @@ import GHC.Stack (HasCallStack) import System.FilePath (joinPath, ()) import System.Info (compilerVersion) import Test.Tasty (TestName, TestTree, testGroup) +import Test.Tasty.ExpectedFailure (ignoreTest) import Test.Tasty.Golden (createDirectoriesAndWriteFile, goldenVsStringDiff) import Test.Tasty.Golden.Advanced (goldenTest) import Test.Tasty.HUnit (Assertion, assertFailure) @@ -313,3 +316,16 @@ expected %=? actual = assertEqualPretty "" expected actual -- ^ The expected value -> Assertion actual %?= expected = assertEqualPretty "" expected actual + +{-| +Some tests inspect GHC code, but GHC code gets instrumented when using hpc. +This flag disables those tests when the custom __HPC_ENABLED__ flag is defined. +-} +ignoreTestIfHpcEnabled :: TestTree -> TestTree +ignoreTestIfHpcEnabled t = +#ifdef __HPC_ENABLED__ + ignoreTest t +#else + let _preventsUnusedBindsWarnings = ignoreTest t + in t +#endif diff --git a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs index 69b6401787a..736dadfce5e 100644 --- a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs @@ -72,9 +72,7 @@ import Hedgehog.Gen qualified as Gen import Hedgehog.Range qualified as Range import Prettyprinter (vsep) import Test.Tasty (TestTree, testGroup) -#ifdef __USING_HPC__ -import Test.Tasty.ExpectedFailure (ignoreTest) -#endif +import Test.Tasty.Extras (ignoreTestIfHpcEnabled) import Test.Tasty.Hedgehog (testPropertyNamed) import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase, (@=?), (@?=)) import Test.Tasty.QuickCheck qualified as QC @@ -502,7 +500,7 @@ test_TrackCostsRestricting = test_TrackCostsRetaining :: TestTree test_TrackCostsRetaining = -#if MIN_VERSION_base(4,15,0) && !defined(__USING_HPC__) +#if MIN_VERSION_base(4,15,0) test_TrackCostsWith "retaining" 10000 $ \term -> do let -- An 'ExBudgetMode' that retains all the individual budgets by sticking them into a -- 'DList'. @@ -1251,11 +1249,7 @@ test_definition = , test_SwapEls , test_IdBuiltinData , test_TrackCostsRestricting -#ifdef __USING_HPC__ - , ignoreTest test_TrackCostsRetaining -#else - , test_TrackCostsRetaining -#endif + , ignoreTestIfHpcEnabled test_TrackCostsRetaining , test_SerialiseDataImpossible , test_fixId , runTestNestedHere diff --git a/plutus-ledger-api/test/Spec/Data/Eval.hs b/plutus-ledger-api/test/Spec/Data/Eval.hs index ea3b5ac0761..a30c76d9d5e 100644 --- a/plutus-ledger-api/test/Spec/Data/Eval.hs +++ b/plutus-ledger-api/test/Spec/Data/Eval.hs @@ -1,7 +1,6 @@ -- editorconfig-checker-disable-file -- TODO: merge this module to Versions.hs ? {-# LANGUAGE BangPatterns #-} -{-# LANGUAGE CPP #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} module Spec.Data.Eval (tests) where @@ -33,10 +32,8 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty -#ifdef __USING_HPC__ import Test.Tasty.ExpectedFailure (ignoreTest) -#endif -import Test.Tasty.HUnit +import Test.Tasty.Extras (ignoreTestIfHpcEnabled) {- Note [Direct UPLC code] For this test-suite we write the programs directly in the UPLC AST, diff --git a/plutus-ledger-api/test/Spec/Eval.hs b/plutus-ledger-api/test/Spec/Eval.hs index 87660f55c81..99dcdf59faf 100644 --- a/plutus-ledger-api/test/Spec/Eval.hs +++ b/plutus-ledger-api/test/Spec/Eval.hs @@ -1,7 +1,6 @@ -- editorconfig-checker-disable-file -- TODO: merge this module to Versions.hs ? {-# LANGUAGE BangPatterns #-} -{-# LANGUAGE CPP #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} module Spec.Eval (tests) where @@ -33,9 +32,7 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty -#ifdef __USING_HPC__ -import Test.Tasty.ExpectedFailure (ignoreTest) -#endif +import Test.Tasty.Extras (ignoreTestIfHpcEnabled) import Test.Tasty.HUnit {- Note [Direct UPLC code] @@ -135,10 +132,7 @@ tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete -#ifdef __USING_HPC__ - , ignoreTest evaluationContextNoThunks -#else + , ignoreTestIfHpcFlagDefined evaluationContextNoThunks , evaluationContextNoThunks -#endif ] From 1f5c96b24b755a16129c2b4e930e28323d169b4a Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 9 Apr 2025 17:31:21 +0200 Subject: [PATCH 21/24] wip --- .../Validator/Data/GoldenTests.hs | 9 +++-- nix/project.nix | 14 +++++-- plutus-benchmark/marlowe/test/Spec.hs | 32 ++++++++-------- .../script-contexts/test/V1/Spec.hs | 37 +++++++++++-------- .../script-contexts/test/V2/Spec.hs | 31 ++++++++++------ .../script-contexts/test/V3/Spec.hs | 17 ++++++--- plutus-core/testlib/Test/Tasty/Extras.hs | 3 +- .../testlib/Evaluation/Builtins/Definition.hs | 4 +- 8 files changed, 88 insertions(+), 59 deletions(-) diff --git a/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs b/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs index db5c9e9ba05..ae6fa972e8a 100644 --- a/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs +++ b/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs @@ -22,6 +22,7 @@ import Data.Maybe import Data.String import System.FilePath import Test.Tasty +import Test.Tasty.Extras (ignoreTestIfHpcEnabled) import Test.Tasty.Golden import Helpers.Guardrail @@ -67,11 +68,11 @@ test_readable_uplc = testGroup "ReadableUplc" $ M.elems $ tests :: TestTreeWithTestState tests = testGroup' "Golden" $ fmap const - [ test_cbor - , test_budget_large - , test_budget_small + [ ignoreTestIfHpcEnabled test_cbor + , ignoreTestIfHpcEnabled test_budget_large + , ignoreTestIfHpcEnabled test_budget_small , test_readable_pir - , test_readable_uplc + , ignoreTestIfHpcEnabled test_readable_uplc ] -- HELPERS diff --git a/nix/project.nix b/nix/project.nix index 717d62404db..e4f217ad69a 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -19,19 +19,27 @@ let enableLibraryProfiling = true; }]; ghc96-coverage.modules = [{ - # NOTE: Enabling coverage for some packages breaks tests due to HPC # (Haskell Program Coverage) instrumentation. The packages listed # below represent the largest subset that can be enabled without # breaking tests. + # packages.cardano-constitution.doCoverage = true; packages.plutus-conformance.doCoverage = true; packages.plutus-core.doCoverage = true; packages.plutus-executables.doCoverage = true; packages.plutus-tx-test-util.doCoverage = true; packages.plutus-ledger-api.doCoverage = true; - packages.plutus-core.configureFlags = [ "--ghc-option=-D__HPC_ENABLED__" ]; - packages.plutus-ledger-api.configureFlags = [ "--ghc-option=-D__HPC_ENABLED__" ]; + # plutus-benchmark + # plutus-conformance + # plutus-core + # plutus-executables + # plutus-ledger-api + # plutus-metatheory + # plutus-tx + # plutus-tx-plugin + # plutus-tx-test-util + # docusaurus-examples }]; ghc810.compiler-nix-name = "ghc810"; ghc98.compiler-nix-name = "ghc98"; diff --git a/plutus-benchmark/marlowe/test/Spec.hs b/plutus-benchmark/marlowe/test/Spec.hs index 9ad0df536fd..3850edb8d41 100644 --- a/plutus-benchmark/marlowe/test/Spec.hs +++ b/plutus-benchmark/marlowe/test/Spec.hs @@ -19,6 +19,7 @@ import PlutusLedgerApi.V3 (ExCPU (..), ExMemory (..)) import System.FilePath (()) import System.IO (hPutStrLn) import Test.Tasty (defaultMain, testGroup) +import Test.Tasty.Extras (ignoreTestIfHpcEnabled) import UntypedPlutusCore.Size qualified as UPLC main :: IO () @@ -65,19 +66,20 @@ main = withUtf8 $ do Lib.measureProgram [benchmarkToUPLC Data.rolePayoutValidator bench | bench <- rolePayout] + let marloweTests = testGroup "Marlowe" + [ Lib.goldenUplcMeasurements "budgets" goldenFile actualFile \writeHandle -> + for_ + (semanticsMeasures <> rolePayoutMeasures) + \(ExCPU cpu, ExMemory mem, UPLC.Size size) -> + hPutStrLn writeHandle $ + List.intercalate "\t" [show cpu, show mem, show size] + , Lib.goldenUplcMeasurements "data-budgets" goldenFileData actualFileData \writeHandle -> + for_ + (dataSemanticsMeasures <> dataRolePayoutMeasures) + \(ExCPU cpu, ExMemory mem, UPLC.Size size) -> + hPutStrLn writeHandle $ + List.intercalate "\t" [show cpu, show mem, show size] + ] + -- Write the measures to the actual file - defaultMain - $ testGroup "Marlowe" - [ Lib.goldenUplcMeasurements "budgets" goldenFile actualFile \writeHandle -> - for_ - (semanticsMeasures <> rolePayoutMeasures) - \(ExCPU cpu, ExMemory mem, UPLC.Size size) -> - hPutStrLn writeHandle $ - List.intercalate "\t" [show cpu, show mem, show size] - , Lib.goldenUplcMeasurements "data-budgets" goldenFileData actualFileData \writeHandle -> - for_ - (dataSemanticsMeasures <> dataRolePayoutMeasures) - \(ExCPU cpu, ExMemory mem, UPLC.Size size) -> - hPutStrLn writeHandle $ - List.intercalate "\t" [show cpu, show mem, show size] - ] + defaultMain $ ignoreTestIfHpcEnabled marloweTests diff --git a/plutus-benchmark/script-contexts/test/V1/Spec.hs b/plutus-benchmark/script-contexts/test/V1/Spec.hs index 8cb761f9a5c..72c523bd760 100644 --- a/plutus-benchmark/script-contexts/test/V1/Spec.hs +++ b/plutus-benchmark/script-contexts/test/V1/Spec.hs @@ -5,7 +5,7 @@ module V1.Spec (allTests) where import Data.Text qualified as Text import Test.Tasty -import Test.Tasty.Extras (TestNested, runTestNested, testNestedGhc) +import Test.Tasty.Extras (TestNested, ignoreTestIfHpcEnabled, runTestNested, testNestedGhc) import Test.Tasty.HUnit import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek) @@ -47,7 +47,10 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4) , testCase "fails on 5" . assertFailed $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5) - , runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $ + , ignoreTestIfHpcEnabled $ + runTestGhcSOP + [ + Tx.goldenSize "checkScriptContext1" $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1) , Tx.goldenPirReadable "checkScriptContext1" $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1) @@ -59,7 +62,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20) , Tx.goldenEvalCekCatch "checkScriptContext1-20" $ [SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20)] - ] + ] ] testCheckDataSc1 :: TestTree @@ -89,19 +92,21 @@ testCheckSOPSc2 = testGroup "checkScriptContext2" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4) , testCase "succeed on 5" . assertSucceeded $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5) - , runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $ - SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) - , Tx.goldenPirReadable "checkScriptContext2" $ - SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) - , Tx.goldenBudget "checkScriptContext2-4" $ - SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4) - , Tx.goldenEvalCekCatch "checkScriptContext2-4" $ - [SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4)] - , Tx.goldenBudget "checkScriptContext2-20" $ - SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20) - , Tx.goldenEvalCekCatch "checkScriptContext2-20" $ - [SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)] - ] + , ignoreTestIfHpcEnabled $ + runTestGhcSOP + [ Tx.goldenSize "checkScriptContext2" $ + SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) + , Tx.goldenPirReadable "checkScriptContext2" $ + SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) + , Tx.goldenBudget "checkScriptContext2-4" $ + SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4) + , Tx.goldenEvalCekCatch "checkScriptContext2-4" $ + [SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4)] + , Tx.goldenBudget "checkScriptContext2-20" $ + SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20) + , Tx.goldenEvalCekCatch "checkScriptContext2-20" $ + [SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)] + ] ] testCheckDataSc2 :: TestTree diff --git a/plutus-benchmark/script-contexts/test/V2/Spec.hs b/plutus-benchmark/script-contexts/test/V2/Spec.hs index 03cf22bc4a4..16a03bec2b0 100644 --- a/plutus-benchmark/script-contexts/test/V2/Spec.hs +++ b/plutus-benchmark/script-contexts/test/V2/Spec.hs @@ -7,7 +7,7 @@ module V2.Spec (allTests) where import Data.Text qualified as Text import Test.Tasty -import Test.Tasty.Extras (TestNested, runTestNested, testNestedGhc) +import Test.Tasty.Extras (TestNested, ignoreTestIfHpcEnabled, runTestNested, testNestedGhc) import Test.Tasty.HUnit import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek) @@ -51,7 +51,10 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4) , testCase "fails on 5" . assertFailed $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5) - , runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $ + , ignoreTestIfHpcEnabled $ + runTestGhcSOP + [ + Tx.goldenSize "checkScriptContext1" $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1) , Tx.goldenPirReadable "checkScriptContext1" $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1) @@ -63,7 +66,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20) , Tx.goldenEvalCekCatch "checkScriptContext1-20" $ [SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20)] - ] + ] ] testCheckDataSc1 :: TestTree @@ -93,7 +96,10 @@ testCheckSOPSc2 = testGroup "checkScriptContext2" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4) , testCase "succeed on 5" . assertSucceeded $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5) - , runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $ + , ignoreTestIfHpcEnabled $ + runTestGhcSOP + [ + Tx.goldenSize "checkScriptContext2" $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) , Tx.goldenPirReadable "checkScriptContext2" $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) @@ -105,7 +111,7 @@ testCheckSOPSc2 = testGroup "checkScriptContext2" SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20) , Tx.goldenEvalCekCatch "checkScriptContext2-20" $ [SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)] - ] + ] ] testCheckDataSc2 :: TestTree @@ -157,13 +163,14 @@ testCheckDataScEquality = testGroup "checkScriptContextEquality" testSOPFwdStakeTrick :: TestTree testSOPFwdStakeTrick = - runTestGhcSOP - [ Tx.goldenSize "sopFwdStakeTrick" testCode - , Tx.goldenPirReadable "sopFwdStakeTrick" testAbsCode - , Tx.goldenUPlcReadable "sopFwdStakeTrick" testAbsCode - , Tx.goldenBudget "sopFwdStakeTrick" testCode - , Tx.goldenEvalCekCatch "sopFwdStakeTrick" [testCode] - ] + ignoreTestIfHpcEnabled $ + runTestGhcSOP + [ Tx.goldenSize "sopFwdStakeTrick" testCode + , Tx.goldenPirReadable "sopFwdStakeTrick" testAbsCode + , Tx.goldenUPlcReadable "sopFwdStakeTrick" testAbsCode + , Tx.goldenBudget "sopFwdStakeTrick" testCode + , Tx.goldenEvalCekCatch "sopFwdStakeTrick" [testCode] + ] where testCredential = SOP.SC.mkStakingCredential "someCredential" diff --git a/plutus-benchmark/script-contexts/test/V3/Spec.hs b/plutus-benchmark/script-contexts/test/V3/Spec.hs index 74b2aee8ecc..44f83295b9c 100644 --- a/plutus-benchmark/script-contexts/test/V3/Spec.hs +++ b/plutus-benchmark/script-contexts/test/V3/Spec.hs @@ -5,7 +5,7 @@ module V3.Spec (allTests) where import Data.Text qualified as Text import Test.Tasty -import Test.Tasty.Extras (TestNested, runTestNested, testNestedGhc) +import Test.Tasty.Extras (TestNested, ignoreTestIfHpcEnabled, runTestNested, testNestedGhc) import Test.Tasty.HUnit import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek) @@ -47,7 +47,10 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4) , testCase "fails on 5" . assertFailed $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5) - , runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $ + , ignoreTestIfHpcEnabled $ + runTestGhcSOP + [ + Tx.goldenSize "checkScriptContext1" $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1) , Tx.goldenPirReadable "checkScriptContext1" $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1) @@ -59,7 +62,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20) , Tx.goldenEvalCekCatch "checkScriptContext1-20" $ [SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20)] - ] + ] ] testCheckDataSc1 :: TestTree @@ -89,7 +92,9 @@ testCheckSOPSc2 = testGroup "checkScriptContext2" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4) , testCase "succeed on 5" . assertSucceeded $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5) - , runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $ + , ignoreTestIfHpcEnabled $ + runTestGhcSOP + [ Tx.goldenSize "checkScriptContext2" $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) , Tx.goldenPirReadable "checkScriptContext2" $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) @@ -101,7 +106,7 @@ testCheckSOPSc2 = testGroup "checkScriptContext2" SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20) , Tx.goldenEvalCekCatch "checkScriptContext2-20" $ [SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)] - ] + ] ] testCheckDataSc2 :: TestTree @@ -152,7 +157,7 @@ testCheckDataScEquality = testGroup "checkScriptContextEquality" ] testPurposeIsWellFormed :: TestTree -testPurposeIsWellFormed = testGroup "purposeIsWellFormed" +testPurposeIsWellFormed = ignoreTestIfHpcEnabled $ testGroup "purposeIsWellFormed" [ runTestGhcData [ Tx.goldenPirReadable "purposeIsWellFormed" $ Data.SC.compiledPurposeIsWellFormed , Tx.goldenSize "purposeIsWellFormed" $ diff --git a/plutus-core/testlib/Test/Tasty/Extras.hs b/plutus-core/testlib/Test/Tasty/Extras.hs index 2caa2190ebe..1db5844427c 100644 --- a/plutus-core/testlib/Test/Tasty/Extras.hs +++ b/plutus-core/testlib/Test/Tasty/Extras.hs @@ -318,7 +318,8 @@ expected %=? actual = assertEqualPretty "" expected actual actual %?= expected = assertEqualPretty "" expected actual {-| -Some tests inspect GHC code, but GHC code gets instrumented when using hpc. +Some tests inspect GHC code, but GHC code gets instrumented when using HPC +(Haskell Program Coverage), which causes those tests to fail. This flag disables those tests when the custom __HPC_ENABLED__ flag is defined. -} ignoreTestIfHpcEnabled :: TestTree -> TestTree diff --git a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs index 736dadfce5e..b1ef2ec10b6 100644 --- a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs @@ -72,7 +72,7 @@ import Hedgehog.Gen qualified as Gen import Hedgehog.Range qualified as Range import Prettyprinter (vsep) import Test.Tasty (TestTree, testGroup) -import Test.Tasty.Extras (ignoreTestIfHpcEnabled) +import Test.Tasty.Extras qualified as TE import Test.Tasty.Hedgehog (testPropertyNamed) import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase, (@=?), (@?=)) import Test.Tasty.QuickCheck qualified as QC @@ -1249,7 +1249,7 @@ test_definition = , test_SwapEls , test_IdBuiltinData , test_TrackCostsRestricting - , ignoreTestIfHpcEnabled test_TrackCostsRetaining + , TE.ignoreTestIfHpcEnabled test_TrackCostsRetaining , test_SerialiseDataImpossible , test_fixId , runTestNestedHere From a774e22904e35095a9dfb4fd33c94c7427a08465 Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 9 Apr 2025 19:41:12 +0200 Subject: [PATCH 22/24] wip --- nix/project.nix | 7 ++----- plutus-ledger-api/test/Spec/Data/Eval.hs | 6 +----- plutus-ledger-api/test/Spec/Eval.hs | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/nix/project.nix b/nix/project.nix index e4f217ad69a..f7ed7b8853c 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -29,16 +29,13 @@ let packages.plutus-executables.doCoverage = true; packages.plutus-tx-test-util.doCoverage = true; packages.plutus-ledger-api.doCoverage = true; + # packages.plutus-tx.doCoverage = true; + packages.plutus-core.configureFlags = [ "--ghc-option=-D__HPC_ENABLED__" ]; # plutus-benchmark - # plutus-conformance - # plutus-core - # plutus-executables - # plutus-ledger-api # plutus-metatheory # plutus-tx # plutus-tx-plugin - # plutus-tx-test-util # docusaurus-examples }]; ghc810.compiler-nix-name = "ghc810"; diff --git a/plutus-ledger-api/test/Spec/Data/Eval.hs b/plutus-ledger-api/test/Spec/Data/Eval.hs index a30c76d9d5e..f42f844f803 100644 --- a/plutus-ledger-api/test/Spec/Data/Eval.hs +++ b/plutus-ledger-api/test/Spec/Data/Eval.hs @@ -32,7 +32,6 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty -import Test.Tasty.ExpectedFailure (ignoreTest) import Test.Tasty.Extras (ignoreTestIfHpcEnabled) {- Note [Direct UPLC code] @@ -132,10 +131,7 @@ tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete -#ifdef __USING_HPC__ - , ignoreTest evaluationContextNoThunks -#else + , ignoreTestIfHpcEnabled evaluationContextNoThunks , evaluationContextNoThunks -#endif ] diff --git a/plutus-ledger-api/test/Spec/Eval.hs b/plutus-ledger-api/test/Spec/Eval.hs index 99dcdf59faf..d66cc23a15b 100644 --- a/plutus-ledger-api/test/Spec/Eval.hs +++ b/plutus-ledger-api/test/Spec/Eval.hs @@ -132,7 +132,7 @@ tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete - , ignoreTestIfHpcFlagDefined evaluationContextNoThunks + , ignoreTestIfHpcEnabled evaluationContextNoThunks , evaluationContextNoThunks ] From fe21d90ea84a505e002f290b889f48699c670278 Mon Sep 17 00:00:00 2001 From: zeme Date: Mon, 14 Apr 2025 12:55:29 +0200 Subject: [PATCH 23/24] wip --- .../Cardano/Constitution/Validator/Data/GoldenTests.hs | 10 +++++----- .../test/Cardano/Constitution/Validator/GoldenTests.hs | 10 +++++----- plutus-benchmark/marlowe/test/Spec.hs | 4 ++-- plutus-benchmark/script-contexts/test/V1/Spec.hs | 6 +++--- plutus-benchmark/script-contexts/test/V2/Spec.hs | 8 ++++---- plutus-benchmark/script-contexts/test/V3/Spec.hs | 8 ++++---- plutus-core/testlib/Test/Tasty/Extras.hs | 8 ++++---- .../testlib/Evaluation/Builtins/Definition.hs | 3 +-- plutus-ledger-api/plutus-ledger-api.cabal | 1 - plutus-ledger-api/test/Spec/Data/Eval.hs | 6 +++--- plutus-ledger-api/test/Spec/Eval.hs | 5 ++--- 11 files changed, 33 insertions(+), 36 deletions(-) diff --git a/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs b/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs index ae6fa972e8a..7743650f191 100644 --- a/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs +++ b/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs @@ -22,7 +22,7 @@ import Data.Maybe import Data.String import System.FilePath import Test.Tasty -import Test.Tasty.Extras (ignoreTestIfHpcEnabled) +import Test.Tasty.Extras (ignoreThisTestIfHpcIsEnabled) import Test.Tasty.Golden import Helpers.Guardrail @@ -68,11 +68,11 @@ test_readable_uplc = testGroup "ReadableUplc" $ M.elems $ tests :: TestTreeWithTestState tests = testGroup' "Golden" $ fmap const - [ ignoreTestIfHpcEnabled test_cbor - , ignoreTestIfHpcEnabled test_budget_large - , ignoreTestIfHpcEnabled test_budget_small + [ ignoreThisTestIfHpcIsEnabled test_cbor + , ignoreThisTestIfHpcIsEnabled test_budget_large + , ignoreThisTestIfHpcIsEnabled test_budget_small , test_readable_pir - , ignoreTestIfHpcEnabled test_readable_uplc + , ignoreThisTestIfHpcIsEnabled test_readable_uplc ] -- HELPERS diff --git a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs index a7aa1cfa28b..113dbb4fc2a 100644 --- a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs +++ b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs @@ -22,7 +22,7 @@ import Data.Maybe import Data.String import System.FilePath import Test.Tasty -import Test.Tasty.Extras (ignoreTestIfHpcEnabled) +import Test.Tasty.Extras (ignoreThisTestIfHpcIsEnabled) import Test.Tasty.Golden import Helpers.Guardrail @@ -68,11 +68,11 @@ test_readable_uplc = testGroup "ReadableUplc" $ M.elems $ tests :: TestTreeWithTestState tests = testGroup' "Golden" $ fmap const - [ ignoreTestIfHpcEnabled test_cbor - , ignoreTestIfHpcEnabled test_budget_large - , ignoreTestIfHpcEnabled test_budget_small + [ ignoreThisTestIfHpcIsEnabled test_cbor + , ignoreThisTestIfHpcIsEnabled test_budget_large + , ignoreThisTestIfHpcIsEnabled test_budget_small , test_readable_pir - , ignoreTestIfHpcEnabled test_readable_uplc + , ignoreThisTestIfHpcIsEnabled test_readable_uplc ] -- HELPERS diff --git a/plutus-benchmark/marlowe/test/Spec.hs b/plutus-benchmark/marlowe/test/Spec.hs index 3850edb8d41..137d4d564b4 100644 --- a/plutus-benchmark/marlowe/test/Spec.hs +++ b/plutus-benchmark/marlowe/test/Spec.hs @@ -19,7 +19,7 @@ import PlutusLedgerApi.V3 (ExCPU (..), ExMemory (..)) import System.FilePath (()) import System.IO (hPutStrLn) import Test.Tasty (defaultMain, testGroup) -import Test.Tasty.Extras (ignoreTestIfHpcEnabled) +import Test.Tasty.Extras (ignoreThisTestIfHpcIsEnabled) import UntypedPlutusCore.Size qualified as UPLC main :: IO () @@ -82,4 +82,4 @@ main = withUtf8 $ do ] -- Write the measures to the actual file - defaultMain $ ignoreTestIfHpcEnabled marloweTests + defaultMain $ ignoreThisTestIfHpcIsEnabled marloweTests diff --git a/plutus-benchmark/script-contexts/test/V1/Spec.hs b/plutus-benchmark/script-contexts/test/V1/Spec.hs index 72c523bd760..a351f16da3f 100644 --- a/plutus-benchmark/script-contexts/test/V1/Spec.hs +++ b/plutus-benchmark/script-contexts/test/V1/Spec.hs @@ -5,7 +5,7 @@ module V1.Spec (allTests) where import Data.Text qualified as Text import Test.Tasty -import Test.Tasty.Extras (TestNested, ignoreTestIfHpcEnabled, runTestNested, testNestedGhc) +import Test.Tasty.Extras (TestNested, ignoreThisTestIfHpcIsEnabled, runTestNested, testNestedGhc) import Test.Tasty.HUnit import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek) @@ -47,7 +47,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4) , testCase "fails on 5" . assertFailed $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5) - , ignoreTestIfHpcEnabled $ + , ignoreThisTestIfHpcIsEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $ @@ -92,7 +92,7 @@ testCheckSOPSc2 = testGroup "checkScriptContext2" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4) , testCase "succeed on 5" . assertSucceeded $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5) - , ignoreTestIfHpcEnabled $ + , ignoreThisTestIfHpcIsEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) diff --git a/plutus-benchmark/script-contexts/test/V2/Spec.hs b/plutus-benchmark/script-contexts/test/V2/Spec.hs index 16a03bec2b0..f01da72f6dd 100644 --- a/plutus-benchmark/script-contexts/test/V2/Spec.hs +++ b/plutus-benchmark/script-contexts/test/V2/Spec.hs @@ -7,7 +7,7 @@ module V2.Spec (allTests) where import Data.Text qualified as Text import Test.Tasty -import Test.Tasty.Extras (TestNested, ignoreTestIfHpcEnabled, runTestNested, testNestedGhc) +import Test.Tasty.Extras (TestNested, ignoreThisTestIfHpcIsEnabled, runTestNested, testNestedGhc) import Test.Tasty.HUnit import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek) @@ -51,7 +51,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4) , testCase "fails on 5" . assertFailed $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5) - , ignoreTestIfHpcEnabled $ + , ignoreThisTestIfHpcIsEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $ @@ -96,7 +96,7 @@ testCheckSOPSc2 = testGroup "checkScriptContext2" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4) , testCase "succeed on 5" . assertSucceeded $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5) - , ignoreTestIfHpcEnabled $ + , ignoreThisTestIfHpcIsEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $ @@ -163,7 +163,7 @@ testCheckDataScEquality = testGroup "checkScriptContextEquality" testSOPFwdStakeTrick :: TestTree testSOPFwdStakeTrick = - ignoreTestIfHpcEnabled $ + ignoreThisTestIfHpcIsEnabled $ runTestGhcSOP [ Tx.goldenSize "sopFwdStakeTrick" testCode , Tx.goldenPirReadable "sopFwdStakeTrick" testAbsCode diff --git a/plutus-benchmark/script-contexts/test/V3/Spec.hs b/plutus-benchmark/script-contexts/test/V3/Spec.hs index 44f83295b9c..2145da1b2e3 100644 --- a/plutus-benchmark/script-contexts/test/V3/Spec.hs +++ b/plutus-benchmark/script-contexts/test/V3/Spec.hs @@ -5,7 +5,7 @@ module V3.Spec (allTests) where import Data.Text qualified as Text import Test.Tasty -import Test.Tasty.Extras (TestNested, ignoreTestIfHpcEnabled, runTestNested, testNestedGhc) +import Test.Tasty.Extras (TestNested, ignoreThisTestIfHpcIsEnabled, runTestNested, testNestedGhc) import Test.Tasty.HUnit import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek) @@ -47,7 +47,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4) , testCase "fails on 5" . assertFailed $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5) - , ignoreTestIfHpcEnabled $ + , ignoreThisTestIfHpcIsEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $ @@ -92,7 +92,7 @@ testCheckSOPSc2 = testGroup "checkScriptContext2" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4) , testCase "succeed on 5" . assertSucceeded $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5) - , ignoreTestIfHpcEnabled $ + , ignoreThisTestIfHpcIsEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) @@ -157,7 +157,7 @@ testCheckDataScEquality = testGroup "checkScriptContextEquality" ] testPurposeIsWellFormed :: TestTree -testPurposeIsWellFormed = ignoreTestIfHpcEnabled $ testGroup "purposeIsWellFormed" +testPurposeIsWellFormed = ignoreThisTestIfHpcIsEnabled $ testGroup "purposeIsWellFormed" [ runTestGhcData [ Tx.goldenPirReadable "purposeIsWellFormed" $ Data.SC.compiledPurposeIsWellFormed , Tx.goldenSize "purposeIsWellFormed" $ diff --git a/plutus-core/testlib/Test/Tasty/Extras.hs b/plutus-core/testlib/Test/Tasty/Extras.hs index 1db5844427c..6ac1fe43c7f 100644 --- a/plutus-core/testlib/Test/Tasty/Extras.hs +++ b/plutus-core/testlib/Test/Tasty/Extras.hs @@ -34,7 +34,7 @@ module Test.Tasty.Extras , assertEqualPretty , (%=?) , (%?=) - , ignoreTestIfHpcEnabled + , ignoreThisTestIfHpcIsEnabled ) where import PlutusPrelude hiding (toList) @@ -320,10 +320,10 @@ actual %?= expected = assertEqualPretty "" expected actual {-| Some tests inspect GHC code, but GHC code gets instrumented when using HPC (Haskell Program Coverage), which causes those tests to fail. -This flag disables those tests when the custom __HPC_ENABLED__ flag is defined. +This function disables those tests when the custom __HPC_ENABLED__ flag is defined. -} -ignoreTestIfHpcEnabled :: TestTree -> TestTree -ignoreTestIfHpcEnabled t = +ignoreThisTestIfHpcIsEnabled :: TestTree -> TestTree +ignoreThisTestIfHpcIsEnabled t = #ifdef __HPC_ENABLED__ ignoreTest t #else diff --git a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs index b1ef2ec10b6..816bacc1912 100644 --- a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs @@ -72,7 +72,6 @@ import Hedgehog.Gen qualified as Gen import Hedgehog.Range qualified as Range import Prettyprinter (vsep) import Test.Tasty (TestTree, testGroup) -import Test.Tasty.Extras qualified as TE import Test.Tasty.Hedgehog (testPropertyNamed) import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase, (@=?), (@?=)) import Test.Tasty.QuickCheck qualified as QC @@ -1249,7 +1248,7 @@ test_definition = , test_SwapEls , test_IdBuiltinData , test_TrackCostsRestricting - , TE.ignoreTestIfHpcEnabled test_TrackCostsRetaining + , ignoreThisTestIfHpcIsEnabled test_TrackCostsRetaining , test_SerialiseDataImpossible , test_fixId , runTestNestedHere diff --git a/plutus-ledger-api/plutus-ledger-api.cabal b/plutus-ledger-api/plutus-ledger-api.cabal index 9297481b4e1..544fe3c5e78 100644 --- a/plutus-ledger-api/plutus-ledger-api.cabal +++ b/plutus-ledger-api/plutus-ledger-api.cabal @@ -200,7 +200,6 @@ test-suite plutus-ledger-api-test , prettyprinter , serialise , tasty - , tasty-expected-failure , tasty-hedgehog , tasty-hunit , tasty-quickcheck diff --git a/plutus-ledger-api/test/Spec/Data/Eval.hs b/plutus-ledger-api/test/Spec/Data/Eval.hs index f42f844f803..0f3db153f72 100644 --- a/plutus-ledger-api/test/Spec/Data/Eval.hs +++ b/plutus-ledger-api/test/Spec/Data/Eval.hs @@ -32,7 +32,8 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty -import Test.Tasty.Extras (ignoreTestIfHpcEnabled) +import Test.Tasty.Extras (ignoreThisTestIfHpcIsEnabled) +import Test.Tasty.HUnit {- Note [Direct UPLC code] For this test-suite we write the programs directly in the UPLC AST, @@ -131,7 +132,6 @@ tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete - , ignoreTestIfHpcEnabled evaluationContextNoThunks - , evaluationContextNoThunks + , ignoreThisTestIfHpcIsEnabled evaluationContextNoThunks ] diff --git a/plutus-ledger-api/test/Spec/Eval.hs b/plutus-ledger-api/test/Spec/Eval.hs index d66cc23a15b..4c7caf767c3 100644 --- a/plutus-ledger-api/test/Spec/Eval.hs +++ b/plutus-ledger-api/test/Spec/Eval.hs @@ -32,7 +32,7 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty -import Test.Tasty.Extras (ignoreTestIfHpcEnabled) +import Test.Tasty.Extras (ignoreThisTestIfHpcIsEnabled) import Test.Tasty.HUnit {- Note [Direct UPLC code] @@ -132,7 +132,6 @@ tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete - , ignoreTestIfHpcEnabled evaluationContextNoThunks - , evaluationContextNoThunks + , ignoreThisTestIfHpcIsEnabled evaluationContextNoThunks ] From b624b9f20ab60e7a9e6c1aa8ed366dc509f4ff8b Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 22 Apr 2025 13:53:13 +0200 Subject: [PATCH 24/24] wip --- .../Cardano/Constitution/Validator/Data/GoldenTests.hs | 10 +++++----- .../test/Cardano/Constitution/Validator/GoldenTests.hs | 10 +++++----- nix/project.nix | 2 +- plutus-benchmark/marlowe/test/Spec.hs | 4 ++-- plutus-benchmark/script-contexts/test/V1/Spec.hs | 6 +++--- plutus-benchmark/script-contexts/test/V2/Spec.hs | 8 ++++---- plutus-benchmark/script-contexts/test/V3/Spec.hs | 8 ++++---- plutus-core/testlib/Test/Tasty/Extras.hs | 6 +++--- .../testlib/Evaluation/Builtins/Definition.hs | 2 +- plutus-ledger-api/test/Spec/Data/Eval.hs | 4 ++-- plutus-ledger-api/test/Spec/Eval.hs | 4 ++-- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs b/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs index 7743650f191..b0b033efa28 100644 --- a/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs +++ b/cardano-constitution/test/Cardano/Constitution/Validator/Data/GoldenTests.hs @@ -22,7 +22,7 @@ import Data.Maybe import Data.String import System.FilePath import Test.Tasty -import Test.Tasty.Extras (ignoreThisTestIfHpcIsEnabled) +import Test.Tasty.Extras (ignoreTestWhenHpcEnabled) import Test.Tasty.Golden import Helpers.Guardrail @@ -68,11 +68,11 @@ test_readable_uplc = testGroup "ReadableUplc" $ M.elems $ tests :: TestTreeWithTestState tests = testGroup' "Golden" $ fmap const - [ ignoreThisTestIfHpcIsEnabled test_cbor - , ignoreThisTestIfHpcIsEnabled test_budget_large - , ignoreThisTestIfHpcIsEnabled test_budget_small + [ ignoreTestWhenHpcEnabled test_cbor + , ignoreTestWhenHpcEnabled test_budget_large + , ignoreTestWhenHpcEnabled test_budget_small , test_readable_pir - , ignoreThisTestIfHpcIsEnabled test_readable_uplc + , ignoreTestWhenHpcEnabled test_readable_uplc ] -- HELPERS diff --git a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs index 113dbb4fc2a..e636eedb281 100644 --- a/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs +++ b/cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs @@ -22,7 +22,7 @@ import Data.Maybe import Data.String import System.FilePath import Test.Tasty -import Test.Tasty.Extras (ignoreThisTestIfHpcIsEnabled) +import Test.Tasty.Extras (ignoreTestWhenHpcEnabled) import Test.Tasty.Golden import Helpers.Guardrail @@ -68,11 +68,11 @@ test_readable_uplc = testGroup "ReadableUplc" $ M.elems $ tests :: TestTreeWithTestState tests = testGroup' "Golden" $ fmap const - [ ignoreThisTestIfHpcIsEnabled test_cbor - , ignoreThisTestIfHpcIsEnabled test_budget_large - , ignoreThisTestIfHpcIsEnabled test_budget_small + [ ignoreTestWhenHpcEnabled test_cbor + , ignoreTestWhenHpcEnabled test_budget_large + , ignoreTestWhenHpcEnabled test_budget_small , test_readable_pir - , ignoreThisTestIfHpcIsEnabled test_readable_uplc + , ignoreTestWhenHpcEnabled test_readable_uplc ] -- HELPERS diff --git a/nix/project.nix b/nix/project.nix index f7ed7b8853c..1663e8761bb 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -24,12 +24,12 @@ let # below represent the largest subset that can be enabled without # breaking tests. # packages.cardano-constitution.doCoverage = true; + # packages.plutus-tx.doCoverage = true; packages.plutus-conformance.doCoverage = true; packages.plutus-core.doCoverage = true; packages.plutus-executables.doCoverage = true; packages.plutus-tx-test-util.doCoverage = true; packages.plutus-ledger-api.doCoverage = true; - # packages.plutus-tx.doCoverage = true; packages.plutus-core.configureFlags = [ "--ghc-option=-D__HPC_ENABLED__" ]; # plutus-benchmark diff --git a/plutus-benchmark/marlowe/test/Spec.hs b/plutus-benchmark/marlowe/test/Spec.hs index 137d4d564b4..c9f3a7d72d1 100644 --- a/plutus-benchmark/marlowe/test/Spec.hs +++ b/plutus-benchmark/marlowe/test/Spec.hs @@ -19,7 +19,7 @@ import PlutusLedgerApi.V3 (ExCPU (..), ExMemory (..)) import System.FilePath (()) import System.IO (hPutStrLn) import Test.Tasty (defaultMain, testGroup) -import Test.Tasty.Extras (ignoreThisTestIfHpcIsEnabled) +import Test.Tasty.Extras (ignoreTestWhenHpcEnabled) import UntypedPlutusCore.Size qualified as UPLC main :: IO () @@ -82,4 +82,4 @@ main = withUtf8 $ do ] -- Write the measures to the actual file - defaultMain $ ignoreThisTestIfHpcIsEnabled marloweTests + defaultMain $ ignoreTestWhenHpcEnabled marloweTests diff --git a/plutus-benchmark/script-contexts/test/V1/Spec.hs b/plutus-benchmark/script-contexts/test/V1/Spec.hs index a351f16da3f..2362ee10829 100644 --- a/plutus-benchmark/script-contexts/test/V1/Spec.hs +++ b/plutus-benchmark/script-contexts/test/V1/Spec.hs @@ -5,7 +5,7 @@ module V1.Spec (allTests) where import Data.Text qualified as Text import Test.Tasty -import Test.Tasty.Extras (TestNested, ignoreThisTestIfHpcIsEnabled, runTestNested, testNestedGhc) +import Test.Tasty.Extras (TestNested, ignoreTestWhenHpcEnabled, runTestNested, testNestedGhc) import Test.Tasty.HUnit import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek) @@ -47,7 +47,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4) , testCase "fails on 5" . assertFailed $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5) - , ignoreThisTestIfHpcIsEnabled $ + , ignoreTestWhenHpcEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $ @@ -92,7 +92,7 @@ testCheckSOPSc2 = testGroup "checkScriptContext2" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4) , testCase "succeed on 5" . assertSucceeded $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5) - , ignoreThisTestIfHpcIsEnabled $ + , ignoreTestWhenHpcEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) diff --git a/plutus-benchmark/script-contexts/test/V2/Spec.hs b/plutus-benchmark/script-contexts/test/V2/Spec.hs index f01da72f6dd..e9c3de7a36e 100644 --- a/plutus-benchmark/script-contexts/test/V2/Spec.hs +++ b/plutus-benchmark/script-contexts/test/V2/Spec.hs @@ -7,7 +7,7 @@ module V2.Spec (allTests) where import Data.Text qualified as Text import Test.Tasty -import Test.Tasty.Extras (TestNested, ignoreThisTestIfHpcIsEnabled, runTestNested, testNestedGhc) +import Test.Tasty.Extras (TestNested, ignoreTestWhenHpcEnabled, runTestNested, testNestedGhc) import Test.Tasty.HUnit import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek) @@ -51,7 +51,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4) , testCase "fails on 5" . assertFailed $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5) - , ignoreThisTestIfHpcIsEnabled $ + , ignoreTestWhenHpcEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $ @@ -96,7 +96,7 @@ testCheckSOPSc2 = testGroup "checkScriptContext2" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4) , testCase "succeed on 5" . assertSucceeded $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5) - , ignoreThisTestIfHpcIsEnabled $ + , ignoreTestWhenHpcEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $ @@ -163,7 +163,7 @@ testCheckDataScEquality = testGroup "checkScriptContextEquality" testSOPFwdStakeTrick :: TestTree testSOPFwdStakeTrick = - ignoreThisTestIfHpcIsEnabled $ + ignoreTestWhenHpcEnabled $ runTestGhcSOP [ Tx.goldenSize "sopFwdStakeTrick" testCode , Tx.goldenPirReadable "sopFwdStakeTrick" testAbsCode diff --git a/plutus-benchmark/script-contexts/test/V3/Spec.hs b/plutus-benchmark/script-contexts/test/V3/Spec.hs index 2145da1b2e3..6f2cde102ad 100644 --- a/plutus-benchmark/script-contexts/test/V3/Spec.hs +++ b/plutus-benchmark/script-contexts/test/V3/Spec.hs @@ -5,7 +5,7 @@ module V3.Spec (allTests) where import Data.Text qualified as Text import Test.Tasty -import Test.Tasty.Extras (TestNested, ignoreThisTestIfHpcIsEnabled, runTestNested, testNestedGhc) +import Test.Tasty.Extras (TestNested, ignoreTestWhenHpcEnabled, runTestNested, testNestedGhc) import Test.Tasty.HUnit import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek) @@ -47,7 +47,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4) , testCase "fails on 5" . assertFailed $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5) - , ignoreThisTestIfHpcIsEnabled $ + , ignoreTestWhenHpcEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $ @@ -92,7 +92,7 @@ testCheckSOPSc2 = testGroup "checkScriptContext2" compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4) , testCase "succeed on 5" . assertSucceeded $ compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5) - , ignoreThisTestIfHpcIsEnabled $ + , ignoreTestWhenHpcEnabled $ runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1) @@ -157,7 +157,7 @@ testCheckDataScEquality = testGroup "checkScriptContextEquality" ] testPurposeIsWellFormed :: TestTree -testPurposeIsWellFormed = ignoreThisTestIfHpcIsEnabled $ testGroup "purposeIsWellFormed" +testPurposeIsWellFormed = ignoreTestWhenHpcEnabled $ testGroup "purposeIsWellFormed" [ runTestGhcData [ Tx.goldenPirReadable "purposeIsWellFormed" $ Data.SC.compiledPurposeIsWellFormed , Tx.goldenSize "purposeIsWellFormed" $ diff --git a/plutus-core/testlib/Test/Tasty/Extras.hs b/plutus-core/testlib/Test/Tasty/Extras.hs index 6ac1fe43c7f..a69e0fc3d8d 100644 --- a/plutus-core/testlib/Test/Tasty/Extras.hs +++ b/plutus-core/testlib/Test/Tasty/Extras.hs @@ -34,7 +34,7 @@ module Test.Tasty.Extras , assertEqualPretty , (%=?) , (%?=) - , ignoreThisTestIfHpcIsEnabled + , ignoreTestWhenHpcEnabled ) where import PlutusPrelude hiding (toList) @@ -322,8 +322,8 @@ Some tests inspect GHC code, but GHC code gets instrumented when using HPC (Haskell Program Coverage), which causes those tests to fail. This function disables those tests when the custom __HPC_ENABLED__ flag is defined. -} -ignoreThisTestIfHpcIsEnabled :: TestTree -> TestTree -ignoreThisTestIfHpcIsEnabled t = +ignoreTestWhenHpcEnabled :: TestTree -> TestTree +ignoreTestWhenHpcEnabled t = #ifdef __HPC_ENABLED__ ignoreTest t #else diff --git a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs index 816bacc1912..cd4c28e0127 100644 --- a/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs +++ b/plutus-core/untyped-plutus-core/testlib/Evaluation/Builtins/Definition.hs @@ -1248,7 +1248,7 @@ test_definition = , test_SwapEls , test_IdBuiltinData , test_TrackCostsRestricting - , ignoreThisTestIfHpcIsEnabled test_TrackCostsRetaining + , ignoreTestWhenHpcEnabled test_TrackCostsRetaining , test_SerialiseDataImpossible , test_fixId , runTestNestedHere diff --git a/plutus-ledger-api/test/Spec/Data/Eval.hs b/plutus-ledger-api/test/Spec/Data/Eval.hs index 0f3db153f72..5457da3bfa1 100644 --- a/plutus-ledger-api/test/Spec/Data/Eval.hs +++ b/plutus-ledger-api/test/Spec/Data/Eval.hs @@ -32,7 +32,7 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty -import Test.Tasty.Extras (ignoreThisTestIfHpcIsEnabled) +import Test.Tasty.Extras (ignoreTestWhenHpcEnabled) import Test.Tasty.HUnit {- Note [Direct UPLC code] @@ -132,6 +132,6 @@ tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete - , ignoreThisTestIfHpcIsEnabled evaluationContextNoThunks + , ignoreTestWhenHpcEnabled evaluationContextNoThunks ] diff --git a/plutus-ledger-api/test/Spec/Eval.hs b/plutus-ledger-api/test/Spec/Eval.hs index 4c7caf767c3..f7148038e1d 100644 --- a/plutus-ledger-api/test/Spec/Eval.hs +++ b/plutus-ledger-api/test/Spec/Eval.hs @@ -32,7 +32,7 @@ import Data.Maybe (fromJust) import Data.Set qualified as Set import NoThunks.Class import Test.Tasty -import Test.Tasty.Extras (ignoreThisTestIfHpcIsEnabled) +import Test.Tasty.Extras (ignoreTestWhenHpcEnabled) import Test.Tasty.HUnit {- Note [Direct UPLC code] @@ -132,6 +132,6 @@ tests = testGroup "eval" [ testAPI -- , testUnlifting , evaluationContextCacheIsComplete - , ignoreThisTestIfHpcIsEnabled evaluationContextNoThunks + , ignoreTestWhenHpcEnabled evaluationContextNoThunks ]