Use colors and dots in test_runner.py
output only if standard output is a terminal – allows for using the test runner output as input to other programs.
I found the need for this when parsing test_runner.py
output while investigating intermittent functional test failures.
Before:
0$ test/functional/test_runner.py wallet_hd.py > output 2>&1
1$ less output
2Temporary test directory at /tmp/test_runner_₿_🏃_20190807_074115
3ESC[1mWARNING!ESC[0m There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!
4Remaining jobs: [wallet_hd.py]
5.......................................^M ^M1/1 - ESC[1mwallet_hd.pyESC[0m passed, Duration: 20 s
6
7ESC[1mTEST | STATUS | DURATION
8
9ESC[0mESC[0;32mwallet_hd.py | ✓ Passed | 20 s
10ESC[0mESC[1m
11ALL | ✓ Passed | 20 s (accumulated)
12ESC[0mRuntime: 20 s
After:
0$ test/functional/test_runner.py wallet_hd.py > output 2>&1
1$ less output
2Temporary test directory at /tmp/test_runner_₿_🏃_20190807_074244
31/1 - wallet_hd.py passed, Duration: 20 s
4WARNING! There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!
5Remaining jobs: [wallet_hd.py]
6
7TEST | STATUS | DURATION
8
9wallet_hd.py | ✓ Passed | 20 s
10
11ALL | ✓ Passed | 20 s (accumulated)
12Runtime: 20 s