17
17
{-# LANGUAGE UndecidableInstances #-}
18
18
19
19
{-# OPTIONS_GHC -Wno-orphans #-}
20
+ {- HLINT ignore "Use camelCase" -}
20
21
21
22
-- | Tests for our filesystem abstractions.
22
23
--
@@ -74,7 +75,7 @@ import Data.TreeDiff (ToExpr (..), defaultExprViaShow)
74
75
import Data.Word (Word64 )
75
76
import qualified Generics.SOP as SOP
76
77
import GHC.Generics
77
- import GHC.Stack
78
+ import GHC.Stack hiding ( prettyCallStack )
78
79
import System.IO.Temp (withTempDirectory )
79
80
import System.Random (getStdRandom , randomR )
80
81
import Text.Read (readMaybe )
@@ -89,13 +90,14 @@ import qualified Test.StateMachine.Labelling as C
89
90
import qualified Test.StateMachine.Sequential as QSM
90
91
import qualified Test.StateMachine.Types as QSM
91
92
import qualified Test.StateMachine.Types.Rank2 as Rank2
92
- import Test.Tasty (TestTree , testGroup )
93
+ import Test.Tasty (TestTree , localOption , testGroup )
93
94
import Test.Tasty.QuickCheck
94
95
95
96
import System.FS.API
96
97
import System.FS.IO
97
98
import qualified System.FS.IO.Internal as F
98
99
100
+ import Util.CallStack
99
101
import Util.Condense
100
102
101
103
import System.FS.Sim.FsTree (FsTree (.. ))
@@ -1445,7 +1447,10 @@ showLabelledExamples = showLabelledExamples' Nothing 1000 (const True)
1445
1447
1446
1448
prop_sequential :: FilePath -> Property
1447
1449
prop_sequential tmpDir = withMaxSuccess 1000 $
1448
- QSM. forAllCommands (sm mountUnused) Nothing $ \ cmds -> QC. monadicIO $ do
1450
+ QSM. forAllCommands (sm mountUnused) Nothing $ runCmds tmpDir
1451
+
1452
+ runCmds :: FilePath -> QSM. Commands (At Cmd ) (At Resp ) -> Property
1453
+ runCmds tmpDir cmds = QC. monadicIO $ do
1449
1454
(tstTmpDir, hist, res) <- QC. run $
1450
1455
withTempDirectory tmpDir " HasFS" $ \ tstTmpDir -> do
1451
1456
let mount = MountPoint tstTmpDir
@@ -1467,6 +1472,8 @@ prop_sequential tmpDir = withMaxSuccess 1000 $
1467
1472
tests :: FilePath -> TestTree
1468
1473
tests tmpDir = testGroup " HasFS" [
1469
1474
testProperty " q-s-m" $ prop_sequential tmpDir
1475
+ , localOption (QuickCheckTests 1 )
1476
+ $ testProperty " regression_removeFileOnDir" $ runCmds tmpDir regression_removeFileOnDir
1470
1477
]
1471
1478
1472
1479
-- | Unused mount mount
@@ -1479,6 +1486,32 @@ tests tmpDir = testGroup "HasFS" [
1479
1486
mountUnused :: MountPoint
1480
1487
mountUnused = error " mount point not used during command generation"
1481
1488
1489
+ -- | The error numbers returned by Linux vs. MacOS differ when using
1490
+ -- 'removeFile' on a directory.
1491
+ regression_removeFileOnDir :: QSM. Commands (At Cmd ) (At Resp )
1492
+ regression_removeFileOnDir = QSM. Commands {unCommands = [
1493
+ QSM. Command
1494
+ (At {unAt =
1495
+ CreateDirIfMissing
1496
+ True
1497
+ (PExpPath (mkFsPath [" x" ]))})
1498
+ (At {unAt = Resp {getResp =
1499
+ Right (Path (QSM. Reference (QSM. Symbolic (QSM. Var 0 ))) () )}})
1500
+ [QSM. Var 0 ]
1501
+ , QSM. Command
1502
+ (At {unAt =
1503
+ RemoveFile
1504
+ (PExpPath (mkFsPath [" x" ]))})
1505
+ (At {unAt = Resp {getResp =
1506
+ Left (FsError {
1507
+ fsErrorType = FsResourceInappropriateType
1508
+ , fsErrorPath = FsErrorPath Nothing (mkFsPath [" x" ])
1509
+ , fsErrorString = " expected file"
1510
+ , fsErrorNo = Nothing
1511
+ , fsErrorStack = prettyCallStack, fsLimitation = False })}})
1512
+ []
1513
+ ]}
1514
+
1482
1515
{- ------------------------------------------------------------------------------
1483
1516
Debugging
1484
1517
-------------------------------------------------------------------------------}
0 commit comments