From 37054e09463c7b46be5575fc085780c2e933a8b8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 27 Oct 2020 13:39:58 -0400 Subject: [PATCH] test if magic library works (When built with it.) I saw John Thorvald Wodder II doing this in https://github.com/datalad/datalad-extensions/blob/master/.github/workflows/build-git-annex-windows.yaml and it seemed like a good idea. John used an empty file for the binary file, but I think it's slightly suprising file picks that mime type for it, so opted to instead use something less ambiguous. --- Test.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Test.hs b/Test.hs index 24ade3b022..b9d4a7d130 100644 --- a/Test.hs +++ b/Test.hs @@ -298,6 +298,7 @@ unitTests note = testGroup ("Unit Tests " ++ note) , testCase "export_import_subdir" test_export_import_subdir , testCase "shared clone" test_shared_clone , testCase "log" test_log + , testCase "magic" test_magic , testCase "import" test_import , testCase "reinject" test_reinject , testCase "unannex (no copy)" test_unannex_nocopy @@ -446,6 +447,28 @@ test_log :: Assertion test_log = intmpclonerepo $ do git_annex "log" [annexedfile] @? "log failed" +test_magic :: Assertion +test_magic = intmpclonerepo $ do +#ifdef WITH_MAGICMIME + boolSystem "git" + [ Param "config" + , Param "annex.largefiles" + , Param "mimeencoding=binary" + ] @? "git config annex.largefiles failed" + writeFile "binary" "\127" + writeFile "text" "test\n" + git_annex "add" ["binary", "text"] + @? "git-annex add failed with mimeencoding in largefiles" + git_annex "sync" [] + @? "git-annex sync failed" + (isJust <$> annexeval (Annex.CatFile.catKeyFile (encodeBS "binary"))) + @? "binary file not added to annex despite mimeencoding config" + (isNothing <$> annexeval (Annex.CatFile.catKeyFile (encodeBS "text"))) + @? "non-binary file got added to annex despite mimeencoding config" +#else + return () +#endif + test_import :: Assertion test_import = intmpclonerepo $ Utility.Tmp.Dir.withTmpDir "importtest" $ \importdir -> do (toimport1, importf1, imported1) <- mktoimport importdir "import1"