[docs] explain how to recompile a modified unit test #11219

pull Sjors wants to merge 1 commits into bitcoin:master from Sjors:patch-1 changing 1 files +4 −1
  1. Sjors commented at 5:12 PM on September 2, 2017: member

    It was not obvious to me to run make inside the test directory, especially because make src/test and make src/test/test_bitcoin result in make: Nothing to be done for ....

  2. achow101 commented at 5:40 PM on September 2, 2017: member

    Use make -C src/test instead of changing to the test directory and running make.

  3. Sjors commented at 5:42 PM on September 2, 2017: member

    @achow101 thanks, I'll update the instruction.

  4. Sjors force-pushed on Sep 2, 2017
  5. fanquake added the label Docs and Output on Sep 2, 2017
  6. laanwj commented at 9:43 PM on September 5, 2017: member

    Worded like this it is not clear to me what is the advantage of this, compared to re-running make in the top-level directory. After all, make detects what files are changed and only recompiles those. Or is this when you change a non-test compilation unit and only want to see how it affects the unit test?

  7. Sjors force-pushed on Sep 6, 2017
  8. [docs] explain how to recompile only what bitcoind tests need
    `make` rebuilds the entire project. This is quite slow if e.g. you're making changes to one file and only wish to run the bitcoind tests.
    
    This commit adds an instruction to run `make -C src/test` (as opposed to `make src/test` and `make src/test/test_bitcoin`).
    478d4fb79c
  9. Sjors force-pushed on Sep 6, 2017
  10. Sjors commented at 8:08 AM on September 6, 2017: member

    The latter scenario was the problem I ran into. I pushed a hopefully more clear instruction.

  11. laanwj commented at 10:16 PM on September 6, 2017: member

    Looks good to me now. Tested ACK 478d4fb79c878c560ed9179b24b48e884a3b0c13

  12. laanwj merged this on Sep 6, 2017
  13. laanwj closed this on Sep 6, 2017

  14. laanwj referenced this in commit bcc8a620ea on Sep 6, 2017
  15. Sjors deleted the branch on Sep 7, 2017
  16. PastaPastaPasta referenced this in commit 7980f55e5a on Sep 23, 2019
  17. PastaPastaPasta referenced this in commit 2f4b32b153 on Sep 24, 2019
  18. PastaPastaPasta referenced this in commit 28e71a3c05 on Nov 19, 2019
  19. PastaPastaPasta referenced this in commit a5a43cdd34 on Nov 21, 2019
  20. PastaPastaPasta referenced this in commit aebdcce73d on Dec 9, 2019
  21. PastaPastaPasta referenced this in commit 9e12a35d9a on Jan 1, 2020
  22. PastaPastaPasta referenced this in commit 514ef9bfa8 on Jan 2, 2020
  23. PastaPastaPasta referenced this in commit c518fa25b0 on Jan 2, 2020
  24. PastaPastaPasta referenced this in commit 4789d90589 on Jan 2, 2020
  25. in src/test/README.md:11 in 478d4fb79c
       4 | @@ -5,7 +5,10 @@ and tests weren't explicitly disabled.
       5 |  
       6 |  After configuring, they can be run with `make check`.
       7 |  
       8 | -To run the bitcoind tests manually, launch `src/test/test_bitcoin`.
       9 | +To run the bitcoind tests manually, launch `src/test/test_bitcoin`. To recompile
      10 | +after a test file was modified, run `make` and then run the test again. If you
      11 | +modify a non-test file, use `make -C src/test` to recompile only what's needed
      12 | +to run the bitcoind tests.
    


    glowang commented at 3:20 PM on May 18, 2020:

    I'm a bit confused by this description...excuse me for asking some beginner questions here...😂 I couldn't find a lot of info on how to use make and -C, but I did find one here. According to this post about phony targets, I derived that the dir after -C flag is the target subdir to build:

    Phony targets are also useful in conjunction with recursive invocations of make (see Recursive Use of make). In this situation the makefile will often contain a variable which lists a number of sub-directories to be built. A simplistic way to handle this is to define one rule with a recipe that loops over the sub-directories, like this:

    SUBDIRS = foo bar baz

    subdirs: for dir in $(SUBDIRS); do
    $(MAKE) -C $$dir;
    done

    If so, make -C src/test is only building the test directory, right? Why is it that if one modify a non-test file, one needs to rebuild the src/test? They should not have to rebuild src/test if they didn't modify any test file?


    MarcoFalke commented at 4:20 PM on May 18, 2020:

    the test depend on bitcoin core, so if a non-test file (a bitcoin core file) like init.cpp is modified, it will need to be recompiled as well.

    init.cpp is then put into libbitcoin_server, which is then linked into test_bitcoin


    glowang commented at 3:08 AM on May 19, 2020:

    Sounds like either the a test or a non-test file gets changed, bitcoin core (the src dir?) needs to be recompiled. Then when is make -C src/test relevant? Because this command only compiles what is in src/test right, instead of bitcoin core itself? The documentation says If you modify a non-test file, use make -C src/test to recompile only what's needed to run the bitcoind tests, and it seems to imply that when a non-test file gets changed, we only need to compile src/test?


    Sjors commented at 8:33 AM on May 19, 2020:

    Tests depend on individual source files, not all of bitcoind. So if you're working on src/descriptor.cpp it's faster to do make -C src/test && src/test/test_bitcoin --run_test=descriptor_tests


    MarcoFalke commented at 10:29 AM on May 19, 2020:

    Tests depend on individual source files, not all of bitcoind

    I don't think this is true. Tests depend on all the libraries that bitcoind depends on. The only thing they don't depend on is bitcoind.cpp

  26. ckti referenced this in commit fd091e416a on Mar 28, 2021
  27. DrahtBot locked this on Feb 15, 2022

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-14 09:15 UTC

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