Skip to content

Commit 09d111b

Browse files
committed
wip
1 parent f6cb080 commit 09d111b

File tree

7 files changed

+31
-29
lines changed

7 files changed

+31
-29
lines changed

cardano-constitution/test/Cardano/Constitution/Validator/GoldenTests.hs

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Data.Maybe
2222
import Data.String
2323
import System.FilePath
2424
import Test.Tasty
25+
import Test.Tasty.Extras (ignoreTestIfHpcEnabled)
2526
import Test.Tasty.Golden
2627

2728
import Helpers.Guardrail
@@ -67,11 +68,11 @@ test_readable_uplc = testGroup "ReadableUplc" $ M.elems $
6768

6869
tests :: TestTreeWithTestState
6970
tests = testGroup' "Golden" $ fmap const
70-
[ test_cbor
71-
, test_budget_large
72-
, test_budget_small
71+
[ ignoreTestIfHpcEnabled test_cbor
72+
, ignoreTestIfHpcEnabled test_budget_large
73+
, ignoreTestIfHpcEnabled test_budget_small
7374
, test_readable_pir
74-
, test_readable_uplc
75+
, ignoreTestIfHpcEnabled test_readable_uplc
7576
]
7677

7778
-- HELPERS

nix/project.nix

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ let
2828
packages.plutus-core.doCoverage = true;
2929
packages.plutus-executables.doCoverage = true;
3030
packages.plutus-tx-test-util.doCoverage = true;
31-
# packages.plutus-ledger-api.doCoverage = true;
31+
packages.plutus-ledger-api.doCoverage = true;
3232

33-
packages.plutus-core.configureFlags = [ "--ghc-option=-D__USING_HPC__" ];
34-
packages.plutus-ledger-api.configureFlags = [ "--ghc-option=-D__USING_HPC__" ];
33+
packages.plutus-core.configureFlags = [ "--ghc-option=-D__HPC_ENABLED__" ];
34+
packages.plutus-ledger-api.configureFlags = [ "--ghc-option=-D__HPC_ENABLED__" ];
3535
}];
3636
ghc810.compiler-nix-name = "ghc810";
3737
ghc98.compiler-nix-name = "ghc98";

plutus-core/plutus-core.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ test-suite untyped-plutus-core-test
465465
, serialise
466466
, split
467467
, tasty
468-
, tasty-expected-failure
469468
, tasty-golden
470469
, tasty-hedgehog
471470
, tasty-hunit
@@ -820,6 +819,7 @@ library plutus-core-testlib
820819
, Stream
821820
, tagged
822821
, tasty
822+
, tasty-expected-failure
823823
, tasty-golden
824824
, tasty-hedgehog
825825
, tasty-hunit

plutus-core/testlib/Test/Tasty/Extras.hs

+16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE BlockArguments #-}
2+
{-# LANGUAGE CPP #-}
23
{-# LANGUAGE FlexibleInstances #-}
34
{-# LANGUAGE MultiParamTypeClasses #-}
45
{-# LANGUAGE OverloadedStrings #-}
@@ -33,6 +34,7 @@ module Test.Tasty.Extras
3334
, assertEqualPretty
3435
, (%=?)
3536
, (%?=)
37+
, ignoreTestIfHpcEnabled
3638
) where
3739

3840
import PlutusPrelude hiding (toList)
@@ -51,6 +53,7 @@ import GHC.Stack (HasCallStack)
5153
import System.FilePath (joinPath, (</>))
5254
import System.Info (compilerVersion)
5355
import Test.Tasty (TestName, TestTree, testGroup)
56+
import Test.Tasty.ExpectedFailure (ignoreTest)
5457
import Test.Tasty.Golden (createDirectoriesAndWriteFile, goldenVsStringDiff)
5558
import Test.Tasty.Golden.Advanced (goldenTest)
5659
import Test.Tasty.HUnit (Assertion, assertFailure)
@@ -313,3 +316,16 @@ expected %=? actual = assertEqualPretty "" expected actual
313316
-- ^ The expected value
314317
-> Assertion
315318
actual %?= expected = assertEqualPretty "" expected actual
319+
320+
{-|
321+
Some tests inspect GHC code, but GHC code gets instrumented when using hpc.
322+
This flag disables those tests when the custom __HPC_ENABLED__ flag is defined.
323+
-}
324+
ignoreTestIfHpcEnabled :: TestTree -> TestTree
325+
ignoreTestIfHpcEnabled t =
326+
#ifdef __HPC_ENABLED__
327+
ignoreTest t
328+
#else
329+
let _preventsUnusedBindsWarnings = ignoreTest t
330+
in t
331+
#endif

plutus-core/untyped-plutus-core/test/Evaluation/Builtins/Definition.hs

+3-9
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ import Hedgehog.Gen qualified as Gen
7272
import Hedgehog.Range qualified as Range
7373
import Prettyprinter (vsep)
7474
import Test.Tasty (TestTree, testGroup)
75-
#ifdef __USING_HPC__
76-
import Test.Tasty.ExpectedFailure (ignoreTest)
77-
#endif
75+
import Test.Tasty.Extras (ignoreTestIfHpcEnabled)
7876
import Test.Tasty.Hedgehog (testPropertyNamed)
7977
import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase, (@=?), (@?=))
8078
import Test.Tasty.QuickCheck qualified as QC
@@ -502,7 +500,7 @@ test_TrackCostsRestricting =
502500

503501
test_TrackCostsRetaining :: TestTree
504502
test_TrackCostsRetaining =
505-
#if MIN_VERSION_base(4,15,0) && !defined(__USING_HPC__)
503+
#if MIN_VERSION_base(4,15,0)
506504
test_TrackCostsWith "retaining" 10000 $ \term -> do
507505
let -- An 'ExBudgetMode' that retains all the individual budgets by sticking them into a
508506
-- 'DList'.
@@ -1251,11 +1249,7 @@ test_definition =
12511249
, test_SwapEls
12521250
, test_IdBuiltinData
12531251
, test_TrackCostsRestricting
1254-
#ifdef __USING_HPC__
1255-
, ignoreTest test_TrackCostsRetaining
1256-
#else
1257-
, test_TrackCostsRetaining
1258-
#endif
1252+
, ignoreTestIfHpcEnabled test_TrackCostsRetaining
12591253
, test_SerialiseDataImpossible
12601254
, test_fixId
12611255
, runTestNestedHere

plutus-ledger-api/test/Spec/Data/Eval.hs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
-- editorconfig-checker-disable-file
22
-- TODO: merge this module to Versions.hs ?
33
{-# LANGUAGE BangPatterns #-}
4-
{-# LANGUAGE CPP #-}
54
{-# LANGUAGE TypeApplications #-}
65
{-# LANGUAGE TypeFamilies #-}
76
module Spec.Data.Eval (tests) where
@@ -33,10 +32,8 @@ import Data.Maybe (fromJust)
3332
import Data.Set qualified as Set
3433
import NoThunks.Class
3534
import Test.Tasty
36-
#ifdef __USING_HPC__
3735
import Test.Tasty.ExpectedFailure (ignoreTest)
38-
#endif
39-
import Test.Tasty.HUnit
36+
import Test.Tasty.Extras (ignoreTestIfHpcEnabled)
4037

4138
{- Note [Direct UPLC code]
4239
For this test-suite we write the programs directly in the UPLC AST,

plutus-ledger-api/test/Spec/Eval.hs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
-- editorconfig-checker-disable-file
22
-- TODO: merge this module to Versions.hs ?
33
{-# LANGUAGE BangPatterns #-}
4-
{-# LANGUAGE CPP #-}
54
{-# LANGUAGE TypeApplications #-}
65
{-# LANGUAGE TypeFamilies #-}
76
module Spec.Eval (tests) where
@@ -33,9 +32,7 @@ import Data.Maybe (fromJust)
3332
import Data.Set qualified as Set
3433
import NoThunks.Class
3534
import Test.Tasty
36-
#ifdef __USING_HPC__
37-
import Test.Tasty.ExpectedFailure (ignoreTest)
38-
#endif
35+
import Test.Tasty.Extras (ignoreTestIfHpcEnabled)
3936
import Test.Tasty.HUnit
4037

4138
{- Note [Direct UPLC code]
@@ -135,10 +132,7 @@ tests = testGroup "eval"
135132
[ testAPI
136133
-- , testUnlifting
137134
, evaluationContextCacheIsComplete
138-
#ifdef __USING_HPC__
139-
, ignoreTest evaluationContextNoThunks
140-
#else
135+
, ignoreTestIfHpcFlagDefined evaluationContextNoThunks
141136
, evaluationContextNoThunks
142-
#endif
143137
]
144138

0 commit comments

Comments
 (0)