runTests :: TestInputs -> IO ()
runTests i = do
  desc <- case tiDescription i of
    Just pd -> return pd
    Nothing -> do
      path <- defaultPackageDesc verbose
      readPackageDescription verbose path
  date <- getCurrentTime
  randStr <- randomString
  let last2 (_, b, c) = (b, c)
      eiRes = testMultipleVersions date
        (last2 . tiLowest $ i) (map last2 . tiDefault $ i)
        (tiCabal i) (tiTest i) desc
  (r1, rs) <- case eiRes of
    Left e -> dependencyError e
    Right g -> g
  makeResultFile date randStr "lowest" (sel1 . tiLowest $ i) r1
  let makeRest r (d, _, _) = makeResultFile date randStr "current" d r
  _ <- zipWithM makeRest rs (tiDefault i)
  when (not $ isOk r1 && all isOk rs) exitFailure
  writeMinimumVersionsReport $ minimumVersionsReport
    (sel2 . tiLowest $ i) (sel1 . tiLowest $ i) date r1
  maybe (return ()) writeCurrentVersionsReport $ currentVersionsReport
    date (tiDefault i) rs
  exitSuccess
runTests :: TestInputs -> IO ()
runTests i = do
  desc <- case tiDescription i of
    Just pd -> return pd
    Nothing -> do
      path <- defaultPackageDesc verbose
      readPackageDescription verbose path
  date <- getCurrentTime
  randStr <- randomString
  let last2 (_, b, c) = (b, c)
      eiRes = testMultipleVersions date
        (last2 . tiLowest $ i) (map last2 . tiDefault $ i)
        (tiCabal i) (tiTest i) desc
  (r1, rs) <- case eiRes of
    Left e -> dependencyError e
    Right g -> g
  makeResultFile date randStr "lowest" (sel1 . tiLowest $ i) r1
  let makeRest r (d, _, _) = makeResultFile date randStr "current" d r
  _ <- zipWithM makeRest rs (tiDefault i)
  when (not $ isOk r1 && all isOk rs) exitFailure
  writeMinimumVersionsReport $ minimumVersionsReport
    (sel2 . tiLowest $ i) (sel1 . tiLowest $ i) date r1
  maybe (return ()) writeCurrentVersionsReport $ currentVersionsReport
    date (tiDefault i) rs
  exitSuccess
runTests i = do
  desc <- case tiDescription i of
    Just pd -> return pd
    Nothing -> do
      path <- defaultPackageDesc verbose
      readPackageDescription verbose path
  date <- getCurrentTime
  randStr <- randomString
  let last2 (_, b, c) = (b, c)
      eiRes = testMultipleVersions date
        (last2 . tiLowest $ i) (map last2 . tiDefault $ i)
        (tiCabal i) (tiTest i) desc
  (r1, rs) <- case eiRes of
    Left e -> dependencyError e
    Right g -> g
  makeResultFile date randStr "lowest" (sel1 . tiLowest $ i) r1
  let makeRest r (d, _, _) = makeResultFile date randStr "current" d r
  _ <- zipWithM makeRest rs (tiDefault i)
  when (not $ isOk r1 && all isOk rs) exitFailure
  writeMinimumVersionsReport $ minimumVersionsReport
    (sel2 . tiLowest $ i) (sel1 . tiLowest $ i) date r1
  maybe (return ()) writeCurrentVersionsReport $ currentVersionsReport
    date (tiDefault i) rs
  exitSuccess