Skip to content

Commit 80141e8

Browse files
committed
wip
1 parent 52442da commit 80141e8

File tree

8 files changed

+88
-59
lines changed

8 files changed

+88
-59
lines changed

cardano-constitution/test/Cardano/Constitution/Validator/Data/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

+11-3
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,27 @@ let
1919
enableLibraryProfiling = true;
2020
}];
2121
ghc96-coverage.modules = [{
22-
2322
# NOTE: Enabling coverage for some packages breaks tests due to HPC
2423
# (Haskell Program Coverage) instrumentation. The packages listed
2524
# below represent the largest subset that can be enabled without
2625
# breaking tests.
26+
# packages.cardano-constitution.doCoverage = true;
2727
packages.plutus-conformance.doCoverage = true;
2828
packages.plutus-core.doCoverage = true;
2929
packages.plutus-executables.doCoverage = true;
3030
packages.plutus-tx-test-util.doCoverage = true;
3131
packages.plutus-ledger-api.doCoverage = true;
32-
3332
packages.plutus-core.configureFlags = [ "--ghc-option=-D__HPC_ENABLED__" ];
34-
packages.plutus-ledger-api.configureFlags = [ "--ghc-option=-D__HPC_ENABLED__" ];
33+
# plutus-benchmark
34+
# plutus-conformance
35+
# plutus-core
36+
# plutus-executables
37+
# plutus-ledger-api
38+
# plutus-metatheory
39+
# plutus-tx
40+
# plutus-tx-plugin
41+
# plutus-tx-test-util
42+
# docusaurus-examples
3543
}];
3644
ghc810.compiler-nix-name = "ghc810";
3745
ghc98.compiler-nix-name = "ghc98";

plutus-benchmark/marlowe/test/Spec.hs

+17-15
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import PlutusLedgerApi.V3 (ExCPU (..), ExMemory (..))
1919
import System.FilePath ((</>))
2020
import System.IO (hPutStrLn)
2121
import Test.Tasty (defaultMain, testGroup)
22+
import Test.Tasty.Extras (ignoreTestIfHpcEnabled)
2223
import UntypedPlutusCore.Size qualified as UPLC
2324

2425
main :: IO ()
@@ -65,19 +66,20 @@ main = withUtf8 $ do
6566
Lib.measureProgram
6667
[benchmarkToUPLC Data.rolePayoutValidator bench | bench <- rolePayout]
6768

69+
let marloweTests = testGroup "Marlowe"
70+
[ Lib.goldenUplcMeasurements "budgets" goldenFile actualFile \writeHandle ->
71+
for_
72+
(semanticsMeasures <> rolePayoutMeasures)
73+
\(ExCPU cpu, ExMemory mem, UPLC.Size size) ->
74+
hPutStrLn writeHandle $
75+
List.intercalate "\t" [show cpu, show mem, show size]
76+
, Lib.goldenUplcMeasurements "data-budgets" goldenFileData actualFileData \writeHandle ->
77+
for_
78+
(dataSemanticsMeasures <> dataRolePayoutMeasures)
79+
\(ExCPU cpu, ExMemory mem, UPLC.Size size) ->
80+
hPutStrLn writeHandle $
81+
List.intercalate "\t" [show cpu, show mem, show size]
82+
]
83+
6884
-- Write the measures to the actual file
69-
defaultMain
70-
$ testGroup "Marlowe"
71-
[ Lib.goldenUplcMeasurements "budgets" goldenFile actualFile \writeHandle ->
72-
for_
73-
(semanticsMeasures <> rolePayoutMeasures)
74-
\(ExCPU cpu, ExMemory mem, UPLC.Size size) ->
75-
hPutStrLn writeHandle $
76-
List.intercalate "\t" [show cpu, show mem, show size]
77-
, Lib.goldenUplcMeasurements "data-budgets" goldenFileData actualFileData \writeHandle ->
78-
for_
79-
(dataSemanticsMeasures <> dataRolePayoutMeasures)
80-
\(ExCPU cpu, ExMemory mem, UPLC.Size size) ->
81-
hPutStrLn writeHandle $
82-
List.intercalate "\t" [show cpu, show mem, show size]
83-
]
85+
defaultMain $ ignoreTestIfHpcEnabled marloweTests

plutus-benchmark/script-contexts/test/V1/Spec.hs

+21-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module V1.Spec (allTests) where
55
import Data.Text qualified as Text
66

77
import Test.Tasty
8-
import Test.Tasty.Extras (TestNested, runTestNested, testNestedGhc)
8+
import Test.Tasty.Extras (TestNested, ignoreTestIfHpcEnabled, runTestNested, testNestedGhc)
99
import Test.Tasty.HUnit
1010

1111
import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek)
@@ -47,7 +47,10 @@ testCheckSOPSc1 = testGroup "checkScriptContext1"
4747
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4)
4848
, testCase "fails on 5" . assertFailed $
4949
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5)
50-
, runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $
50+
, ignoreTestIfHpcEnabled $
51+
runTestGhcSOP
52+
[
53+
Tx.goldenSize "checkScriptContext1" $
5154
SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1)
5255
, Tx.goldenPirReadable "checkScriptContext1" $
5356
SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1)
@@ -59,7 +62,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1"
5962
SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20)
6063
, Tx.goldenEvalCekCatch "checkScriptContext1-20" $
6164
[SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20)]
62-
]
65+
]
6366
]
6467

6568
testCheckDataSc1 :: TestTree
@@ -89,19 +92,21 @@ testCheckSOPSc2 = testGroup "checkScriptContext2"
8992
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4)
9093
, testCase "succeed on 5" . assertSucceeded $
9194
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5)
92-
, runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $
93-
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1)
94-
, Tx.goldenPirReadable "checkScriptContext2" $
95-
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1)
96-
, Tx.goldenBudget "checkScriptContext2-4" $
97-
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4)
98-
, Tx.goldenEvalCekCatch "checkScriptContext2-4" $
99-
[SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4)]
100-
, Tx.goldenBudget "checkScriptContext2-20" $
101-
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)
102-
, Tx.goldenEvalCekCatch "checkScriptContext2-20" $
103-
[SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)]
104-
]
95+
, ignoreTestIfHpcEnabled $
96+
runTestGhcSOP
97+
[ Tx.goldenSize "checkScriptContext2" $
98+
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1)
99+
, Tx.goldenPirReadable "checkScriptContext2" $
100+
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1)
101+
, Tx.goldenBudget "checkScriptContext2-4" $
102+
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4)
103+
, Tx.goldenEvalCekCatch "checkScriptContext2-4" $
104+
[SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4)]
105+
, Tx.goldenBudget "checkScriptContext2-20" $
106+
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)
107+
, Tx.goldenEvalCekCatch "checkScriptContext2-20" $
108+
[SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)]
109+
]
105110
]
106111

107112
testCheckDataSc2 :: TestTree

plutus-benchmark/script-contexts/test/V2/Spec.hs

+19-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module V2.Spec (allTests) where
77
import Data.Text qualified as Text
88

99
import Test.Tasty
10-
import Test.Tasty.Extras (TestNested, runTestNested, testNestedGhc)
10+
import Test.Tasty.Extras (TestNested, ignoreTestIfHpcEnabled, runTestNested, testNestedGhc)
1111
import Test.Tasty.HUnit
1212

1313
import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek)
@@ -51,7 +51,10 @@ testCheckSOPSc1 = testGroup "checkScriptContext1"
5151
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4)
5252
, testCase "fails on 5" . assertFailed $
5353
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5)
54-
, runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $
54+
, ignoreTestIfHpcEnabled $
55+
runTestGhcSOP
56+
[
57+
Tx.goldenSize "checkScriptContext1" $
5558
SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1)
5659
, Tx.goldenPirReadable "checkScriptContext1" $
5760
SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1)
@@ -63,7 +66,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1"
6366
SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20)
6467
, Tx.goldenEvalCekCatch "checkScriptContext1-20" $
6568
[SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20)]
66-
]
69+
]
6770
]
6871

6972
testCheckDataSc1 :: TestTree
@@ -93,7 +96,10 @@ testCheckSOPSc2 = testGroup "checkScriptContext2"
9396
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4)
9497
, testCase "succeed on 5" . assertSucceeded $
9598
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5)
96-
, runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $
99+
, ignoreTestIfHpcEnabled $
100+
runTestGhcSOP
101+
[
102+
Tx.goldenSize "checkScriptContext2" $
97103
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1)
98104
, Tx.goldenPirReadable "checkScriptContext2" $
99105
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1)
@@ -105,7 +111,7 @@ testCheckSOPSc2 = testGroup "checkScriptContext2"
105111
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)
106112
, Tx.goldenEvalCekCatch "checkScriptContext2-20" $
107113
[SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)]
108-
]
114+
]
109115
]
110116

111117
testCheckDataSc2 :: TestTree
@@ -157,13 +163,14 @@ testCheckDataScEquality = testGroup "checkScriptContextEquality"
157163

158164
testSOPFwdStakeTrick :: TestTree
159165
testSOPFwdStakeTrick =
160-
runTestGhcSOP
161-
[ Tx.goldenSize "sopFwdStakeTrick" testCode
162-
, Tx.goldenPirReadable "sopFwdStakeTrick" testAbsCode
163-
, Tx.goldenUPlcReadable "sopFwdStakeTrick" testAbsCode
164-
, Tx.goldenBudget "sopFwdStakeTrick" testCode
165-
, Tx.goldenEvalCekCatch "sopFwdStakeTrick" [testCode]
166-
]
166+
ignoreTestIfHpcEnabled $
167+
runTestGhcSOP
168+
[ Tx.goldenSize "sopFwdStakeTrick" testCode
169+
, Tx.goldenPirReadable "sopFwdStakeTrick" testAbsCode
170+
, Tx.goldenUPlcReadable "sopFwdStakeTrick" testAbsCode
171+
, Tx.goldenBudget "sopFwdStakeTrick" testCode
172+
, Tx.goldenEvalCekCatch "sopFwdStakeTrick" [testCode]
173+
]
167174
where
168175
testCredential =
169176
SOP.SC.mkStakingCredential "someCredential"

plutus-benchmark/script-contexts/test/V3/Spec.hs

+11-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module V3.Spec (allTests) where
55
import Data.Text qualified as Text
66

77
import Test.Tasty
8-
import Test.Tasty.Extras (TestNested, runTestNested, testNestedGhc)
8+
import Test.Tasty.Extras (TestNested, ignoreTestIfHpcEnabled, runTestNested, testNestedGhc)
99
import Test.Tasty.HUnit
1010

1111
import PlutusBenchmark.Common (Term, compiledCodeToTerm, runTermCek, unsafeRunTermCek)
@@ -47,7 +47,10 @@ testCheckSOPSc1 = testGroup "checkScriptContext1"
4747
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 4)
4848
, testCase "fails on 5" . assertFailed $
4949
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 5)
50-
, runTestGhcSOP [ Tx.goldenSize "checkScriptContext1" $
50+
, ignoreTestIfHpcEnabled $
51+
runTestGhcSOP
52+
[
53+
Tx.goldenSize "checkScriptContext1" $
5154
SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1)
5255
, Tx.goldenPirReadable "checkScriptContext1" $
5356
SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 1)
@@ -59,7 +62,7 @@ testCheckSOPSc1 = testGroup "checkScriptContext1"
5962
SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20)
6063
, Tx.goldenEvalCekCatch "checkScriptContext1-20" $
6164
[SOP.SC.mkCheckScriptContext1Code (SOP.SC.mkScriptContext 20)]
62-
]
65+
]
6366
]
6467

6568
testCheckDataSc1 :: TestTree
@@ -89,7 +92,9 @@ testCheckSOPSc2 = testGroup "checkScriptContext2"
8992
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 4)
9093
, testCase "succeed on 5" . assertSucceeded $
9194
compiledCodeToTerm $ SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 5)
92-
, runTestGhcSOP [ Tx.goldenSize "checkScriptContext2" $
95+
, ignoreTestIfHpcEnabled $
96+
runTestGhcSOP
97+
[ Tx.goldenSize "checkScriptContext2" $
9398
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1)
9499
, Tx.goldenPirReadable "checkScriptContext2" $
95100
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 1)
@@ -101,7 +106,7 @@ testCheckSOPSc2 = testGroup "checkScriptContext2"
101106
SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)
102107
, Tx.goldenEvalCekCatch "checkScriptContext2-20" $
103108
[SOP.SC.mkCheckScriptContext2Code (SOP.SC.mkScriptContext 20)]
104-
]
109+
]
105110
]
106111

107112
testCheckDataSc2 :: TestTree
@@ -152,7 +157,7 @@ testCheckDataScEquality = testGroup "checkScriptContextEquality"
152157
]
153158

154159
testPurposeIsWellFormed :: TestTree
155-
testPurposeIsWellFormed = testGroup "purposeIsWellFormed"
160+
testPurposeIsWellFormed = ignoreTestIfHpcEnabled $ testGroup "purposeIsWellFormed"
156161
[ runTestGhcData [ Tx.goldenPirReadable "purposeIsWellFormed" $
157162
Data.SC.compiledPurposeIsWellFormed
158163
, Tx.goldenSize "purposeIsWellFormed" $

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ expected %=? actual = assertEqualPretty "" expected actual
318318
actual %?= expected = assertEqualPretty "" expected actual
319319

320320
{-|
321-
Some tests inspect GHC code, but GHC code gets instrumented when using hpc.
321+
Some tests inspect GHC code, but GHC code gets instrumented when using HPC
322+
(Haskell Program Coverage), which causes those tests to fail.
322323
This flag disables those tests when the custom __HPC_ENABLED__ flag is defined.
323324
-}
324325
ignoreTestIfHpcEnabled :: TestTree -> TestTree

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +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-
import Test.Tasty.Extras (ignoreTestIfHpcEnabled)
75+
import Test.Tasty.Extras qualified as TE
7676
import Test.Tasty.Hedgehog (testPropertyNamed)
7777
import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase, (@=?), (@?=))
7878
import Test.Tasty.QuickCheck qualified as QC
@@ -1249,7 +1249,7 @@ test_definition =
12491249
, test_SwapEls
12501250
, test_IdBuiltinData
12511251
, test_TrackCostsRestricting
1252-
, ignoreTestIfHpcEnabled test_TrackCostsRetaining
1252+
, TE.ignoreTestIfHpcEnabled test_TrackCostsRetaining
12531253
, test_SerialiseDataImpossible
12541254
, test_fixId
12551255
, runTestNestedHere

0 commit comments

Comments
 (0)