test: simplify test_runner.py #29497

pull tdb3 wants to merge 1 commits into bitcoin:master from tdb3:20240227_testrunnersimplification changing 1 files +6 −8
  1. tdb3 commented at 12:28 AM on February 28, 2024: contributor

    Implements the simplifications to test_runner.py proposed by sipa in PR #23995.

    Remove the num_running variable as it can be implied by the length of the jobs list.

    Remove the i variable as it can be implied by the length of the test_results list.

    Instead of counting results to determine if finished, make the queue object itself responsible (by looking at running jobs and jobs left).

  2. DrahtBot commented at 12:28 AM on February 28, 2024: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK mzumsande, davidgumberg, marcofleon

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Tests on Feb 28, 2024
  4. kevkevinpal commented at 10:22 PM on March 2, 2024: contributor

    I tried this with --failfast and it seemed to properly fail fast

  5. tdb3 commented at 10:35 PM on March 2, 2024: contributor

    I tried this with --failfast and it seemed to properly fail fast

    Thank you for the test

  6. kevkevinpal commented at 10:42 PM on March 2, 2024: contributor

    I tested with this diff e82b3421a8d5fb82fe20e670857abbbe220ae09e

    and ran ./test/functional/test_runner.py --failfast

  7. in test/functional/test_runner.py:615 in 0dfd4c213a outdated
     612 | @@ -613,14 +613,12 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=
     613 |      max_len_name = len(max(test_list, key=len))
     614 |      test_count = len(test_list)
    


    davidgumberg commented at 2:53 PM on March 11, 2024:

    Maybe we can remove test_count? See below.


    tdb3 commented at 9:57 PM on March 11, 2024:

    test_count being assigned outside of the loop enables reporting of the correct number of total tests on the right side of the /.

  8. in test/functional/test_runner.py:621 in 0dfd4c213a outdated
     620 |              break
     621 |          for test_result, testdir, stdout, stderr, skip_reason in job_queue.get_next():
     622 |              test_results.append(test_result)
     623 | -            i += 1
     624 | -            done_str = "{}/{} - {}{}{}".format(i, test_count, BOLD[1], test_result.name, BOLD[0])
     625 | +            done_str = "{}/{} - {}{}{}".format(len(test_results), test_count, BOLD[1], test_result.name, BOLD[0])
    


    davidgumberg commented at 2:56 PM on March 11, 2024:

    Nit: We could use an f-string here and replace test_count with len(test_list)

                done_str = f"{len(test_results)}/{len(test_list)} - {BOLD[1]}{test_result.name}{BOLD[0]}"
    

    tdb3 commented at 9:57 PM on March 11, 2024:

    Thanks, updating to an f-string better aligns with the style guidelines (and that line is being changed anyway). Leaving other format strings untouched for now (those could be updated in another refactor PR).

  9. tdb3 force-pushed on Mar 11, 2024
  10. tdb3 commented at 9:56 PM on March 11, 2024: contributor

    Thanks for the review @davidgumberg! Force pushed. Responses inline.

  11. marcofleon approved
  12. marcofleon commented at 12:05 AM on March 12, 2024: contributor

    Tested ACK 8f2d814407c280f863be0303b4c2c1efdc0b8f36.

    Reviewed the code changes and I think they make the program a bit more readable. I ran test_runner.py and there were no issues. Also tested with --failfast and it did indeed fail fast at the expected test.

  13. mzumsande commented at 9:49 PM on March 12, 2024: contributor

    Code Review ACK 8f2d814407c280f863be0303b4c2c1efdc0b8f36

  14. tdb3 commented at 9:52 PM on March 12, 2024: contributor

    Tested ACK 8f2d814407c280f863be0303b4c2c1efdc0b8f36.

    Reviewed the code changes and I think they make the program a bit more readable. I ran test_runner.py and there were no issues. Also tested with --failfast and it did indeed fail fast at the expected test.

    Thank you for the review @marcofleon!

  15. tdb3 commented at 9:52 PM on March 12, 2024: contributor

    Code Review ACK 8f2d814407c280f863be0303b4c2c1efdc0b8f36

    Thank you for the review @mzumsande!

  16. test: simplify test_runner.py
    Remove the num_running variable as it can be implied by the
    length of the jobs list.
    
    Remove the i variable as it can be implied by the length of the
    test_results list.
    
    Instead of counting results to determine if finished, make the
    queue object itself responsible (by looking at running jobs and
    jobs left).
    
    Originally proposed by @sipa in PR #23995.
    
    Co-authored-by: Pieter Wuille <pieter@wuille.net>
    0831b54dfc
  17. tdb3 force-pushed on Mar 12, 2024
  18. tdb3 commented at 10:01 PM on March 12, 2024: contributor

    rebased

  19. mzumsande commented at 10:28 PM on March 12, 2024: contributor

    re-ACK 0831b54

    rebased

    Why? This looked ready for merge with 3 ACKs. A rebase invalidates existing ACKs, so once these exist it should only be done if there is a conflict (Drahtbot will complain) or a specific reason (such as. a silent conflict). The CI will always rebase on master anyway for its runs (which could be restarted without rebasing if really necessary).

  20. DrahtBot requested review from davidgumberg on Mar 12, 2024
  21. DrahtBot requested review from marcofleon on Mar 12, 2024
  22. tdb3 commented at 10:33 PM on March 12, 2024: contributor

    re-ACK 0831b54

    rebased

    Why? This looked ready for merge with 3 ACKs. A rebase invalidates existing ACKs, so once these exist it should only be done if there is a conflict (Drahtbot will complain) or a specific reason (such as. a silent conflict). The CI will always rebase on master anyway for its runs (which could be restarted without rebasing if really necessary).

    Thank you for the insight, didn't realize that. I'll avoid that moving forward. The rationale was to bring it to head while reinitiating CI (MacOS brew issue).

  23. davidgumberg commented at 11:30 PM on March 12, 2024: contributor

    reACK https://github.com/bitcoin/bitcoin/commit/0831b54dfca1b9e728295fff500215da14589fc0 Verified that the commit is unchanged with range-diff, and re-ran make check:

    $ git range-diff a945f09...8f2d814 1105aa4..0831b54
    1:  8f2d814407 = 1:  0831b54dfc test: simplify test_runner.py
    
  24. marcofleon commented at 5:43 AM on March 14, 2024: contributor

    re-ACK 0831b54dfca1b9e728295fff500215da14589fc0

  25. maflcko approved
  26. maflcko commented at 8:27 AM on March 14, 2024: member

    lgtm

  27. fanquake merged this on Mar 14, 2024
  28. fanquake closed this on Mar 14, 2024

  29. PastaPastaPasta referenced this in commit b3960437a9 on Oct 24, 2024
  30. PastaPastaPasta referenced this in commit ec1c735c17 on Oct 24, 2024
  31. PastaPastaPasta referenced this in commit 6d7aa3d978 on Oct 24, 2024
  32. PastaPastaPasta referenced this in commit aaccc9ea51 on Oct 24, 2024
  33. bitcoin locked this on Mar 14, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 06:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me