diff options
| author | adelon <22380201+adelon@users.noreply.github.com> | 2026-07-31 22:51:13 +0200 |
|---|---|---|
| committer | adelon <22380201+adelon@users.noreply.github.com> | 2026-07-31 22:51:13 +0200 |
| commit | 236bb2a7f961f58b015f78e019c43a99dab6223e (patch) | |
| tree | 2b2e89a46eaa8338756eb3d02555aa9583acce1d /source/Test/Unit | |
| parent | aa265683d2389ecdf407628e0464bfc9dc44e156 (diff) | |
Close verification output failures
Diffstat (limited to 'source/Test/Unit')
| -rw-r--r-- | source/Test/Unit/CommandLine.hs | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/source/Test/Unit/CommandLine.hs b/source/Test/Unit/CommandLine.hs index aef5d41..ba31934 100644 --- a/source/Test/Unit/CommandLine.hs +++ b/source/Test/Unit/CommandLine.hs @@ -10,7 +10,8 @@ import Felix.Store qualified as Store import Render.Html.Output qualified as HtmlOutput import Report.Location (pattern Nowhere) -import Control.Exception (bracket) +import Control.Exception (IOException, bracket) +import Control.Exception qualified as Exception import Data.ByteString qualified as ByteString import Data.List qualified as List import Data.Text qualified as Text @@ -41,6 +42,8 @@ unitTests = `shouldBe` expectedExitCode , testCase "reports the committed HTML prefix" reportsCommittedHtmlPrefix + , testCase "removes an unpublished dump temporary" + removesFailedDumpTemporary , testGroup "process boundary" [ testCase "version needs no input or store" versionNeedsNoInputOrStore @@ -107,6 +110,8 @@ unitTests = dumpAndHtmlVerifyOnce , testCase "semantic failure publishes no HTML" semanticFailurePublishesNoHtml + , testCase "missing renderer data is a typed failure" + missingRendererDataIsTyped ] ] @@ -280,6 +285,25 @@ nestedHtmlRoutesPrecedeStoreStartup = stderr `shouldContain` "\"a.html/b.html\"" assertNoDefaultStore fixture +removesFailedDumpTemporary :: Assertion +removesFailedDumpTemporary = + withTemporaryDirectory "felix-dump-atomic" \root -> do + let destination = root </> "1.p" + Directory.createDirectory destination + result <- Exception.try + (publishDumpFile destination "complete request") + :: IO (Either IOException ()) + case result of + Left _failure -> + pure () + Right () -> + assertFailure "dump publication unexpectedly succeeded" + contents <- List.sort <$> Directory.listDirectory root + assertEqual + "only the pre-existing final target remains" + ["1.p"] + contents + dumpsExactExecutedRequest :: Assertion dumpsExactExecutedRequest = withCliFixture cliSource \fixture -> do @@ -405,6 +429,29 @@ semanticFailurePublishesNoHtml = =<< Directory.doesPathExist (cliFixtureRoot fixture </> "html") +missingRendererDataIsTyped :: Assertion +missingRendererDataIsTyped = + withCliFixture cliSource \fixture -> do + Directory.removeFile + (cliFixtureRoot fixture </> "library" </> "lexicon.tsv") + writeExecutableScript + (cliFixtureVampire fixture) + [ "cat >/dev/null" + , "printf '%s\\n' '% SZS status Theorem for cli'" + ] + (exitCode, stdout, stderr) <- + runCliFixture fixture ["input.tex", "--fresh", "--html"] + exitCode `shouldBe` ExitFailure 2 + stdout `shouldBe` "" + stderr `shouldContain` "HTML preparation failed:" + stderr `shouldContain` "renderer data \"lexicon.tsv\" was not found" + assertBool "does not expose an ErrorCall" + (not ("ErrorCall" `List.isInfixOf` stderr)) + assertBool "failed preparation publishes no HTML" + . not + =<< Directory.doesPathExist + (cliFixtureRoot fixture </> "html") + outcomeCases :: [(CommandOutcome, ExitCode)] outcomeCases = [ (CommandCompleted, ExitSuccess) |
