Fix test suite to reap zombies.
I had not taken into account that the code was written to run git and leave zombies, for performance/laziness reasons, when I wrote the test suite. So rather than the typical 1 zombie process that git-annex develops, test developed dozens. Caused problems on system with low process limits. Added a reap function to GitRepo, that waits for any zombie child processes.
This commit is contained in:
parent
9806af7368
commit
c319a336a3
3 changed files with 27 additions and 19 deletions
|
@ -101,4 +101,7 @@ shutdown = do
|
||||||
unless (q == GitQueue.empty) $ do
|
unless (q == GitQueue.empty) $ do
|
||||||
showSideAction "Recording state in git..."
|
showSideAction "Recording state in git..."
|
||||||
Annex.queueRun
|
Annex.queueRun
|
||||||
|
|
||||||
|
liftIO $ Git.reap
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
37
GitRepo.hs
37
GitRepo.hs
|
@ -34,7 +34,6 @@ module GitRepo (
|
||||||
gitCommandLine,
|
gitCommandLine,
|
||||||
run,
|
run,
|
||||||
pipeRead,
|
pipeRead,
|
||||||
hPipeRead,
|
|
||||||
attributes,
|
attributes,
|
||||||
remotes,
|
remotes,
|
||||||
remotesAdd,
|
remotesAdd,
|
||||||
|
@ -50,6 +49,7 @@ module GitRepo (
|
||||||
typeChangedFiles,
|
typeChangedFiles,
|
||||||
typeChangedStagedFiles,
|
typeChangedStagedFiles,
|
||||||
absDir,
|
absDir,
|
||||||
|
reap,
|
||||||
|
|
||||||
prop_idempotent_deencode
|
prop_idempotent_deencode
|
||||||
) where
|
) where
|
||||||
|
@ -58,6 +58,7 @@ import Control.Monad (unless)
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import System.Posix.Directory
|
import System.Posix.Directory
|
||||||
import System.Posix.User
|
import System.Posix.User
|
||||||
|
import System.Posix.Process
|
||||||
import System.Path
|
import System.Path
|
||||||
import System.Cmd.Utils
|
import System.Cmd.Utils
|
||||||
import IO (bracket_)
|
import IO (bracket_)
|
||||||
|
@ -254,22 +255,24 @@ run repo params = assertLocal repo $ do
|
||||||
ok <- boolSystem "git" (gitCommandLine repo params)
|
ok <- boolSystem "git" (gitCommandLine repo params)
|
||||||
unless ok $ error $ "git " ++ show params ++ " failed"
|
unless ok $ error $ "git " ++ show params ++ " failed"
|
||||||
|
|
||||||
{- Runs a git subcommand and returns its output. -}
|
{- Runs a git subcommand and returns it output, lazily.
|
||||||
|
-
|
||||||
|
- Note that this leaves the git process running, and so zombies will
|
||||||
|
- result unless reap is called.
|
||||||
|
-}
|
||||||
pipeRead :: Repo -> [String] -> IO String
|
pipeRead :: Repo -> [String] -> IO String
|
||||||
pipeRead repo params = assertLocal repo $ do
|
pipeRead repo params = assertLocal repo $ do
|
||||||
pOpen ReadFromPipe "git" (gitCommandLine repo params) $ \h -> do
|
(_, s) <- pipeFrom "git" (gitCommandLine repo params)
|
||||||
hGetContentsStrict h
|
return s
|
||||||
|
|
||||||
{- Like pipeRead, but does not read output strictly; recommended
|
{- Reaps any zombie git processes. -}
|
||||||
- for git commands that produce a lot of output that will be processed
|
reap :: IO ()
|
||||||
- lazily.
|
reap = do
|
||||||
-
|
-- throws an exception when there are no child processes
|
||||||
- ONLY AFTER the string has been read completely, You must call either
|
r <- catch (getAnyProcessStatus False True) (\_ -> return Nothing)
|
||||||
- getProcessStatus or forceSuccess on the PipeHandle. Zombies will result
|
case r of
|
||||||
- otherwise.-}
|
Nothing -> return ()
|
||||||
hPipeRead :: Repo -> [String] -> IO (PipeHandle, String)
|
Just _ -> reap
|
||||||
hPipeRead repo params = assertLocal repo $ do
|
|
||||||
pipeFrom "git" (gitCommandLine repo params)
|
|
||||||
|
|
||||||
{- Scans for files that are checked into git at the specified locations. -}
|
{- Scans for files that are checked into git at the specified locations. -}
|
||||||
inRepo :: Repo -> [FilePath] -> IO [FilePath]
|
inRepo :: Repo -> [FilePath] -> IO [FilePath]
|
||||||
|
@ -322,9 +325,7 @@ typeChangedFiles' repo l middle = pipeNullSplit repo $ start ++ middle ++ end
|
||||||
- parameter), and splits it into a list of files. -}
|
- parameter), and splits it into a list of files. -}
|
||||||
pipeNullSplit :: Repo -> [String] -> IO [FilePath]
|
pipeNullSplit :: Repo -> [String] -> IO [FilePath]
|
||||||
pipeNullSplit repo params = do
|
pipeNullSplit repo params = do
|
||||||
-- XXX handle is left open, this is ok for git-annex, but may need
|
fs0 <- pipeRead repo params
|
||||||
-- to be cleaned up for other uses.
|
|
||||||
(_, fs0) <- hPipeRead repo params
|
|
||||||
return $ split0 fs0
|
return $ split0 fs0
|
||||||
where
|
where
|
||||||
split0 s = filter (not . null) $ split "\0" s
|
split0 s = filter (not . null) $ split "\0" s
|
||||||
|
@ -410,8 +411,6 @@ checkAttr repo attr files = do
|
||||||
(_, s) <- pipeBoth "git" params $ join "\0" absfiles
|
(_, s) <- pipeBoth "git" params $ join "\0" absfiles
|
||||||
cwd <- getCurrentDirectory
|
cwd <- getCurrentDirectory
|
||||||
return $ map (topair $ cwd++"/") $ lines s
|
return $ map (topair $ cwd++"/") $ lines s
|
||||||
-- XXX handle is left open, this is ok for git-annex, but may need
|
|
||||||
-- to be cleaned up for other uses.
|
|
||||||
where
|
where
|
||||||
params = gitCommandLine repo ["check-attr", attr, "-z", "--stdin"]
|
params = gitCommandLine repo ["check-attr", attr, "-z", "--stdin"]
|
||||||
topair cwd l = (relfile, value)
|
topair cwd l = (relfile, value)
|
||||||
|
|
6
debian/changelog
vendored
6
debian/changelog
vendored
|
@ -1,3 +1,9 @@
|
||||||
|
git-annex (0.22) UNRELEASED; urgency=low
|
||||||
|
|
||||||
|
* Fix test suite to reap zombies.
|
||||||
|
|
||||||
|
-- Joey Hess <joeyh@debian.org> Sun, 13 Feb 2011 00:48:02 -0400
|
||||||
|
|
||||||
git-annex (0.21) unstable; urgency=low
|
git-annex (0.21) unstable; urgency=low
|
||||||
|
|
||||||
* test: Don't rely on chmod -R working.
|
* test: Don't rely on chmod -R working.
|
||||||
|
|
Loading…
Reference in a new issue