#!/bin/sh

# We do the clean-up only when the tests are run with GNUPGHOME
# set to the tests directory (which is the default). If the user
# saw fit to override TESTS_ENVIRONMENT to use another home, we
# must assume she knows what she is doing.
[ "$GNUPGHOME" = "$HOME/.gnupg" ] && exit 0

if [ "$GNUPGHOME" = "`/bin/pwd`" ]; then
    socketdir=`gpgconf --list-dirs socketdir`
    if [ -d "$socketdir" ]; then
        rm -f $socketdir/S.*
        rmdir $socketdir || true
    fi

    rm -f pubring.kbx reader_*.status
    if [ -d private-keys-v1.d ]; then
        rm -f private-keys-v1.d/*.key
        rmdir private-keys-v1.d
    fi
fi
