From 0c0f4a20f4c1fbf43283018eafabb3e11af7e7d7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 30 Jan 2025 19:06:06 -0400 Subject: [PATCH] move windows test suite workaround to relatedTemplate --- Annex/ReplaceFile.hs | 6 ------ Utility/Tmp.hs | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Annex/ReplaceFile.hs b/Annex/ReplaceFile.hs index 3af555d39d..5cb46b17dd 100644 --- a/Annex/ReplaceFile.hs +++ b/Annex/ReplaceFile.hs @@ -5,8 +5,6 @@ - Licensed under the GNU AGPL version 3 or higher. -} -{-# LANGUAGE CPP #-} - module Annex.ReplaceFile ( replaceGitAnnexDirFile, replaceGitDirFile, @@ -59,11 +57,7 @@ replaceFile createdirectory file action = replaceFile' createdirectory file (con replaceFile' :: (RawFilePath -> Annex ()) -> RawFilePath -> (a -> Bool) -> (RawFilePath -> Annex a) -> Annex a replaceFile' createdirectory file checkres action = withOtherTmp $ \othertmpdir -> do -#ifndef mingw32_HOST_OS let basetmp = relatedTemplate' (P.takeFileName file) -#else - let basetmp = toRawFilePath "t" -#endif withTmpDirIn (fromRawFilePath othertmpdir) (toOsPath basetmp) $ \tmpdir -> do let tmpfile = toRawFilePath tmpdir P. basetmp r <- action tmpfile diff --git a/Utility/Tmp.hs b/Utility/Tmp.hs index 8e0ca10755..3f01a01919 100644 --- a/Utility/Tmp.hs +++ b/Utility/Tmp.hs @@ -6,6 +6,7 @@ -} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-tabs #-} module Utility.Tmp ( @@ -111,6 +112,7 @@ relatedTemplate :: RawFilePath -> Template relatedTemplate = toOsPath . relatedTemplate' relatedTemplate' :: RawFilePath -> RawFilePath +#ifndef mingw32_HOST_OS relatedTemplate' f | len > templateAddedLength = {- Some filesystems like FAT have issues with filenames @@ -122,6 +124,11 @@ relatedTemplate' f where len = B.length f dot = fromIntegral (ord '.') +#else +-- Avoids a test suite failure on windows, reason unknown, but +-- best to keep paths short on windows anyway. +relatedTemplate' _ = "t" +#endif {- When a Template is used to create a temporary file, some random bytes - are appended to it. This is how many such bytes can be added, maximum.