Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build_by_default:false is ignored by mesontest. #1949

Closed
zajo opened this issue Jun 16, 2017 · 13 comments · Fixed by #6833
Closed

build_by_default:false is ignored by mesontest. #1949

zajo opened this issue Jun 16, 2017 · 13 comments · Fixed by #6833

Comments

@zajo
Copy link

zajo commented Jun 16, 2017

I have many targets, all flagged as "build_by_default: false". When I do ninja <target_name> it correctly builds only what is required for that target. But if I do mesontest <test_name> it seems to build everything.

@nirbheek
Copy link
Member

ninja targetname will always only build what is required for a target. However, mesontest will run a ninja all before running the test. We might provide an option to turn this off in the future, but in the meantime you can run mesontest --no-rebuild.

build_by_default: is only used for custom targets. It is ignored everywhere else.

@zajo
Copy link
Author

zajo commented Jun 20, 2017

Thanks, --no-rebuild is a useful workaround.

In my experience build_by_default is NOT ignored for executables. It is remarkable that Meson builds all targets by default, I think this is a "good thing" in general but build_by_default:false should always work on any target IMO.

@zajo
Copy link
Author

zajo commented Jun 20, 2017

Just tried:

mesontest --no-rebuild test-name

It still ended up rebuilding all.

@nirbheek
Copy link
Member

In my experience build_by_default is NOT ignored for executables.

Right, we added that feature recently, I forgot about that.

It still ended up rebuilding all.

That would be a bug, but I cannot reproduce it here with 0.41.1

@zajo
Copy link
Author

zajo commented Jun 20, 2017

I was on 0.41.0. Upgraded to 0.41.1, still --no-rebuild rebuilds all.

Even though you said it is ignored, I was still specifying build_by_default:false on the test executables AND the test targets, so I removed that too, still --no-rebuild rebuilds all.

@nirbheek
Copy link
Member

What are the exact steps that you are taking while doing this?

@zajo
Copy link
Author

zajo commented Jun 27, 2017

I was on 0.41.0. Upgraded to 0.41.1, still --no-rebuild rebuilds all.

Even though you said it is ignored, I was still specifying build_by_default:false on the test executables AND the test targets, so I removed that too, still --no-rebuild rebuilds all.

@zajo
Copy link
Author

zajo commented Jun 27, 2017

It seems there was a misunderstanding what --no-rebuild does: it seems to not build even the test i want to run. Please confirm -- if this is correct, then --no-rebuild is a useless option because there is little value in running unit tests that are out of date.

When I say "mesontest foo", I need it to build foo (and NOT build any other unit test), then run foo. Is there any way to get this behavior? The reason it is needed is that if I am working on one of very many unit tests, I don't want to have to wait for hundreds of files to build (possibly fail to build), just so I can run the one unit test I want to run.

@jpakkane
Copy link
Member

That is currently the case. Either you rebuild all targets or none of them. There has been interest in adding functionality to specify a single test and only compile that one (and other things it depends on) and then run it.

Until that is done if you know your specific target executable you can do ninja path/to/targetname followed by your test command with --no-rebuild. It's not great usability but it works.

@zajo
Copy link
Author

zajo commented Jun 29, 2017

The suggested workaround does not work for me. After changing a single CPP file, the ninja build compiles just that one file and links, as it should:

ninja maya_test-error_anim_no_name
[2/2] Linking target maya_test-error_anim_no_name.

Immediately after that, if I issue

mesontest --no-rebuild maya_test-error_anim_no_name

it builds/links 106 other targets that use the modified CPP file, then runs maya_test-error_anim_no_name.

P.S. I can't run the unit test directly (outside of mesontest) as it requires specific environment which meson.build sets correctly.

@jpakkane
Copy link
Member

That would be a bug then. Strange.

@zajo
Copy link
Author

zajo commented Jun 30, 2017

I don't think there is anything special to reproducing this, but If you need a test case, you can look at https://github.com/zajo/boost-noexcept.git: if you do e.g. ninja error_test, it'll build just that, then mesontest --no-rebuild error_test builds all other unit tests (warning, the wrap files will download boost as a subproject). I'm on 0.41.1.

Thanks!

jpakkane added a commit that referenced this issue Jun 30, 2017
@jpakkane
Copy link
Member

Can you test the linked branch?

marc-h38 pushed a commit to marc-h38/meson that referenced this issue Feb 21, 2020
marc-h38 pushed a commit to marc-h38/meson that referenced this issue Mar 24, 2020
eli-schwartz added a commit to eli-schwartz/meson that referenced this issue Jan 8, 2025
When running `ninja all` we shouldn't build testsuite programs as these
might not be wanted e.g. in order to just install the project. We do
want them to be built when running `ninja test`. Since meson 0.63 we
actually have a dedicated ninja alias for test dependencies -- move
these from the "all" rule to the dedicated test/benchmark rules.

Closes: mesonbuild#1704
Closes: mesonbuild#1949
Closes: mesonbuild#2518
Closes: mesonbuild#3662
Closes: mesonbuild#5728
Closes: mesonbuild#5867
Closes: mesonbuild#6511
Closes: mesonbuild#11317
Closes: mesonbuild#13378
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants