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 ....
[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-
Sjors commented at 5:12 PM on September 2, 2017: member
-
achow101 commented at 5:40 PM on September 2, 2017: member
Use
make -C src/testinstead of changing to the test directory and runningmake. - Sjors force-pushed on Sep 2, 2017
- fanquake added the label Docs and Output on Sep 2, 2017
-
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?
- Sjors force-pushed on Sep 6, 2017
-
478d4fb79c
[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`).
- Sjors force-pushed on Sep 6, 2017
-
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.
-
laanwj commented at 10:16 PM on September 6, 2017: member
Looks good to me now. Tested ACK 478d4fb79c878c560ed9179b24b48e884a3b0c13
- laanwj merged this on Sep 6, 2017
- laanwj closed this on Sep 6, 2017
- laanwj referenced this in commit bcc8a620ea on Sep 6, 2017
- Sjors deleted the branch on Sep 7, 2017
- PastaPastaPasta referenced this in commit 7980f55e5a on Sep 23, 2019
- PastaPastaPasta referenced this in commit 2f4b32b153 on Sep 24, 2019
- PastaPastaPasta referenced this in commit 28e71a3c05 on Nov 19, 2019
- PastaPastaPasta referenced this in commit a5a43cdd34 on Nov 21, 2019
- PastaPastaPasta referenced this in commit aebdcce73d on Dec 9, 2019
- PastaPastaPasta referenced this in commit 9e12a35d9a on Jan 1, 2020
- PastaPastaPasta referenced this in commit 514ef9bfa8 on Jan 2, 2020
- PastaPastaPasta referenced this in commit c518fa25b0 on Jan 2, 2020
- PastaPastaPasta referenced this in commit 4789d90589 on Jan 2, 2020
-
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;
doneIf so,
make -C src/testis only building the test directory, right? Why is it that if onemodify a non-test file, one needs to rebuild thesrc/test? They should not have to rebuildsrc/testif 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/testrelevant? Because this command only compiles what is insrc/testright, instead of bitcoin core itself? The documentation saysIf you modify a non-test file, usemake -C src/testto 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 compilesrc/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 onsrc/descriptor.cppit's faster to domake -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
ckti referenced this in commit fd091e416a on Mar 28, 2021DrahtBot locked this on Feb 15, 2022
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
More mirrored repositories can be found on mirror.b10c.me