aboutsummaryrefslogtreecommitdiff
path: root/unittests
AgeCommit message (Collapse)AuthorFilesLines
4 daysoptions: put back in place 1.7 ordering of opt=value vs subp:opt=valuePaolo Bonzini1-10/+3
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 daystests: Fix shutil.which shim signature not accepting kwargsL. E. Segovia1-2/+2
13 daysvsenv: Ignore errors when parsing multiline env valuesXavier Claessens1-0/+6
2025-08-29Fix Cygwin test failure.Jussi Pakkanen1-1/+2
2025-08-28python: add a python.build_config option (PEP 739)Filipe Laíns1-0/+116
Signed-off-by: Filipe Laíns <lains@riseup.net> Signed-off-by: Michał Górny <mgorny@quansight.com>
2025-08-27options: do not raise exception for unknown options in -U commandPaolo Bonzini1-0/+5
Fixes: #14956 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-08-18Revert "backends: Use POSIX paths for target paths"Jussi Pakkanen1-38/+37
This reverts commit 12563f74a9f3dda70dcd4778aa958de355d1fae7.
2025-08-11Revert "build: Throw an error instead of warning for sourceless targets"Eli Schwartz1-1/+1
This reverts commit 651aede977179c5fe382744e3dd91ca8e01d050c. This was most certainly not acceptable.
2025-08-11Condense test directory names.Jussi Pakkanen6-43/+43
2025-08-10build: Throw an error instead of warning for sourceless targetsFlorian "sp1rit"​1-1/+1
We might run into an assertion failure down the road, if we don't fail here. Specifically project('proj') executable('bin', 'header.h') will throw during the ninja generation.
2025-08-10options: ensure all build keys are changed to hostPaolo Bonzini1-0/+65
OptionStore.get_value did not change build keys to host when not cross-compiling. get_value_object_and_value_for also didn't when accessing self.augments. Make all accessors go through ensure_and_validate_key so that the conversion is done early. Otherwise, when "native: true" targets look up compiler options they do so with the "build.*" name, which does not exist when not cross compiling. This removes the distinction between get_value(), meant to be for global options, and get_value_for() which would be for project-specific options. While the distinction was added in commit d37d649b0 ("Make all Meson level options overridable per subproject.", 2025-02-13), it is not particularly useful and can be a source of bugs like the one in test_build_to_host_subproject testcase (corresponding to issue #14869). Fixes: #14869 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-08-10unittests: remove FakeCompilerOptionsPaolo Bonzini1-5/+1
It does not seem to be needed anymore, and the incomplete mock does not have for example the "yielding" attribute that is used by OptionStore.get_value_object_and_value_for. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-08-10rewriter: Accept UnknownValue() in more placesVolker Weißmann1-1/+15
Fixes #14840
2025-08-04build: fix introspection interpreter issue when project selects RustPaolo Bonzini1-0/+5
The introspection interpreter sometimes produces targets with no source files; BuildTarget will then pick a random compiler, according to the order in clink_langs. According to the comment in sort_clink, clink_langs are supposed to list languages from *lowest* to highest priority. However, process_compilers_late() process clink_langs in straight order and returns the first language; which is the one with lowest priority. This became visible with the addition of Rust to clink_langs, because Rust has limitation on the names of library targets, but the bug existed before. Fixes: e49f2f7283e1d9f18e2f5f54647c07287cd70339 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-08-01unittests/cargotests: add tests for workspace inheritancePaolo Bonzini1-1/+70
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-08-01cargo: 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>
2025-08-01unittests/cargotests: add tests for Cargo.toml parsingPaolo Bonzini1-0/+184
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-08-01unittests/cargotests: fix pylintPaolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-08-01Condense test directory names for 1.9.Jussi Pakkanen6-44/+44
2025-07-22mintro: 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.
2025-07-22unittests: 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