Copy tests/gnupg/ into trash directory for tests gpg2 currently creates a Unix socket in GNUPGHOME, which therefore needs to fit in 108 bytes (the maximum length for a Unix socket path). Copying tests/gnupg/ into the temporary trash directory makes it easier to set things up so that it's always in a short enough path, as well as avoiding accidental pollution by tests.
Ensure compatibility with tree 2.0 Tree 2.0 and later will unconditionally ignore all options and write JSON data on file descriptor 3 when available, which causes problems for the test harness and other scripts that use FD 3. Work around by closing descriptor 3 for the 'tree' command.