summaryrefslogtreecommitdiff
path: root/unittests
AgeCommit message (Collapse)Author
2025-12-18options: canonicalize to host options anything that is not per-machinePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-17dependencies: Require 'native' be passed in kwargsDylan Baker
This simplifies a bunch of cases, and likely fixes some annoying bugs in cross compile situations where should have been passing this and weren't.
2025-12-17dependencies: stop passing "language" as a keyword argumentDylan Baker
It's allowed in the `DependencyKeywordArguments` TypeDict already, so we now have two sources of truth. Additionally, it's often populated by reading from that dict, so we're just doing useless work.
2025-12-15cargo: add --check-cfg cfg(test) unconditionallyPaolo Bonzini
It should be added even if unexpected_cfgs is not part of Cargo.toml. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-01templates: fix remaining languages for source file discovery tooSam James
I missed this in 9104bb616766bd9a05f0b2f280359463d32e227d as we were only testing whitelisted languages for source file discovery. Tests now handle all of these by using the map we have in compilers, as we need to know the suffix to use for the invalid source files we inject. Note that for tests, we mix explicit --lang in some cases and not others, which we could probably do better with. For these 'must fail' tests, I've stuck with explicit `--lang` to make sure we're testing what we want, but the others are perhaps up for debate. Bug: https://github.com/mesonbuild/meson/issues/15286
2025-12-01templates: sort langs in testSam James
2025-12-01templates: fix --executableSam James
* In 1.7.1, the behaviour of --executable was to just ignore it. * After my recent 9104bb616766bd9a05f0b2f280359463d32e227d, the behaviour was that we'd require, for --executable xyz, xyz.c to exist or we'd fail to generate. Neither are good! Instead, create the sample source file w/ the project name, but call the executable whatever the user passed with `--executable`. Bug: https://github.com/mesonbuild/meson/issues/15286
2025-12-01templates: refactor tests to have a bit less nestingSam James
Use `itertools.product()` to reduce an indentation level or two, though we lose one again by changing to a function for fresh vs dirty. I plan on adding more to these tests and it makes it a bit more manageable. Best-viewed-with: --ignore-all-space
2025-11-23Condense directory names for rc1.Jussi Pakkanen
2025-11-23templates: respect parametersSam James
Respect collected sources for `meson init` as well as --executable. This regressed in 9f0ac314ba0c54cc18c2499845324efc14c1849e (part of https://github.com/mesonbuild/meson/pull/14086, it's easier to see how with the whole PR). Also, add subtests (distinguishing between empty directories and those with some file(s) within). We already had some of these but they weren't marked as such. Test `meson init` with a broken source file in the source directory as we should fail with that, not ignore the file. It's easier to test with a broken file than a working one as we can assert the build should fail, it'll pass with just the 1 example file we generate. Closes: https://github.com/mesonbuild/meson/issues/15286
2025-11-21rewrite: fix duplicate objects for predefined globalsPaolo Bonzini
Global objects are treated as UnknownValue(), but unlike other variables their object is created on every call to get_cur_value_if_defined() instead of coming from a dictionary. This causes the dataflow DAG to have multiple objects from the same object. Fix this by building the UnknownValues at interpreter construction time. Fixes: #15261 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-19compilers: Remove Environment parameter from CLikeCompiler.gen_dynamic_link_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from ↵Dylan Baker
Compiler.symbols_have_underscore_prefix
2025-11-19compilers: Remove Environment parameter from Compiler.find_libraryDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_library_namingDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.sanity_checkDylan Baker
2025-11-19linkers: Store a reference to the Environment in the DynamicLinkerDylan Baker
For the same reason that the StaticLinker needs this, we need it in the DynamicLinker as well.
2025-11-19compilers: Stop passing `is_cross`Dylan Baker
This is calculated by `Environment().is_cross_build(for_machine)`. Since we have that in the Compiler class, just calculate it in the Compiler initializer
2025-11-19compilers: Pass Environment instead of MachineInfoDylan Baker
We end up needing it everywhere, so just store it. This patch is huge already, so it's just the conversion to passing Environment, more cleanups to come.
2025-11-19tests: Fix regex in test_sliceMarkus Jörg
If the first line already conained a match, the former regex didn't catch it correctly, because it was looking for a newline character to detect the start of a line. The new regex is using the proper `^` to match the beginning of a line. For this to work as expected the `re.MULTILINE` flag has to be set.
2025-11-19options: the parent of a yielding option can be falsyPaolo Bonzini
Fixes: #15258
2025-11-18rewriter: fix kwargs info for dict-valued kwargsBenjamin Gilbert
We can't modify dict-valued kwargs (#14739) but this lets us at least read them.
2025-11-18rewriter: support project(license_files: )Benjamin Gilbert
2025-11-17mtest: add convenience key to testlog.json for "is a failure"Eli Schwartz
This info is also available from the "result" entry, but requires mapping result types to "would cause a failure, but isn't literally FAIL". It comes in handy for the meson testsuite, too.
2025-11-12rust: allow linking with sanitizer-enabled C librariesPaolo Bonzini
Fixes: #15222 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-11compilers: support prelinking with ClangAlois Wohlschlager
Clang supports prelinking using the same `-r` flag as GCC. There has been prior art in [1], which stalled at the time due to Clang inappropriately trying (and failing) to link libgcc_s. This issue does not occur any more with versions 14 and higher. [1] https://github.com/mesonbuild/meson/pull/8883
2025-11-03backends: add CustomTargetIndexes to meson-{test,benchmark}-prereqPaolo Bonzini
If a CustomTargetIndex is passed as an argument to a test, running meson test (with no test glob) does not automatically build the custom_target before running the test, because CustomTargetIndex outputs are not added as prerequisites to the meson-test-prereq and meson-benchmark-prereq targets. Fixes: #14743 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-31Always check if found libraries are linkableSam James
We don't always check if a library is actually linkable because of concerns that a library may not be standalone, so linking against it may still have unresolved references. We can workaround that by building a shared library as a test rather than an executable, and in fact we already do that in a bunch of cases since bb5f2ca3da821d7a8e865cd55a8d5d638e0aab22. This comes up in particular with Fedora and dependency('atomic') because on x86_64, they provide a libatomic.so linker script (so our file existence check passes), but trying to use it later on will fail if the backing package isn't installed. _get_file_from_list has not been deleted because the Ninja backend's guess_library_absolute_path uses it. We might be able to change it to also use a link test but I've left that alone. Test notes: * The _test_all_naming unittest has been tweaked because we were using a blank file rather than an actual shared library, which (as expected), now fails. * I've also added a test for dependency('atomic') providing a result that can actually be linked against. I've not made it check generally whether dependency('atomic') finds something when we expect to (at least for now) as it'll involve some CI whack-a-mole. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=2352531 Bug: https://github.com/mesonbuild/meson/issues/14946 Closes: https://github.com/mesonbuild/meson/issues/10936
2025-10-29options: rename get_value_object_and_value_forPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-29environment: move tool detection functions to a new modulePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-29environment: move detection functions to envconfig.pyPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-23cargo: fix proc-macro=true without crate_typePaolo Bonzini
The default value is not passed further through the converter, therefore it must take proc-macro into account. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-23cargo: generate lint arguments from tablePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-23cargo: parse lints tablePaolo Bonzini
The lints table in Cargo.toml has a very human-targeted syntax. When building manifest.from_raw, flatten everything into a single list, prefixing the tool name to every warning option and sorting by priority. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-23cargo: remove duplicate proc_macro fieldPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-23mtest: Display test name in format expected by "meson test" argumentXavier Claessens
This makes easier to run a single test after running them all. For example the test "test_accsadubl" in the suite "default" of project "orc" used to be displayed "orc:default / test_accsadubl". To run that test specifically the command line is `meson test -C builddir orc:test_accsadubl --suite default`. To make this more consistent the test is now displayed as "default - orc:test_accsadubl".
2025-10-23mtest: Fix test selection implementationXavier Claessens
Omitting test()'s `suite` kwarg used to default to `test.suite==['']` because of how stringlistify() works. That had inconsistent behavior with `suite: []` which makes `test.suite==[]`. That changed when porting to typed_kwarg (#8855), which made the default `test.suite==[]`. Change `suite: []`, and missing kwarg, back to `test.suite==['']` which was the original intention. It has impact on `meson test --suite` selection, an empty `test.suite` list means that test is never going to be selected when `--suite` is used, even when we want all tests from a given subproject. It was also unclear what `--suite foo` means. Is `foo` a suite or a project name? It can now be either, it selects all tests from project `foo` as well as all tests from any project in suite `foo`.
2025-10-23cargo: convert proc_macro to crate_type in Library dataclass.Paolo Bonzini
Do not look anymore at proc_macro after init, keeping crate_type as the sole source of truth about the desired crate types.
2025-10-22cargo: Move all conversions in _raw_to_dataclass()Xavier Claessens
This allows keeping the manifest unmodified which is better practice for a parser. Previously some places had e.g. raw.setdefault(). It also fix some values: - BuildTarget.doc_scrape_examples is removed. It seems to be some experimental cargo feature, but I haven't found documentation that says it should be part of the manifest. It was also missing from raw manifest. - BuildTarget.edition does not default to 2015, it default to package's edition, which itself default to 2015. - bench value defaults to False for tests. - Dependency.path must be relative to its Cargo.toml location. If the value comes from the package it can be used as-is, but if it comes from workspace it must be made relative. - Library.name default to its package name with dash replaced with underscores.
2025-10-20interpreter: port dependency version to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency static to typed_kwargsDylan Baker
Static must be optional, because although the default is static=false, we special case that static : false is different than static being not set in a number of cases.
2025-10-20interpreter: port dependency required to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency modules to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency method to typed_kwargsDylan Baker
This allows us a bunch of nice things: 1. We can use the DependencyMethods enum everywhere 2. The deprecated methods can be checked in the Interpreter, so we can now emit deprecation warnings for stuff that was deperecated in 0.44! 3. We can share this more strongly typed method everywhere
2025-10-17cargo: raw.Manifest can be any Cargo.tomlXavier Claessens
raw.Manifest represents any Cargo.toml file, a package, a workspace, or both. However, the Manifest dataclass can only be a package, and the Workspace dataclass is a workspace with an optional root package.
2025-10-17options: Fix long/short option mixture detectionTobias Stoeckmann
Take the key/value separator `=` into account when comparing long and short option names to avoid invalid matches.
2025-10-14cargo: load a single Cargo.lock for a whole chain of subprojectsPaolo Bonzini
When processing cargo subprojects, each Resolver was independently loading Cargo.lock files, leading to duplicate wraps and errors like 'Multiple wrap files provide dependency'. Instead, build the cargo.Interpreter as soon as a Cargo.lock file is found, and merge that Cargo.lock into the wrap resolver. There is no need anymore to build a separate resolver for the dependent packages, because their indirect dependencies are all listed in the parent lockfile.
2025-10-14cargo: When loading wraps multiple packages can have the same URLXavier Claessens
This avoids cloning the same repo multiple times, instead a single wrap can provide multiple cargo dependencies.
2025-10-06compilers: do not use coredata.set_optionsPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06unittests: do not use coredata.set_optionPaolo Bonzini
optstore is able to set buildtype correctly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>