summaryrefslogtreecommitdiff
path: root/tests/Common.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Common.hs')
-rw-r--r--tests/Common.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/Common.hs b/tests/Common.hs
index 0d399ad..a8c38fb 100644
--- a/tests/Common.hs
+++ b/tests/Common.hs
@@ -207,6 +207,27 @@ testMarkdownFormattingCaption2 tk =
extractImageCaption _ = mempty
+-------------------------------------------------------------------------------
+-- Test that cleanOutpuDirs correctly cleans the output directory specified in a block.
+testCleanOutputDirs :: Toolkit -> TestTree
+testCleanOutputDirs tk =
+ testCase "correctly cleans output directories" $ do
+ let postfix = unpack . cls $ tk
+ tempDir <- (</> "test-clean-output-dir" <> postfix) <$> getCanonicalTemporaryDirectory
+ ensureDirectoryExistsAndEmpty tempDir
+
+ let cb = addDirectory tempDir
+ $ codeBlock tk (trivialContent tk)
+
+ result <- (make tk) def cb
+ cleanedDirs <- cleanOutputDirs def cb
+
+ assertEqual "" [tempDir] cleanedDirs
+
+ outputDirExists <- doesDirectoryExist tempDir
+ assertEqual "" outputDirExists False
+
+
codeBlock :: Toolkit -> Script -> Block
codeBlock tk script = CodeBlock (mempty, [cls tk], mempty) script