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

Don't build tests by default in ninja #6511

Closed
wants to merge 10 commits into from

Conversation

dcbaker
Copy link
Member

@dcbaker dcbaker commented Jan 25, 2020

This is a rebased version of #5728, with the changes I requested applied on top. The idea is that tests and benchmarks are removed from the all target, and are placed in their own meson-build-tests and meson-build-benchmarks targets, which the test and benchmark targets depend on. This allows us to avoid building test executables by default.

I'd like to follow this up with a change that allows targets that are not installed to not build by default.

Fixes #2518
Fixes #1704

@lgtm-com
Copy link

lgtm-com bot commented Jan 25, 2020

This pull request introduces 1 alert when merging aec3478 into 03065f2 - view on LGTM.com

new alerts:

  • 1 for Wrong number of arguments in a call

@scivision
Copy link
Member

scivision commented Feb 5, 2020

Is this a summary of functionality this PR adds?

  • I have a "large" project with lots of tests that only devs, not end-users that may build this project are interested in
  • whether using "large" directly via meson build or as a Meson subproject, I don't want to build tests by default

this appears to be done new for this PR by:

executable('test_shaky', build_by_default : false)

such that test_shaky is not built by

ninja -C build
# or 
meson install -C build

but would be built by

meson test -C build
# or
ninja -C build test

Currently my approach to this is to enclose user-annoying tests like:

if get_option('dev')
  executable('test_shaky')
endif

@dcbaker
Copy link
Member Author

dcbaker commented Feb 20, 2020

Ideally this would have a follow up of "don't build targets that aren't installed by default", so that if you had helper libraries only used in tests those also wouldn't get built by default. This is for me, motivated by the fact that mesa has a lot of test-only helper libraries that all have to be carefully guarded, and not having to do that guarding would be nice.

@dcbaker dcbaker force-pushed the no-tests-by-default branch from aec3478 to a2985cb Compare February 20, 2020 18:33
@dcbaker dcbaker requested a review from jpakkane as a code owner February 20, 2020 18:33
@lgtm-com
Copy link

lgtm-com bot commented Feb 20, 2020

This pull request introduces 1 alert when merging a2985cb into 4597235 - view on LGTM.com

new alerts:

  • 1 for Wrong number of arguments in a call

@dcbaker dcbaker force-pushed the no-tests-by-default branch from a2985cb to ed01153 Compare February 20, 2020 22:32
@dcbaker dcbaker force-pushed the no-tests-by-default branch 2 times, most recently from 0c8c1d5 to ef87c6a Compare March 19, 2020 19:44
@dcbaker
Copy link
Member Author

dcbaker commented Mar 19, 2020

I've adde a bunch of stuff to make working with run_project_tests more pleasant, as I had to run a few tests over and over on windows to figure some of the problems out.

@lgtm-com
Copy link

lgtm-com bot commented Mar 19, 2020

This pull request introduces 1 alert when merging ef87c6a into 321774d - view on LGTM.com

new alerts:

  • 1 for Wrong number of arguments in a class instantiation

@dcbaker dcbaker force-pushed the no-tests-by-default branch from 683acb1 to c30e8b0 Compare October 21, 2020 18:33
@emersion
Copy link
Contributor

What's the status of this PR? Apart from rebasing, what are the outstanding issues?

@jpakkane
Copy link
Member

Featurewise this is ok, but the failing tests need to be fixed at least.

@dcbaker
Copy link
Member Author

dcbaker commented Apr 19, 2021

I need to find a chance to rebase it and fix the failing tests, just not right at the top of queue right now

DyXel added a commit to DyXel/ygopen that referenced this pull request Apr 10, 2022
Set `build_by_default` to `false` for the unit test executable which in the
future should cause tests to be only built if they are gonna run when
mesonbuild/meson#6511 is merged
@gaudetja gaudetja mentioned this pull request Jan 21, 2023
@gaudetja
Copy link

gaudetja commented Jan 21, 2023

I need to find a chance to rebase it and fix the failing tests, just not right at the top of queue right now

@dcbaker, @jpakkane, I came across this PR and created #11317 to try and help with rebasing and running tests. Everything seems to be consistent between master and this branch as far as tests passing on my development machine. Thank you for creating this fix years ago!

@evelikov
Copy link

evelikov commented Sep 9, 2024

@dcbaker can we offer some virtual 🍪 in exchange for updating/landing this PR?

@bonzini
Copy link
Collaborator

bonzini commented Dec 31, 2024

Closing in favor of #11317, though even that one might be unnecessary given that meson has meson-test-prereq and meson-benchmark-prereq.

@bonzini bonzini closed this Dec 31, 2024
eli-schwartz added a commit to eli-schwartz/meson that referenced this pull request 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test executable always built even when build_by_default is false Test target depends on all executables
8 participants