Flush test-suite output before running the cleanup code.
Skip running the test is not attached to a TTY.
Merge pull request #6665 from s0undt3ch/develop

Testsuite fixes for Jenkins