Skip to content

Conversation

@practicalswift
Copy link
Contributor

@practicalswift practicalswift commented Aug 7, 2019

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:

$ test/functional/test_runner.py wallet_hd.py > output 2>&1
$ less output
Temporary test directory at /tmp/test_runner_₿_🏃_20190807_074115
ESC[1mWARNING!ESC[0m There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!
Remaining jobs: [wallet_hd.py]
.......................................^M                                       ^M1/1 - ESC[1mwallet_hd.pyESC[0m passed, Duration: 20 s

ESC[1mTEST         | STATUS    | DURATION

ESC[0mESC[0;32mwallet_hd.py | ✓ Passed  | 20 s
ESC[0mESC[1m
ALL          | ✓ Passed  | 20 s (accumulated)
ESC[0mRuntime: 20 s

After:

$ test/functional/test_runner.py wallet_hd.py > output 2>&1
$ less output
Temporary test directory at /tmp/test_runner_₿_🏃_20190807_074244
1/1 - wallet_hd.py passed, Duration: 20 s
WARNING! There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!
Remaining jobs: [wallet_hd.py]

TEST         | STATUS    | DURATION

wallet_hd.py | ✓ Passed  | 20 s

ALL          | ✓ Passed  | 20 s (accumulated)
Runtime: 20 s

@fanquake fanquake added the Tests label Aug 7, 2019
@promag
Copy link
Contributor

promag commented Aug 7, 2019

Could use sys.stdout.isatty() to automatically disable colors and progress dots?

@practicalswift
Copy link
Contributor Author

@promag Good point -- I thought about that but I'm not sure sys.stdout.isatty() holds True in Travis where we want the dots at least. I'll investigate :-)

@fanquake fanquake requested a review from maflcko August 12, 2019 06:16
@practicalswift practicalswift force-pushed the parsable branch 2 times, most recently from 322bd8b to 6ac121b Compare August 15, 2019 08:28
@practicalswift practicalswift changed the title tests: Add test_runner.py option --parsable tests: Use colors and dots in test_runner.py output only if standard output is a terminal Aug 15, 2019
@practicalswift
Copy link
Contributor Author

@promag Turns out sys.stdout.isatty() holds True also in Travis. Updated PR. Would you mind re-reviewing? :-)

…output is a terminal -- allows for using the test runner output as input to other programs
@laanwj
Copy link
Member

laanwj commented Aug 15, 2019

Looks good to me now,
ACK 37f2784

@maflcko maflcko merged commit 37f2784 into bitcoin:master Aug 15, 2019
maflcko pushed a commit that referenced this pull request Aug 15, 2019
…y if standard output is a terminal

37f2784 tests: 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 (practicalswift)

Pull request description:

  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:

  ```
  $ test/functional/test_runner.py wallet_hd.py > output 2>&1
  $ less output
  Temporary test directory at /tmp/test_runner_₿_🏃_20190807_074115
  ESC[1mWARNING!ESC[0m There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!
  Remaining jobs: [wallet_hd.py]
  .......................................^M                                       ^M1/1 - ESC[1mwallet_hd.pyESC[0m passed, Duration: 20 s

  ESC[1mTEST         | STATUS    | DURATION

  ESC[0mESC[0;32mwallet_hd.py | ✓ Passed  | 20 s
  ESC[0mESC[1m
  ALL          | ✓ Passed  | 20 s (accumulated)
  ESC[0mRuntime: 20 s
  ```

  After:

  ```
  $ test/functional/test_runner.py wallet_hd.py > output 2>&1
  $ less output
  Temporary test directory at /tmp/test_runner_₿_🏃_20190807_074244
  1/1 - wallet_hd.py passed, Duration: 20 s
  WARNING! There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!
  Remaining jobs: [wallet_hd.py]

  TEST         | STATUS    | DURATION

  wallet_hd.py | ✓ Passed  | 20 s

  ALL          | ✓ Passed  | 20 s (accumulated)
  Runtime: 20 s
  ```

ACKs for top commit:
  laanwj:
    ACK 37f2784

Tree-SHA512: f15d95f9e07de2954c326d63d7a4bcd2971faeaa00386600dec2fb915ec89475aeef1dbc968b2c12aa5e988d4b3ed1974d6da0b6a3f1e1a105cfd90e8cb97cf6
maflcko pushed a commit that referenced this pull request Aug 16, 2019
faba46d ci: Set --ansi in test_runner (MarcoFalke)

Pull request description:

  Fixup to:

  *  tests: Use colors and dots in test_runner.py output only if standard output is a terminal #16561

ACKs for top commit:
  practicalswift:
    ACK faba46d -- diff looks correct
  fanquake:
    ACK faba46d - assuming Travis is all green.

Tree-SHA512: 50bf6ec8e7a2987d77821816289fd87458e63237d419a149e5e04027387d2c4b3c23db58977585fda30fbc4b13686a7def0d9e00096b9a8469dea2916fd30565
@practicalswift practicalswift deleted the parsable branch April 10, 2021 19:38
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants