aboutsummaryrefslogtreecommitdiff
path: root/unittests
AgeCommit message (Collapse)AuthorFilesLines
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>
2025-04-24options: subproject system options require the global onesPaolo Bonzini1-0/+14
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 Bonzini1-0/+30
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 Pakkanen6-38/+38
2025-04-08coredata: delete set_default_optionsDylan Baker1-1/+0
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 Baker1-0/+15
"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 Baker1-1/+1
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 Baker1-2/+0
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 Baker1-0/+40
Because we don't set the appropriate dependencies
2025-04-03tests: demonstrate that our scanner cannot handle cross target modulesDylan Baker2-3/+20
2025-04-02unittests: use more subtestsDylan Baker1-9/+11
2025-04-02rust: new target rustdocPaolo Bonzini1-0/+18
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 Turney2-18/+0
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 Brunet1-93/+93
2025-03-14Move variables to InterpreterBaseCharles Brunet1-1/+1
subproject_dir, environment, and coredata
2025-03-10options: merge set_value and set_optionDylan Baker1-2/+2
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 Steinhardt2-2/+25
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 Brunet1-0/+3
2025-03-06options: delete unused set_subproject_optionsDylan Baker1-23/+0
2025-03-06unittests: Use more subtestsDylan Baker3-57/+73
2025-03-05options: Remove BuiltinOption classDylan Baker1-2/+8
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 Baker1-1/+2
2025-03-04OptionStore: remove unused build_options attributeDylan Baker1-3/+1
2025-03-04msetup: remove bad warning about unused optionsDylan Baker1-5/+8
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 Baker1-1/+1
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 Pakkanen1-1/+1
2025-02-27optstore: remove num_optionsDylan Baker1-8/+14
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 Pakkanen1-0/+5
Closes: #14255.
2025-02-27test: fix hang when running tests that need parsing with `--interactive`Patrick Steinhardt1-0/+8
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 Steinhardt1-0/+29
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 Pakkanen1-0/+16
Closes #14281.
2025-02-22Permit all unknown b_ options.Jussi Pakkanen1-3/+6
Closes #14254.
2025-02-20Fix reconfiguration on --wipe.Jussi Pakkanen1-0/+5
Closes #14279.
2025-02-15Permit more missing b options. Closes #14254.Jussi Pakkanen1-0/+5
2025-02-13Make all Meson level options overridable per subproject.Jussi Pakkanen7-48/+322
2025-02-04ci: Update appleclang job to test Xcode-provided PythonL. E. Segovia1-1/+1
2025-02-04unittests: Unbreak Python bytecompile tests with Xcode PythonL. E. Segovia1-2/+7
Apple sets sys.pycache_prefix to an user-wide cache folder, so it needs to be prepended to the root for the glob to work correctly.