Skip to content

Commit

Permalink
Run each anoma compilation test in a separate temp dir
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcadman committed Feb 20, 2024
1 parent e6734d1 commit c11d971
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions test/Anoma/Compilation/Positive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,26 @@ mkAnomaCallTest' :: Bool -> Text -> Prelude.Path Rel Dir -> Prelude.Path Rel Fil
mkAnomaCallTest' enableDebug _testName relRoot mainFile args _testCheck =
testCase (unpack _testName) (mkTestIO >>= mkNockmaAssertion)
where
rootDir' :: Prelude.Path Abs Dir
rootDir' = root <//> relRoot

mkTestIO :: IO Test
mkTestIO = do
entryPoint <- set entryPointTarget TargetAnoma . set entryPointDebug enableDebug <$> testDefaultEntryPointIO rootDir' (rootDir' <//> mainFile)
_testProgramSubject <- (^. pipelineResult) . snd <$> testRunIO entryPoint upToAnoma
_testProgramSubject <- withRootCopy compileMain
let _testProgramFormula = anomaCall args
_testEvalOptions = defaultEvalOptions
return Test {..}

withRootCopy :: (Prelude.Path Abs Dir -> IO a) -> IO a
withRootCopy action = withSystemTempDir "test" $ \tmpRootDir -> do
copyDirRecur root tmpRootDir
action tmpRootDir

compileMain :: Prelude.Path Abs Dir -> IO (Term Natural)
compileMain rootCopyDir = do
let testRootDir = rootCopyDir <//> relRoot
entryPoint <-
set entryPointTarget TargetAnoma . set entryPointDebug enableDebug
<$> testDefaultEntryPointIO testRootDir (testRootDir <//> mainFile)
(^. pipelineResult) . snd <$> testRunIO entryPoint upToAnoma

mkAnomaCallTestNoTrace :: Text -> Prelude.Path Rel Dir -> Prelude.Path Rel File -> [Term Natural] -> Check () -> TestTree
mkAnomaCallTestNoTrace = mkAnomaCallTest' False

Expand Down

0 comments on commit c11d971

Please sign in to comment.