summaryrefslogtreecommitdiff
path: root/unittests
AgeCommit message (Collapse)Author
2025-06-05unittests: use subtests to break up test_compiler_detectionDylan Baker
Which is a very large and complicated test function
2025-06-05Add ELD linkerKushal Pal
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"​
DirectoryLock provides a generic locking implementation the replaces the previously used BuildDirLock.
2025-05-31cargo: Do not convert cfg() to Meson ASTXavier Claessens
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 Claessens
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ßmann
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ßmann
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ßmann
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 Bonzini
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 Bonzini
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 Bonzini
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 Seifert
2025-05-15unittests: add minimal coverage of --buildtype=customPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-15add test case for setting options from reconfigurePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-15unittests: add test for CFLAGS in linker command linePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-14devenv: do not use os.execv on WindowsCharles Brunet
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 Bonzini
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 Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-29unittests: fix overly loose regex in tests for `--slice=` optionPatrick Steinhardt
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 Bonzini
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>
2025-04-24options: subproject system options require the global onesPaolo Bonzini
Because system options apply to all subprojects, they need to be present globally whenever a subproject needs them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-18fix prefix computation in validate_original_argsPaolo Bonzini
validate_original_args only checks whether an option is prefixed with the name of a built-in option that was also set. It does not check whether the prefix is the full name of the option specified with -D. Adding an "=" at the end fixes the test. Fixes: #14487 Reported-by: Alyssa Ross <hi@alyssa.is> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-14Condense directory names for 1.8 rc1.Jussi Pakkanen
2025-04-08coredata: delete set_default_optionsDylan Baker
This was only being used by the introspection interpreter, which meant the two interpreters had different behavior. They still do, which is really bad because the IntrospectionInterpreter doesn't have the command line options or project_default_options. I have a plan to fix that later, and I don't want to spend time on it here, as it's not a regression of this patch, it's just the status quo. This also fixes an issue caused by dead code being left, and hit, due to the option refactor branch. Fixes: #14382
2025-04-08tests: Add a rewriter test that handles prefixDylan Baker
"prefix" has a lot of special handling that has to go on because so many other options depend on prefix. It was also regressed by the option refactor changes, so having a test feels appropriate. This was verified against the 1.7 release, so it has the same behavior as pre-option refactor Meson.
2025-04-08options: fix typing issues stemming from initialize_from_top_level_project_callDylan Baker
Machine files provide a `Mapping[OptionKey, ElementaryOptionValues]`, but the expectation listed was that they provided options in the raw DSL format.
2025-04-03backend/ninja: Fortran targets need to -I transitive deps private dirsDylan Baker
Otherwise they won't be able to find their module outputs. This requires a new method to look at dependencies, as the existing ones wont find static libraries that were linked statically into previous targets (this links with A which link_whole's B). We still need to have B in that case because we need it's BMI outputs.
2025-04-03tests: our fortran order deps are wrong if a new module is introducedDylan Baker
Because we don't set the appropriate dependencies
2025-04-03tests: demonstrate that our scanner cannot handle cross target modulesDylan Baker
2025-04-02unittests: use more subtestsDylan Baker
2025-04-02rust: new target rustdocPaolo Bonzini
Another rust tool, another rough copy of the code to run clippy. Apart from the slightly different command lines, the output is in a directory and test targets are skipped. Knowing the output directory can be useful, so print that on successful execution of rustdoc. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-03-21CI: Fix filemode tests with cygwin 3.6.0Jon Turney
Put cygwin filemode tests back under the sourcedir Remove inheritable permissions from the sourcedir For :reasons:, the unit tests which check file mode were built in the tempdir. Instead, remove inheritable permissions from the working directory (which the GitHub VM image has set for some reaons), since they can interfere with getting exactly the file mode you asked for. Partially reverts 04ae1cfb7999e25f476f84572ff0ad853629346c
2025-03-14Add subTests to test_introspect_json_dumpCharles Brunet
2025-03-14Move variables to InterpreterBaseCharles Brunet
subproject_dir, environment, and coredata
2025-03-10options: merge set_value and set_optionDylan Baker
Which are basically the same, except for handling of deprecated options, and various bugs that only existed in one implementation or the other.
2025-03-09compilers: convert `b_sanitize` to a free-form array optionPatrick Steinhardt
In the preceding commit we have started to perform compiler checks for the value of `b_sanitize`, which allows us to detect sanitizers that aren't supported by the compiler toolchain. But we haven't yet loosened the option itself to accept arbitrary values, so until now it's still only possible to pass sanitizer combinations known by Meson, which is quite restrictive. Lift that restriction by adapting the `b_sanitize` option to become a free-form array. Like this, users can pass whatever combination of comma-separated sanitizers to Meson, which will then figure out whether that combination is supported via the compiler checks. This lifts a couple of restrictions and makes the supporting infrastructure way more future proof. A couple of notes regarding backwards compatibility: - All previous values of `b_sanitize` will remain valid as the syntax for free-form array values and valid combo choices is the same. We also treat 'none' specially so that we know to convert it into an empty array. - Even though the option has been converted into a free-form array, callers of `get_option('b_sanitize')` continue to get a string as value. We may eventually want to introduce a kwarg to alter this behaviour, but for now it is expected to be good enough for most use cases. Fixes #8283 Fixes #7761 Fixes #5154 Fixes #1582 Co-authored-by: Dylan Baker <dylan@pnwbakers.com> Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-03-09Add cache to coredata.get_external_link_argsCharles Brunet
2025-03-06options: delete unused set_subproject_optionsDylan Baker
2025-03-06unittests: Use more subtestsDylan Baker
2025-03-05options: Remove BuiltinOption classDylan Baker
It basically served two purposes, to allow us to initialize UserOptions, and to convert those options into Argparse values. The latter has been transformed into a standalone function, the former can be easily achieved without this class. This reduces LOC, simplifies setup, and helps with our type safety.
2025-03-05unittests: use subtests for test_Builtin_options_documentedDylan Baker
2025-03-04OptionStore: remove unused build_options attributeDylan Baker
2025-03-04msetup: remove bad warning about unused optionsDylan Baker
This is just a bad warning, while it *could* give the user useful information, it often doesn't since it can get values to warn about from: - environment variables - the command line - machine files - `project(default_options : ...)` - `subproject(default_options : ...)` - `dependency(default_options : ...)` The problem of course is that user may have no control over these values. 3 of them are hardcoded into the meson.build files, so the user can't do anything about them. And there are legitimate reasons to have unused values in those, like setting defaults for a language only used on specific platforms. Environment variables may be set by the distro (NixOS sets them for any enabled language, so just having a D compiler causes `DFLAGS` to be set, for example). They likely don't want to special case "only set the environment variables if the project is going to use them". For machine files it limits the utility of the files, since the user needs to be sure that they don't include any options that wont be used. Finally, the command line could be altered by wrapper scripts, or simply programmed to insert options that *may* be used but aren't required. like setting `objc_args` regardless of whether ObjectivC bindings are generated. However, passing completely unknown builtin options should be an error, as it was before the optionrefactor
2025-03-03options: use an OptionKey for `get_default_for_b_option`Dylan Baker
We have the OptionKey in the one caller that exists already, and this allows us to do a hash lookup instead of a linear walk.
2025-02-27Actually fix base option default values.Jussi Pakkanen
2025-02-27optstore: remove num_optionsDylan Baker
It's only used for unittests, so define it as a helper in the unit test module instead
2025-02-27Maintain bw compatibility for requesting bad options.Jussi Pakkanen
Closes: #14255.
2025-02-27test: fix hang when running tests that need parsing with `--interactive`Patrick Steinhardt
When running tests with `--interactive` we don't redirect stdin, stdout or stderr and instead pass them on to the user's console. This redirect causes us to hang in case the test in question needs parsing, like it is the case for TAP output, because we cannot read the process's stdout. Fix this hang by not parsing output when running in interactive mode. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-02-27mtest: add option to slice testsPatrick Steinhardt
Executing tests can take a very long time. As an example, the Git test suite on Windows takes around 4 hours to execute. The Git project has been working around the issue by splitting up CI jobs into multiple slices: one job creates the build artifacts, and then we spawn N test jobs with those artifacts, where each test job executes 1/Nth of the tests. This can be scripted rather easily by using `meson test --list`, selecting every Nth line, but there may be other projects that have a similar need. Wire up a new option "--slice i/n" to `meson test` that does implements this logic. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-02-22Fix yielding when top project does not define the option.Jussi Pakkanen
Closes #14281.