test: Stop gpg-agent daemons that are started for the test framework's gpg key
They normally shutdown when the GNUPGHOME directory is deleted, but on NFS they keep the directory from being deleted. And also, this avoids a number of them piling up while the test suite is running.
This commit is contained in:
parent
6fb7ecde35
commit
cde3e5eb0c
4 changed files with 39 additions and 4 deletions
|
@ -416,7 +416,7 @@ testHarness tmpdir cmd a = ifM (inPath (unGpgCmd cmd))
|
|||
, return Nothing
|
||||
)
|
||||
where
|
||||
var = "GNUPGHOME"
|
||||
var = "GNUPGHOME"
|
||||
|
||||
setup = do
|
||||
orig <- getEnv var
|
||||
|
@ -431,9 +431,16 @@ testHarness tmpdir cmd a = ifM (inPath (unGpgCmd cmd))
|
|||
[testSecretKey, testKey]
|
||||
return orig
|
||||
|
||||
cleanup (Just (Just v)) = setEnv var v True
|
||||
cleanup (Just Nothing) = unsetEnv var
|
||||
cleanup Nothing = return ()
|
||||
cleanup (Just (Just v)) = stopgpgagent >> setEnv var v True
|
||||
cleanup (Just Nothing) = stopgpgagent >> unsetEnv var
|
||||
cleanup Nothing = stopgpgagent
|
||||
|
||||
-- Recent versions of gpg automatically start gpg-agent, or perhaps
|
||||
-- other daemons. Stop them when done. This only affects
|
||||
-- daemons started for the GNUPGHOME that was used.
|
||||
-- Older gpg may not support this, so ignore failure.
|
||||
stopgpgagent = void $ boolSystem "gpgconf"
|
||||
[Param "--kill", Param "all"]
|
||||
|
||||
go (Just _) = Just <$> a
|
||||
go Nothing = return Nothing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue