-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cardano-tesnet: allow to specify output directory #6095
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,3 +1,5 @@ | ||||||
{-# LANGUAGE NamedFieldPuns #-} | ||||||
|
||||||
module Testnet.Property.Run | ||||||
( runTestnet | ||||||
-- Ignore tests on various OSs | ||||||
|
@@ -19,11 +21,13 @@ import Data.Bool (bool) | |||||
import Data.String (IsString (..)) | ||||||
import qualified System.Console.ANSI as ANSI | ||||||
import System.Console.ANSI (Color (..), ColorIntensity (..), ConsoleLayer (..), SGR (..)) | ||||||
import System.Directory | ||||||
import qualified System.Exit as IO | ||||||
import qualified System.Info as SYS | ||||||
import qualified System.IO as IO | ||||||
|
||||||
import Testnet.Property.Util (integrationWorkspace) | ||||||
import Testnet.Filepath | ||||||
import Testnet.Property.Util (integration, integrationWorkspace) | ||||||
import Testnet.Start.Types | ||||||
|
||||||
import Hedgehog (Property) | ||||||
|
@@ -35,11 +39,11 @@ import qualified Test.Tasty.Hedgehog as H | |||||
import Test.Tasty.Providers (testPassed) | ||||||
import Test.Tasty.Runners (Result (resultShortDescription), TestTree) | ||||||
|
||||||
runTestnet :: (Conf -> H.Integration a) -> IO () | ||||||
runTestnet tn = do | ||||||
runTestnet :: CardanoTestnetOptions -> (Conf -> H.Integration a) -> IO () | ||||||
runTestnet tnOpts tn = do | ||||||
tvRunning <- STM.newTVarIO False | ||||||
|
||||||
void . H.check $ testnetProperty $ \c -> do | ||||||
void . H.check $ testnetProperty tnOpts $ \c -> do | ||||||
void $ tn c | ||||||
H.evalIO . STM.atomically $ STM.writeTVar tvRunning True | ||||||
|
||||||
|
@@ -60,17 +64,29 @@ runTestnet tn = do | |||||
IO.exitFailure | ||||||
|
||||||
|
||||||
testnetProperty :: (Conf -> H.Integration ()) -> H.Property | ||||||
testnetProperty tn = integrationWorkspace "testnet" $ \workspaceDir -> do | ||||||
conf <- mkConf workspaceDir | ||||||
|
||||||
-- Fork a thread to keep alive indefinitely any resources allocated by testnet. | ||||||
void . H.evalM . liftResourceT . resourceForkIO . forever . liftIO $ IO.threadDelay 10000000 | ||||||
|
||||||
void $ tn conf | ||||||
|
||||||
H.failure -- Intentional failure to force failure report | ||||||
|
||||||
testnetProperty :: CardanoTestnetOptions -> (Conf -> H.Integration ()) -> H.Property | ||||||
testnetProperty CardanoTestnetOptions{cardanoOutputDir} tn = | ||||||
case cardanoOutputDir of | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be more readable if the |
||||||
Nothing -> do | ||||||
integrationWorkspace "testnet" $ \workspaceDir -> do | ||||||
mkConf workspaceDir >>= go | ||||||
Just userOutputDir -> | ||||||
integration $ do | ||||||
absUserOutputDir <- H.evalIO $ makeAbsolute userOutputDir | ||||||
dirExists <- H.evalIO $ doesDirectoryExist absUserOutputDir | ||||||
(if dirExists then | ||||||
-- Likely dangerous, but who are we to judge the user? | ||||||
H.note_ $ "Reusing " <> absUserOutputDir | ||||||
else do | ||||||
liftIO $ createDirectory absUserOutputDir | ||||||
H.note_ $ "Created " <> absUserOutputDir) | ||||||
go $ Conf $ TmpAbsolutePath absUserOutputDir | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, you should use
Suggested change
I think the whole |
||||||
where | ||||||
go conf = do | ||||||
-- Fork a thread to keep alive indefinitely any resources allocated by testnet. | ||||||
void $ H.evalM . liftResourceT . resourceForkIO . forever . liftIO $ IO.threadDelay 10000000 | ||||||
void $ tn conf | ||||||
H.failure -- Intentional failure to force failure report | ||||||
|
||||||
-- Ignore properties on various OSs | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a little wtf moment, what does tn mean