dkrun :: FilePath -> [FilePath] -> Expectation -> IO CheckResult
dkrun dk deps exp = do
  cwd <- getCurrentDirectory
  setCurrentDirectory $ cwd </> "t"
  result <- catch (do
    let compile = rawSystem "../dist/build/dedukti/dedukti" [dk <.> "dk"]
        run = rawSystem "../scripts/dkrun" $ (dk <.> "dko") : map (<.> "dko") deps
    test (return ()) fail compile
    case exp of
      ExpectSuccess -> test (return CheckOk) fail run
      ExpectFailure -> test (return CheckNoExpectedFailure) (const $ return CheckOk) run)
            (\e -> return (e :: CheckResult))
  setCurrentDirectory cwd
  return result
    where test s f m = m >>= \code -> case code of
            ExitSuccess -> s
            ExitFailure x -> f x
          fail x = throw $ CheckFailed $ "exit status " ++ show x
dkrun :: FilePath -> [FilePath] -> Expectation -> IO CheckResult
dkrun dk deps exp = do
  cwd <- getCurrentDirectory
  setCurrentDirectory $ cwd </> "t"
  result <- catch (do
    let compile = rawSystem "../dist/build/dedukti/dedukti" [dk <.> "dk"]
        run = rawSystem "../scripts/dkrun" $ (dk <.> "dko") : map (<.> "dko") deps
    test (return ()) fail compile
    case exp of
      ExpectSuccess -> test (return CheckOk) fail run
      ExpectFailure -> test (return CheckNoExpectedFailure) (const $ return CheckOk) run)
            (\e -> return (e :: CheckResult))
  setCurrentDirectory cwd
  return result
    where test s f m = m >>= \code -> case code of
            ExitSuccess -> s
            ExitFailure x -> f x
          fail x = throw $ CheckFailed $ "exit status " ++ show x
dkrun dk deps exp = do
  cwd <- getCurrentDirectory
  setCurrentDirectory $ cwd </> "t"
  result <- catch (do
    let compile = rawSystem "../dist/build/dedukti/dedukti" [dk <.> "dk"]
        run = rawSystem "../scripts/dkrun" $ (dk <.> "dko") : map (<.> "dko") deps
    test (return ()) fail compile
    case exp of
      ExpectSuccess -> test (return CheckOk) fail run
      ExpectFailure -> test (return CheckNoExpectedFailure) (const $ return CheckOk) run)
            (\e -> return (e :: CheckResult))
  setCurrentDirectory cwd
  return result
    where test s f m = m >>= \code -> case code of
            ExitSuccess -> s
            ExitFailure x -> f x
          fail x = throw $ CheckFailed $ "exit status " ++ show x