Skip to content

Commit 71aa8b1

Browse files
committed
A QoL improvement for cabal test plutus-core --test-options=--accept
1 parent 0b2cee1 commit 71aa8b1

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

plutus-core/executables/traceToStacks/TestGetStacks.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{-# LANGUAGE OverloadedStrings #-}
22

33
import Common
4+
import System.Environment.IgnoreAccept
45
import Test.Tasty (defaultMain, testGroup)
56
import Test.Tasty.HUnit (testCase, (@?=))
67

@@ -76,7 +77,7 @@ kInyzInxStackVals = [
7677
]
7778

7879
main :: IO ()
79-
main = defaultMain $ testGroup "getStacks tests" [
80+
main = ignoreAcceptOption $ defaultMain $ testGroup "getStacks tests" [
8081
testCase "x only" (getStacks xEvent @?= xStackVal),
8182
testCase "x calls y calling z" (getStacks zInyInxEvent @?= zInyInxStackVals),
8283
testCase "x calls y and z" (getStacks yzInxEvent @?= yzInxStackVals),

plutus-core/flat/test/Big.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import PlutusCore.Flat (Decoded, Flat (..), flat, unflat, unflatWith)
1515
import PlutusCore.Flat.AsBin (AsBin, unbin)
1616
import PlutusCore.Flat.AsSize
1717
import PlutusCore.Flat.Decoder (Get, listTDecoder)
18+
import System.Environment.IgnoreAccept
1819
import System.TimeIt (timeIt)
1920

2021
-- Big is a type that has a small encoded representation but a very large in-memory footprint.
@@ -42,7 +43,7 @@ instance Flat Big where
4243
decode = newBig <$> decode
4344

4445
main :: IO ()
45-
main = tbig
46+
main = ignoreAcceptOption tbig
4647

4748
tbig = do
4849
let numOfBigs = 5

plutus-core/flat/test/Spec.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import PlutusCore.Flat.Encoder qualified as E
3333
import PlutusCore.Flat.Encoder.Prim qualified as E
3434
import PlutusCore.Flat.Encoder.Strict qualified as E
3535
import PlutusCore.Flat.Endian
36+
import System.Environment.IgnoreAccept
3637
import System.Exit
3738
import Test.Data
3839
import Test.Data.Arbitrary ()
@@ -87,7 +88,7 @@ mainShow = do
8788
mapM_ (\_ -> generate (arbitrary :: Gen Int) >>= print) [1 .. 10]
8889
exitFailure
8990

90-
mainTest = defaultMain tests
91+
mainTest = ignoreAcceptOption $ defaultMain tests
9192

9293
tests :: TestTree
9394
tests = testGroup "Tests" [testPrimitives, testEncDec, testFlat]
@@ -794,7 +795,3 @@ prop_common_unsigned n _ = let n2 :: h = fromIntegral n
794795
-- b1 :: BLOB UTF8
795796
-- b1 = BLOB UTF8 (preAligned (List255 [97,98,99]))
796797
-- -- b1 = BLOB (preAligned (UTF8 (List255 [97,98,99])))
797-
798-
799-
800-

plutus-core/index-envs/test/Spec.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ module Main
33
) where
44

55
import RAList.Spec qualified as RAList
6+
import System.Environment.IgnoreAccept
67
import Test.Tasty
78

89
main :: IO ()
9-
main = defaultMain RAList.tests
10+
main = ignoreAcceptOption $ defaultMain RAList.tests

plutus-core/plutus-core.cabal

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ library plutus-core-testlib
811811
PlutusIR.Generators.QuickCheck.ShrinkTerms
812812
PlutusIR.Pass.Test
813813
PlutusIR.Test
814+
System.Environment.IgnoreAccept
814815
Test.Tasty.Extras
815816
UntypedPlutusCore.Generators.Hedgehog.AST
816817
UntypedPlutusCore.Test.DeBruijn.Bad
@@ -905,6 +906,7 @@ test-suite traceToStacks-test
905906
, base >=4.9 && <5
906907
, bytestring
907908
, cassava
909+
, plutus-core:plutus-core-testlib
908910
, tasty
909911
, tasty-hunit
910912
, text
@@ -1080,6 +1082,7 @@ test-suite satint-test
10801082
, base >=4.9 && <5
10811083
, HUnit
10821084
, QuickCheck
1085+
, plutus-core:plutus-core-testlib
10831086
, satint
10841087
, test-framework
10851088
, test-framework-hunit
@@ -1136,9 +1139,10 @@ test-suite index-envs-test
11361139
ghc-options: -threaded -rtsopts -with-rtsopts=-N
11371140
build-depends:
11381141
, base >=4.9 && <5
1142+
, QuickCheck
11391143
, index-envs
11401144
, nonempty-vector
1141-
, QuickCheck
1145+
, plutus-core:plutus-core-testlib
11421146
, quickcheck-instances
11431147
, tasty
11441148
, tasty-quickcheck
@@ -1241,11 +1245,12 @@ test-suite flat-test
12411245

12421246
build-depends:
12431247
, base
1248+
, QuickCheck
12441249
, bytestring
12451250
, containers
12461251
, deepseq
12471252
, plutus-core:flat
1248-
, QuickCheck
1253+
, plutus-core:plutus-core-testlib
12491254
, quickcheck-text
12501255
, tasty
12511256
, tasty-hunit
@@ -1268,4 +1273,5 @@ test-suite flat-big-test
12681273
, bytestring
12691274
, list-t
12701275
, plutus-core:flat
1276+
, plutus-core:plutus-core-testlib
12711277
, timeit

plutus-core/satint/test/TestSatInt.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
-- in safeint, since I want to upstream this in due course.
77
module Main where
88

9+
import System.Environment.IgnoreAccept
910
import Control.Exception as E
1011
import Data.List
1112
import Data.Maybe
@@ -17,7 +18,7 @@ import Test.HUnit as T
1718
import Test.QuickCheck
1819

1920
main :: IO ()
20-
main = defaultMain tests
21+
main = ignoreAcceptOption $ defaultMain tests
2122

2223
isArithException :: a -> IO Bool
2324
isArithException n = E.catch (n `seq` return False)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module System.Environment.IgnoreAccept (ignoreAcceptOption) where
2+
3+
import System.Environment
4+
import Data.List
5+
6+
-- | Ignores options like --accept and --accept=True from argv
7+
ignoreAcceptOption :: IO a -> IO a
8+
ignoreAcceptOption m = do
9+
args <- getArgs
10+
withArgs (filter (not . isPrefixOf "--accept") args) m

0 commit comments

Comments
 (0)