aboutsummaryrefslogtreecommitdiff
path: root/unittests
AgeCommit message (Collapse)AuthorFilesLines
2 daysunittests/cargotests: add tests for workspace inheritancePaolo Bonzini1-1/+70
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2 dayscargo: change init-time computation to lazy propertiesPaolo Bonzini1-9/+16
Make the dataclasses closer to the TypedDicts. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2 daysunittests/cargotests: add tests for Cargo.toml parsingPaolo Bonzini1-0/+184
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2 daysunittests/cargotests: fix pylintPaolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2 daysCondense test directory names for 1.9.Jussi Pakkanen6-44/+44
12 daysmintro: Record rpath_dirs_to_remove in install_planDaniele Nicolodi1-0/+20
This is required by meson-python to fix RPATH entries when building a wheel.
12 daysunittests: allow running with pytest/unittest directlyChristoph Reiter1-0/+20
Currently the unittests are not runnable with pytest or unittest without going through the run_unittests.py wrapper, or setting certain env vars like MESON_UNIT_TEST_BACKEND. This has that downside that the common "pytest ..." fails and integration with things like VSCode fails too. To work around that we set everything that is needed to run the tests in __init__.py and run_unittests is only one more variant to invoke them by providing different defaults and settings. To make sure that pytest/unittest discover and run_unittests don't diverge implement an automatic test discovery in run_unittests to avoid hardcoding the tests to run there. There shouldn't be any functional changes.
2025-07-19options: fix misindentationPaolo Bonzini1-0/+8
Ensure that valobj.yielding is cleared for options in the toplevel project. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-18options: resolve yielding options at the time they are addedPaolo Bonzini1-1/+1
This makes it possible to adjust the value of the option with a subproject-specific augment. This was an undocumented change in 1.8 which was (voluntarily) undone in commit eae4efa72 ("options: resolve yielding options at the time they are added", 2025-07-13), but is useful. This reimplementation of yielding options makes it possible to presreve the bugfix while restoring this new feature. Reported-by: Nirbheek Chauhan <nirbheek@centricular.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-17options: parse -D and -U arguments directly into a Dict[OptionKey, ↵Paolo Bonzini1-7/+7
Optional[str]] As a side effect, this deduplicates -D and -U arguments passed to meson configure, taking into account the relative ordering of -D and -U options. Fixes: #14754 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-14unittests: add test case for setting and retrieving build optionsPaolo Bonzini1-2/+7
Check that build options fall back to host options, and that they can be retrieved with get_option. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-13backends: Use POSIX paths for target pathsL. E. Segovia1-37/+38
This commit completes 5de09cbe8838e8febf1ca3aa83b53cf06972bff3, ensuring that only POSIX style paths are passed to the compiler line, and thus fixing UNIX-style tools that treat single backward slashes as Unicode escaped characters. Fixes #12191 Completes #12534 Completes #12564
2025-07-10unittests: add test for c_link_args and CFLAGS interactionPaolo Bonzini1-0/+18
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-09unittests: improve test for yielding optionsPaolo Bonzini1-0/+24
Go through the whole initialization and set_option process, and check that the option value is unaffected by the creation of a subproject. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-07options: give priority to parent augments over child default_optionsPaolo Bonzini1-0/+20
Restore behavior of 1.7. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-07options: handle augments in OptionStore.set_optionPaolo Bonzini1-1/+27
Remove all the special casing and late validation now that early augments are stored in pending_subproject_options until the subproject is found. As a result, this makes the buildtype special case operate on subprojects as well. It also simplifies set_from_configure_command(), which does not have to treat various kinds of options in different ways. Fixes: #14729 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-07msetup, options: reverse direction of unknown options checkPaolo Bonzini1-8/+2
Remove knowledge of the internal pending_options from msetup; operate on the command line and check against the option store. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-07options: project options never act globallyPaolo Bonzini1-0/+20
As shown in the test, "-Dtests=true" should not override the subproject() call because tests is a project options and those do not share a namespace. Fixes: #14728 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-23vala: Also add --target-glib if glib is built as subprojectFlorian "sp1rit"​1-0/+17
Previously, meson would only check if glib was part of target.external_dependencies and add --target-glib appropriately. This however had the downside of meson not adding --target-glib if glib was included as a subproject, potentially breaking otherwise builds. Instead of checking external_dependencies, check target.added_deps for an occurrence of 'glib-2.0' and then pick the appropriate codepath (either from the external dependency based on version_reqs or for the internal dependency based on the actual version, potentially downgraded to the latest release version) Related-to: #14694
2025-06-18options: fix option orderingPaolo Bonzini2-4/+72
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18test cases: do not pass global option on command linePaolo Bonzini1-4/+5
The test covers overriding an option from the dependency() function. If the same option is passed on the command line, it overrides the dependency()'s default_options as well. Tweak the description of the unittests that uses the same sources. The tests pass, but I am not sure they should. For example in the second test the default_library=both setting in the machine file should have the same effect as the -D option (machine files have lower priority than command line, but higher priority than anything in meson.build files). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18options: reuse set_option_maybe_rootPaolo Bonzini1-2/+2
There is common logic hiding between project() and "meson configure": the complication that the comment mentions for the "default_options" case actually applies to "meson configure", to machine files, to command line options and to project options. Reuse the same function in all four cases. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18options: accept backend options as pending on first invocationPaolo Bonzini1-0/+6
They must be there when running re-configuring, because the backend cannot be changed, but they can be pending on the first invocation. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18optiontests: use a real system optionPaolo Bonzini1-3/+3
Once unknown options will go through accept_as_pending_option, only system options that really exist in Meson will be accepted. Adjust the unit tests. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18options: print option name before "as_root()" in errorsPaolo Bonzini1-3/+3
Starting with Meson 1.8.0, "meson configure" prints some options as ":foo" instead of "foo". Print the option as it was passed by the user. While at it, make errors more consistent and/or correct (e.g. "Unknown option" instead of "Unknown options"). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-09AstInterpreter: Fix dead-code-crashVolker Weißmann1-0/+1
Without this commit, the rewriter and the static introspection tool crash if `meson.build` contains something like ```meson if false foo = not_defined endif ``` or ```meson if false message(not_defined) endif ``` While it could be argued, that you should not write stuff like this, this used to raise a `MesonBugException`, which we have to fix. Fixes #14667
2025-06-08add unittest for cmake preprocessingJan2001011-0/+41
it uses the existing 14 configure file test case to configure config 7 and 10 with cmake and meson and then compares the relevant output to see if they are equal
2025-06-05unittests: use UnitTest helper methods instead of raw assertDylan Baker1-4/+4
Which doesn't give helpful error messages unless used with pytest
2025-06-05unittests: Handle missing compiler support in test_compiler_detectionDylan Baker1-5/+30
This wraps all of the compiler detections in this test case in try/except blocks. These blocks will return a skipTest for Python >= 3.11 (where subTest and skipTest interact correctly), and continue if they do not. For Meson CI runs they will fail the specific subtest, which is also an improvement as it can help pinpoint exactly which subtest failed. Fixes: #14579
2025-06-05unittests: add asserts to test_compiler_detectionDylan Baker1-0/+2
Add a few asserts for functions that could in theory return None, but if they do something has gone *really* wrong with the test.
2025-06-05unittests: use subtests to break up test_compiler_detectionDylan Baker1-99/+106
Which is a very large and complicated test function
2025-06-05Add ELD linkerKushal Pal1-1/+1
ELD is Qualcomm's open-source embedded linker. https://github.com/qualcomm/eld Signed-off-by: Kushal Pal <kushpal@qti.qualcomm.com>
2025-06-03utils: Replace BuildDirLock with generic DirectoryLockFlorian "sp1rit"​1-4/+3
DirectoryLock provides a generic locking implementation the replaces the previously used BuildDirLock.
2025-05-31cargo: Do not convert cfg() to Meson ASTXavier Claessens1-50/+19
We'll need to evaluate those expressions before generating the AST. Instead take a config key-value dictionary and evaluate the expression to return a boolean.
2025-05-31cargo: Fix cfg() parsingXavier Claessens1-0/+18
Add cfg token to be able to parse the top level cfg() function. Fix parser which was creating a new iterator when recursing which caused the caller function's iterator to not have advanced when recursing function returns.
2025-05-29rewriter: Rewrite how we add/remove source filesVolker Weißmann2-36/+83
Change the semantics of IntrospectionBuildTarget.source_nodes and IntrospectionBuildTarget.extra_files . The rewriter and the static introspection tool used to be very broken, now it is *less* broken, hence we add some tests in this commit. Fixes #11763
2025-05-29Add AstInterpreter.dataflow_dagVolker Weißmann1-0/+21
Make the AstInterpreter create a directed acyclic graph (called `dataflow_dag`) that stores the how the data flowes from one node in the AST to another. Add `AstInterpreter.node_to_runtime_value` which uses `dataflow_dag` to find what value a variable at runtime will have. We don't use dataflow_dag or node_to_runtime_value anywhere yet, but it will prove useful in future commits.
2025-05-29rewritetests.py: Ignore order of listed sourcesVolker Weißmann1-10/+22
The order in which the rewriter outputs the listed sources is more or less arbitrary anyways, so we ignore it to prevent the tests from breaking after small irrelevant changes.
2025-05-23options: process project options before machine optionsPaolo Bonzini1-0/+16
Restore the behavior from before commit d37d649b0 ("Make all Meson level options overridable per subproject.", 2025-02-13). The old code was: options: T.MutableMapping[OptionKey, T.Any] = OrderedDict() # process project default options for k, v in default_options.items(): if not subproject or k.subproject == subproject: options[k] = v # override them with machine default and command line options options.update(env.options) env.options = options Fixes: #14608 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-21options: accept compiler and built-in options in --reconfigure and "meson ↵Paolo Bonzini1-0/+4
configure" Follow the same logic that is used at the end of the first invocation. This fixes meson setup --reconfigure -Db_ndebug=true on a project that has no language that defines b_ndebug. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-21options: commonize code to accept unknown optionsPaolo Bonzini1-0/+11
The check for unknown options is duplicated in OptionStore and MesonApp. Place the better version of the two as a new method of OptionStore, and use it in OptionStore.validate_cmd_line_options. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-21compilers: add option for ignoring system dirsDavid Seifert1-2/+2
2025-05-15unittests: add minimal coverage of --buildtype=customPaolo Bonzini1-2/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-15add test case for setting options from reconfigurePaolo Bonzini1-0/+10
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-15unittests: add test for CFLAGS in linker command linePaolo Bonzini1-0/+16
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-14devenv: do not use os.execv on WindowsCharles Brunet1-0/+4
On Windows, os.execv spawn the process in background and returns 0. Therefore, it prevents devenv to return proper exit code from the called process. (see https://github.com/python/cpython/issues/63323 for reference.) The solution is to call subprocess.run instead, on Windows, at the price of keeping the meson python process alive while the devenv subprocess runs.
2025-05-07options: fix "deprecated" with dictionary argument and non-string typesPaolo Bonzini1-0/+11
Since opt.deprecated is a dictionary with string keys, the lookup must use str() around the user-provided value; with some care because booleans will be the meson-ic 'true' and 'false' instead of Python's 'True' and 'False'. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-01unittests: smoke test the backend optionsPaolo Bonzini1-1/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-29unittests: fix overly loose regex in tests for `--slice=` optionPatrick Steinhardt1-1/+1
The unit tests for the `meson test --slice=` option check that the option is working by extracting all tests that have been run from the command output. This is done with a rather loose regular expression "test-[0-9]*", which can easily match other parts of the output, as well. One user for example reported that the test broke because they were executing tests in a directory called "meson-test-1.8.0-build", and given that the "test-1" part of that directory matches the regular expression we have too many matches. Fix the issue by tightening the regex so that is way less likely to match anything from the host's build environment. Reported-by: Dominique Leuenberger <dleuenberger@suse.com> Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-04-24interpreter: do not use pathlib for DependencyVariableString creationPaolo Bonzini1-0/+12
Path.is_dir() can raise a PermissionError if a parent does not have the executable permission set; plus the "in p.parents" tests are very expensive. Do not use Path at all. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>