test: Pin and document TEST_DIR_PATH_ELEMENT, SeedRand::FIXED_SEED #30748

pull maflcko wants to merge 2 commits into bitcoin:master from maflcko:2408-test changing 5 files +21 −14
  1. maflcko commented at 8:01 am on August 29, 2024: member

    Two small test changes:

    • A refactor to update the name and documentation around SeedRand::FIXED_SEED.
    • A change to extract and document TEST_DIR_PATH_ELEMENT, and to change its value to better match the TMPDIR_PREFIX in functional tests. The value previously included PACKAGE_NAME, which is cute, but doesn’t explain why it was used (to include a space). So just use test_common bitcoin to achieve the same with less effort.
  2. test: Rename SeedRand::SEED to FIXED_SEED for clarity 2222f7a874
  3. DrahtBot commented at 8:01 am on August 29, 2024: contributor

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

    Code Coverage

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK hodlinator, ryanofsky

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #30737 (test: Fix RANDOM_CTX_SEED use with parallel tests by hodlinator)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. DrahtBot renamed this:
    test: Pin and document TEST_DIR_PATH_ELEMENT, SeedRand::FIXED_SEED
    test: Pin and document TEST_DIR_PATH_ELEMENT, SeedRand::FIXED_SEED
    on Aug 29, 2024
  5. DrahtBot added the label Tests on Aug 29, 2024
  6. in src/test/util/setup_common.cpp:78 in fa9c3aecb1 outdated
    74@@ -77,6 +75,7 @@ const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
    75 
    76 /** Random context to get unique temp data dirs. Separate from m_rng, which can be seeded from a const env var */
    77 static FastRandomContext g_rng_temp_path;
    78+constexpr inline auto TEST_DIR_PATH_ELEMENT{"test_common bitcoin"}; // Includes a space to catch possible path escape issues.
    


    hodlinator commented at 12:43 pm on August 29, 2024:

    constexpr inline is used to abide by the One Definition Rule when putting variables in header files. This is a .CPP file.

    Also would have added an extra newline to separate it from the commented code-section above.

    0
    1constexpr auto TEST_DIR_PATH_ELEMENT{"test_common bitcoin"}; // Includes a space to catch possible path escape issues.
    

    maflcko commented at 1:15 pm on August 29, 2024:

    I don’t think there is a risk in putting inline in a CPP file. In fact, it seems easier to just be consistent when using it in headers and CPP files. Otherwise, issues could appear when the code is moved, making it harder to move the code.

    The newline was omitted on purpose, to group the two into a related section about the test tmp path.

    So I’ll leave this as-is for now.


    hodlinator commented at 6:50 pm on August 29, 2024:
    Okay, would have at least tweaked the comment a bit in that case. But I’ll chalk this down to me still getting familiar with this project’s style of working with the code.

    maflcko commented at 7:00 pm on August 29, 2024:
    I think TEST_DIR_PATH_ELEMENT is self-explanatory, but I am open to consider to include a comment on TEST_DIR_PATH_ELEMENT, if you have a suggestion.

    hodlinator commented at 10:20 pm on August 30, 2024:

    I agree it’s self-explanatory, and it is closely related, but the comment does not apply to it. How about putting it first, still grouping them together?

    0constexpr inline auto TEST_DIR_PATH_ELEMENT{"test_common bitcoin"}; // Includes a space to catch possible path escape issues.
    1/** Random context to get unique temp data dirs. Separate from m_rng, which can be seeded from a const env var */
    2static FastRandomContext g_rng_temp_path;
    

    maflcko commented at 7:29 am on September 2, 2024:
    Thanks, done!
  7. hodlinator commented at 1:08 pm on August 29, 2024: contributor

    Concept ACK fa9c3aecb18e68cfaeae44aa0daffec020ca3927

    Not entirely sure why the two changes are combined in one PR but they are small enough and both touch setup_common.cpp.

    Good to see SeedRandomForTest no longer defaults which enum value to use (it was explicitly passed everywhere anyway). :+1:

    No remaining references to PACKAGE_NAME in tests, nor “test_common_Bitcoin Core” in project. Shortening to “test_common bitcoin” seems like it should be tolerable for forks.

  8. test: Pin and document TEST_DIR_PATH_ELEMENT fa84f9decd
  9. maflcko force-pushed on Sep 2, 2024
  10. hodlinator approved
  11. hodlinator commented at 1:35 pm on September 3, 2024: contributor

    ACK fa84f9decd224ea1c25dc7095bad70a48fa1a534

    git range-diff master fa9c3aec fa84f9de

    Only one minor change (that I suggested) since prior review.

    Passed ctest -j <cores> --test-dir build.

  12. ryanofsky approved
  13. ryanofsky commented at 6:07 pm on September 5, 2024: contributor

    Code review ACK fa84f9decd224ea1c25dc7095bad70a48fa1a534

    IMO, TEST_DIR_PATH_ELEMENT would be clearer as TESTS_DIR_NAME and "test_common bitcoin" would be clearer as "bitcoin tests" but current names seem fine too.

  14. fanquake merged this on Sep 6, 2024
  15. fanquake closed this on Sep 6, 2024

  16. maflcko deleted the branch on Sep 6, 2024
  17. maflcko commented at 8:48 am on September 6, 2024: member

    IMO, TEST_DIR_PATH_ELEMENT would be clearer as TESTS_DIR_NAME and "test_common bitcoin" would be clearer as "bitcoin tests" but current names seem fine too.

    Looks like #30737 may or may not change the path layout, so any clarifications could in theory be done there.


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: 2024-12-27 06:12 UTC

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