Skip to content

Commit

Permalink
Remove duplicate function used by tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcadman committed Nov 16, 2023
1 parent e6dca22 commit ef9dd6b
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 16 deletions.
3 changes: 0 additions & 3 deletions src/Juvix/Compiler/Pipeline/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ runIO opts entry = runIOEither entry >=> mayThrow
Left err -> runM . runReader opts $ printErrorAnsiSafe err >> embed exitFailure
Right r -> return r

runIO' :: EntryPoint -> Sem PipelineEff a -> IO (ResolverState, a)
runIO' = runIOLockMode LockModeExclusive defaultGenericOptions

runIOExclusive :: EntryPoint -> Sem PipelineEff a -> IO (ResolverState, a)
runIOExclusive = runIOLockMode LockModeExclusive defaultGenericOptions

Expand Down
2 changes: 1 addition & 1 deletion test/BackendGeb/Compilation/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ gebCompilationAssertion ::
gebCompilationAssertion root mainFile expectedFile step = do
step "Translate to JuvixCore"
entryPoint <- set entryPointTarget TargetGeb <$> defaultEntryPointIO' LockModeExclusive root mainFile
tab <- (^. Core.coreResultTable) . snd <$> runIO' entryPoint upToCore
tab <- (^. Core.coreResultTable) . snd <$> runIOExclusive entryPoint upToCore
coreToGebTranslationAssertion' tab entryPoint expectedFile step
2 changes: 1 addition & 1 deletion test/Compilation/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ compileErrorAssertion ::
compileErrorAssertion root' mainFile step = do
step "Translate to JuvixCore"
entryPoint <- defaultEntryPointIO' LockModeExclusive root' mainFile
tab <- (^. Core.coreResultTable) . snd <$> runIO' entryPoint upToCore
tab <- (^. Core.coreResultTable) . snd <$> runIOExclusive entryPoint upToCore
case run $ runReader Core.defaultCoreOptions $ runError @JuvixError $ Core.toStripped' tab of
Left _ -> assertBool "" True
Right _ -> assertFailure "no error"
4 changes: 2 additions & 2 deletions test/Format.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ testDescr PosTest {..} =
original :: Text <- readFile (toFilePath f)

step "Parsing"
p :: Parser.ParserResult <- snd <$> runIO' entryPoint upToParsing
p :: Parser.ParserResult <- snd <$> runIOExclusive entryPoint upToParsing

step "Scoping"
s :: Scoper.ScoperResult <-
snd
<$> runIO'
<$> runIOExclusive
entryPoint
( do
void (entrySetup defaultDependenciesConfig)
Expand Down
2 changes: 1 addition & 1 deletion test/Internal/Eval/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internalCoreAssertion :: Path Abs Dir -> Path Abs File -> Path Abs File -> (Stri
internalCoreAssertion root' mainFile expectedFile step = do
step "Translate to Core"
entryPoint <- defaultEntryPointIO' LockModeExclusive root' mainFile
tab0 <- (^. Core.coreResultTable) . snd <$> runIO' entryPoint upToCore
tab0 <- (^. Core.coreResultTable) . snd <$> runIOExclusive entryPoint upToCore
let tab = etaExpansionApps tab0
case (tab ^. infoMain) >>= ((tab ^. identContext) HashMap.!?) of
Just node -> do
Expand Down
4 changes: 2 additions & 2 deletions test/Markdown.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ testDescr PosTest {..} =
_testAssertion = Steps $ \step -> do
entryPoint <- defaultEntryPointIO' LockModeExclusive _dir _file
step "Parsing"
p :: Parser.ParserResult <- snd <$> runIO' entryPoint upToParsing
p :: Parser.ParserResult <- snd <$> runIOExclusive entryPoint upToParsing
step "Scoping"
s :: Scoper.ScoperResult <-
snd
<$> runIO'
<$> runIOExclusive
entryPoint
( do
void (entrySetup defaultDependenciesConfig)
Expand Down
2 changes: 1 addition & 1 deletion test/Reachability/Positive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ testDescr PosTest {..} =
<$> defaultEntryPointIO' LockModeExclusive tRoot file'

step "Pipeline up to reachability"
p :: Internal.InternalTypedResult <- snd <$> runIO' entryPoint upToInternalReachability
p :: Internal.InternalTypedResult <- snd <$> runIOExclusive entryPoint upToInternalReachability

step "Check reachability results"
let names = concatMap getNames (p ^. Internal.resultModules)
Expand Down
4 changes: 2 additions & 2 deletions test/Termination/Positive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ testDescr PosTest {..} =
_testRoot = tRoot,
_testAssertion = Single $ do
entryPoint <- set entryPointNoStdlib True <$> defaultEntryPointIO' LockModeExclusive tRoot file'
(void . runIO' entryPoint) upToInternalTyped
(void . runIOExclusive entryPoint) upToInternalTyped
}

--------------------------------------------------------------------------------
Expand All @@ -44,7 +44,7 @@ testDescrFlag N.NegTest {..} =
set entryPointNoTermination True
. set entryPointNoStdlib True
<$> defaultEntryPointIO' LockModeExclusive tRoot file'
(void . runIO' entryPoint) upToInternalTyped
(void . runIOExclusive entryPoint) upToInternalTyped
}

tests :: [PosTest]
Expand Down
4 changes: 2 additions & 2 deletions test/Typecheck/Positive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ testDescr PosTest {..} =
_testRoot = _dir,
_testAssertion = Single $ do
entryPoint <- defaultEntryPointIO' LockModeExclusive _dir _file
(void . runIO' entryPoint) upToInternalTyped
(void . runIOExclusive entryPoint) upToInternalTyped
}

rootNegTests :: Path Abs Dir
Expand All @@ -47,7 +47,7 @@ testNoPositivityFlag N.NegTest {..} =
entryPoint <-
set entryPointNoPositivity True
<$> defaultEntryPointIO' LockModeExclusive tRoot file'
(void . runIO' entryPoint) upToInternalTyped
(void . runIOExclusive entryPoint) upToInternalTyped
}

negPositivityTests :: [N.NegTest]
Expand Down
2 changes: 1 addition & 1 deletion test/Typecheck/PositiveNew.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ testDescr Old.PosTest {..} =
_testRoot = _dir,
_testAssertion = Single $ do
entryPoint <- set entryPointNewTypeCheckingAlgorithm True <$> defaultEntryPointIO' LockModeExclusive _dir _file
(void . runIO' entryPoint) upToInternalTyped
(void . runIOExclusive entryPoint) upToInternalTyped
}

allTests :: TestTree
Expand Down

0 comments on commit ef9dd6b

Please sign in to comment.