@@ -231,7 +231,7 @@ test_streamManyFilesToNar = HU.testCaseSteps "streamManyFilesToNar" $ \step ->
231231 IO. withFile " hnar" IO. WriteMode $ \ h ->
232232 buildNarIO narEffectsIO narFilePath h
233233 filesPostcount <- countProcessFiles
234- pure $ filesPostcount - filesPrecount
234+ pure $ (-) <$> filesPostcount <*> filesPrecount
235235
236236 step " create test files"
237237 Directory. createDirectory packagePath
@@ -252,7 +252,9 @@ test_streamManyFilesToNar = HU.testCaseSteps "streamManyFilesToNar" $ \step ->
252252
253253 step " check constant file usage"
254254 filesPostcount <- countProcessFiles
255- (filesPostcount - filesPrecount) `shouldSatisfy` (< 50 )
255+ case ((-) <$> filesPostcount <*> filesPrecount) of
256+ Nothing -> pure ()
257+ Just c -> c `shouldSatisfy` (< 50 )
256258
257259 -- step "check file exists"
258260 -- e <- doesPathExist packagePath'
@@ -361,12 +363,16 @@ packThenExtract testName setup =
361363 pure ()
362364
363365-- | Count file descriptors owned by the current process
364- countProcessFiles :: IO Int
366+ countProcessFiles :: IO ( Maybe Int )
365367countProcessFiles = do
366368 pid <- Unix. getProcessID
367- let fdDir = " /proc/" <> show pid <> " /fd"
368- fds <- P. readProcess " ls" [fdDir] " "
369- pure $ length $ words fds
369+ hasProc <- doesDirectoryExist " /proc"
370+ if not hasProc
371+ then pure Nothing
372+ else do
373+ let fdDir = " /proc/" <> show pid <> " /fd"
374+ fds <- P. readProcess " ls" [fdDir] " "
375+ pure $ pure $ length $ words fds
370376
371377
372378-- | Read the binary output of `nix-store --dump` for a filepath
0 commit comments