test, univalue: Specify path to tests instead of hardcoding #31434

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:241206-unitester changing 2 files +10 −9
  1. hebasto commented at 11:16 am on December 6, 2024: member

    This change is required to pass cross builds on to a different machine after the build.

    For tests managed by CTest, the new UNIVALUE_JSON_TEST_SRC environment variable is set automatically. For other cases, it must be set manually. If not set, it defaults to the current working directory.

    See for example #31176, but this PR will also allow someone to implement it outside this repo.

    Also see: #31176 (review).

  2. test, univalue: Specify path to tests instead of hardcoding
    This change is required to pass cross builds on to a different machine
    after the build.
    
    For tests managed by CTest, the new `UNIVALUE_JSON_TEST_SRC` environment
    variable is set automatically. For other cases, it must be set manually.
    If not set, it defaults to the current working directory.
    b6b7058161
  3. hebasto added the label Tests on Dec 6, 2024
  4. DrahtBot commented at 11:16 am on December 6, 2024: contributor

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

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31434.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK theuni

    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:

    • #31176 (ci: Test cross-built Windows executables on Windows natively by hebasto)

    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.

  5. in src/univalue/test/unitester.cpp:16 in b6b7058161
    16-std::string srcdir(JSON_TEST_SRC);
    17+std::string srcdir = []() {
    18+    if (const char* env_srcdir = std::getenv("UNIVALUE_JSON_TEST_SRC")) {
    19+        return env_srcdir;
    20+    }
    21+    return ".";
    


    maflcko commented at 2:36 pm on December 6, 2024:

    This will be asserting later on anyway, as the files can likely not be opened. So I think it is fine and even preferable to assert early.

    0    return Assert(std::getenv("UNIVALUE_JSON_TEST_SRC"))); 
    

    edit: I guess with Assert replaced by assert


    theuni commented at 8:27 pm on December 6, 2024:
    Maybe print an error and call exit(1) directly? Or breaking this out so that main() returns non-zero in this case? Otherwise there’s no (helpful) indication of how to run the binary correctly when it fails.

    maflcko commented at 9:29 am on December 7, 2024:

    I think Assert/assert will already print the stringified content of the assert, which should be self-explanatory, at least in the context of a unit test that is only for developers (not shipped with releases). But anything is probably fine here.

    A step further could even go as far as directly embedding the blobs in the exe?


    TheCharlatan commented at 1:41 pm on December 9, 2024:

    A step further could even go as far as directly embedding the blobs in the exe?

    I think I would prefer that.

  6. theuni commented at 8:28 pm on December 6, 2024: member
    Concept ACK.
  7. maflcko commented at 9:34 am on December 18, 2024: member
    Are you still working on this? If not, I am happy to pick it up.
  8. hebasto commented at 9:42 am on December 18, 2024: member

    Are you still working on this? If not, I am happy to pick it up.

    Thank you @maflcko! I’ll review your PR.

  9. hebasto closed this on Dec 18, 2024


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: 2025-01-21 06:12 UTC

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