aboutsummaryrefslogtreecommitdiff
path: root/unittests
AgeCommit message (Collapse)AuthorFilesLines
2024-06-05Add -export_dynamic flag for AppleDynamicLinkerWolfgang Walther1-0/+12
The apple linker uses -export_dynamic instead of --export-dynamic [1]. This should be set when setting export_dynamic: true. Resolves #13290 [1]: https://opensource.apple.com/source/ld64/ld64-609/doc/man/man1/ld.1.auto.html
2024-06-04Extract native file parser to machinefile source file.Jussi Pakkanen2-2/+2
2024-06-02Create a directory for machine files used in unit tests.Jussi Pakkanen3-34/+31
2024-06-02Start moving machine files to their own store.Jussi Pakkanen1-1/+12
2024-05-23Refactor option classes to their own file.Jussi Pakkanen2-3/+4
2024-05-09implement @PLAINNAME0@ and @BASENAME0@Stas Sergeev1-1/+10
@PLAINNAME@ and @BASENAME@ cannot be used in custom_target() with multiple inputs. For those, similar macros are needed with an index. Fixes #13164
2024-04-27mdist: gracefully handle stale Git indexBenjamin Gilbert1-1/+4
Running `touch` on a tracked file in Git, to update its timestamp, and then running `meson dist` would cause dist to fail: ERROR: Repository has uncommitted changes that will not be included in the dist tarball Use --allow-dirty to ignore the warning and proceed anyway Unlike `git status` and `git diff`, `git diff-index` doesn't refresh the index before comparing, so stat changes are assumed to imply content changes. Run `git update-index -q --refresh` first to refresh the index. Fixes: #12985
2024-04-15Add bztar support to meson distTristan Partin1-1/+13
Some projects, like Postgres, distribute code in this format.
2024-04-14Fix builds with Ninja 12 and remove a 5 year old workaround.Jussi Pakkanen1-4/+1
2024-04-09modules: rename qt.py -> _qt.pyDylan Baker1-1/+1
Since it's an implementation detail, and shouldn't be exposed. This also helps give better error messages when a user writes `import('qt')`, since otherwise you get an error about `qt doesn't have an initialize method`, and now you get `qt module doesn't exist`.
2024-04-08meson format commandCharles Brunet2-0/+44
2024-04-08parser: revert to single StringNode typeCharles Brunet1-1/+0
this will allow transforming string types in the formater
2024-03-18mconf: Reload the options files if they have changedDylan Baker1-9/+1
This fixes issues where a new option is added, an option is removed, the constraints of an option are changed, an option file is added where one didn't previously exist, an option file is deleted, or it is renamed between meson_options.txt and meson.options There is one case that is known to not work, but it's probably a less common case, which is setting options for an unconfigured subproject. We could probably make that work in some cases, but I don't think it makes sense to download a wrap during meson configure.
2024-03-18tests: Add tests for configure on changed optionsDylan Baker1-1/+102
This demonstrates a limitation of Meson that can happen in the following situation: `meson setup builddir` <update to meson.options> (such as git pull) `meson configure -Dnew_option=value builddir` <Error> Since Meson is unaware of the updates to the meson.options file. The purposes of these tests is to fix this behavior.
2024-03-18unittests: annotate BasePlatformTests.setconfDylan Baker1-2/+4
2024-03-15tests: Fix unit tests with high parallelismJan Alexander Steffens (heftig)1-12/+9
On Arch's shiny new 48-core/96-thread build server, the `test_install_log_content` test fails because of an unexpected `invalid-symlink.txt` file. Apparently the test runs in parallel with `test_install_subdir_symlinks`, which modifies the `59 install subdir` source directory. To fix this, make `install_subdir_invalid_symlinks` copy the entire test into a tmpdir before modifying it.
2024-03-15unittests: Add a helper for copying source treesDylan Baker1-0/+23
This is a useful thing to do when a test needs to modify the source tree, as it prevents races between tests.
2024-03-15Improve error messages for invalid option valuesCharles Brunet1-1/+22
By adding the option name to UserOption object, it is now possible to display the name of the affected option when the given option value is not valid. Fixes #12635
2024-03-10fix reconfigure subproject base optionsCharles Brunet2-8/+10
2024-03-10Fix detection of unknown base options in subprojCharles Brunet1-1/+1
cc4cfbcad92945a1629c80664e1eb755c68905dd added detection for unknown base options, but it was not working for subproject base options. This should fix it.
2024-03-03Condense test dirs for rc2.Jussi Pakkanen1-3/+3
2024-03-03compilers: only wrap multiple input libraries with start/end groupEli Schwartz1-3/+3
When only a single input file shows up in an arglist, it makes no sense to inject `-W,--start-group -lone -Wl,--end-group`, since there is nothing being grouped together. It's just longer command lines for nothing.
2024-03-01Fix unknown base options not detected in commandline argumentsCharles Brunet2-1/+8
2024-03-01Fix base and compiler options not reconfigurable.Charles Brunet1-0/+10
Fixes #12920.
2024-03-01Set PYTHONIOENCODING when running testsCharles Brunet2-1/+2
For instance, on Windows, if the terminal is in cp65001, the subprocess output is not encoded correctly and it results in error when running unit test.
2024-01-25interpreter: replace mock keyword argument with unittest.mockDylan Baker2-5/+15
Python provides some nifty tools for mocking, without relying on altering running code. We should use these to simplify the actual run paths and move the complicated logic into tests.
2024-01-17tests: Also test implicit rpaths from dependenciesJonathon Anderson1-0/+92
Meson will implicit rpaths when *.so/*.dll/etc. files are injected onto the link line from pkg-config and (now) cmake dependencies. Extend the "prebuilt shared" tests to test that these are added.
2023-12-17Skip pkg-config-dependent tests if it's missingAlyssa Ross2-3/+7
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker15-182/+17
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field
2023-12-13macos: Fix test_pkgconfig_parse_libs() test on armAndres Freund1-1/+2
The unit test infrastructure hardcodes the architecture as x86_64. On macos, the test_pkgconfig_parse_libs() test creates a few libraries for testing using clang. This leads to the test failing on arm based macs, as darwin_get_object_archs() will skip over these libraries, which then leads to the test failing because of using -l instead of referencing the libraries by their full path. I am not at all sure this is the best approach. I am also somewhat confused why nobody else has encountered this? CI apparently just runs on x86_64 macs? CC: @tristan957
2023-12-10unittests: migrate from jsonschema to fastjsonschemaEli Schwartz1-8/+19
The former has rust dependencies, which lead to max capping on Cygwin since there is no rust compiler there. But it turns out there are other disadvantages of jsonschema: - it involves installing 5 wheels, instead of just 1 - it is much slower To give some perspective to the latter issue, this is what it looks like when I test with jsonschema: ``` ===== 1 passed, 509 deselected in 3.07s ===== Total time: 3.341 seconds ``` And here's what it looks like when I test with fastjsonschema: ``` ===== 1 passed, 509 deselected, 1 warning in 0.28s ===== Total time: 0.550 seconds ``` I cannot think of a good reason to use the former. Although in order to work on old CI images, we'll support it as a fallback mechanism
2023-12-05ninja backend: don't hide all compiler warnings for transpiled languagesEli Schwartz1-37/+0
This was originally added for vala only, with the rationale that vala generates bad code that has warnings. Unfortunately, the rationale was fatally flawed. The compiler warns about a number of things, which the user can control depending on their code (or their code generator's code), but some of those things are absolutely critical to warn about. In particular, GCC 14 and clang 17 are updating their defaults to warn -- and error by default for -- invalid C code that breaks the standard, but has been silently accepted for over 20 years "because lots of people do it". The code in question is UB, and compilers will generate faulty machine code that behaves erroneously and probably has a mass of CVEs waiting to happen. Compiler warnings are NOT safe to just... universally turn off. Compiler warnings could be either: - coding style lints - threatening statements that the code is factually and behaviorally wrong There is no magic bullet to ignore the former while respecting the latter. And the very last thing we should ever do is pass `-w`, since that causes ALL warnings to be disabled, even the manually added `-Werror=XXX`. If vala generated code creates warnings, then the vala compiler can decrease the log level by generating better code, or by adding warning suppression pragmas for *specific* issues, such as unused functions.
2023-12-03macos: Fix path in test to be Sonoma compatibleAndres Freund1-1/+1
The path tested prior does not exist anymore in Sonoma. It seems less likely that 'cat' will be removed, so use that.
2023-11-12Renumber test dirs for rc3.Jussi Pakkanen3-17/+17
2023-11-04Fine-tune the error message when trying to build outside the project rootEli Schwartz1-0/+8
We try to backtrack through the filesystem to find the correct directory to build in, and suggest this as a possible diagnostic. However, our current heuristic relies on parsing the raw file with string matching to see if it starts with `project(`, and this may or may not actually work. Instead, do a bit of recursion and parse each candidate with mparser, then check if the first node of *that* file is a project() function. This makes us resilient to a common case: where the root meson.build is entirely valid, but, the first line is a comment containing e.g. SPDX license headers and a simple string comparison simply does not cut it. Fixes the bad error message from #12441, which was supposed to provide more guidance but did not.
2023-10-27Condense test directories for RC1.Jussi Pakkanen6-31/+31
2023-10-20modules/rust: Add a test that bindgen drops arguments it shouldn't useDylan Baker1-0/+28
This does require hacking up the test pretty badly, since we need to not ever pass GCC these invalid values. But it's preferable to writing another project test I think. Co-Authored-by: Nirbheek Chauhan <nirbheek@centricular.com>
2023-10-09cargo: Fix '1.0.45' version conversionXavier Claessens1-2/+3
The middle 0 was wrongly dropped.
2023-10-09cargo: builder: Remove all duplicated functionsXavier Claessens1-51/+51
Keep only the Builder class, there is no point in duplicating everything.
2023-10-09interpreter: add <lang>_(static|shared)_argsDylan Baker1-1/+1
Which allow passing arguments specifically to the static or shared libraries. For design, this is all handled in the interpreter, by the build layer the arguments are combined into the existing fields. This limits changes required in the mid and backend layers
2023-10-09Allow c++23 in gcc-11.Benjamin Redelings1-2/+2
2023-10-05mcompile: add suffix as an additional parameterDudemanguy1-0/+9
Since the previous commit allows for more scenarios with name collisions, it makes sense to expand the compile command so that it can also take into account suffixes. i.e. meson compile -C build foo.exe can now work if the executable has an exe suffix along with being named foo.
2023-10-05build: use suffix when getting target id for exesDudemanguy1-0/+10
When checking target names, meson explictly forbids having multiple targets with the same name. This is good, but it is strict and it is impossible to have targets with the same basename and differing suffixes (e.g. foo and foo.bin) in the same directory. Allow this for executables by including the suffix (if it exists) in the interal target id. So foo would be foo@exe and foo.bin would be foo.bin@exe.
2023-10-04Remove type comments in run_project_tests.pyTristan Partin1-1/+1
2023-09-28unittest: Fix clang-tidy-fixLei YU2-10/+18
The unittest case for `clang-tidy-fix` checks if the whole project is in git or not, and skips if not. Fix this by creating a temporary git repo, copy the test files and run the tests, following how `clang-format` does. It also reverts some help code introduced in the previous test. Tested: Verify the test case passes. Signed-off-by: Lei YU <yulei.sh@bytedance.com>
2023-09-26compilers: use correct version comparison for openbsd librariesEli Schwartz1-1/+4
It should *be* a version comparison. We are guaranteed to get a two-element version number, which also parses as a float but a float doesn't correctly handle version sorting when the second component differs in number of digits. The standard way to handle this is by comparing tuples such that each component is an integer. Do so here. Fixes #12195 Co-authored-by: George Koehler <xkernigh@netscape.net> (for unittests)
2023-09-25Add clang-tidy-fix targetLei YU2-2/+25
Add the `clang-tidy-fix` target to apply clang-tidy fixes to the source code. This is done by calling `run-clang-tidy` with `-fix` argument. Add a test case to run `clang-tidy-fix` and verify the file is changed. Signed-off-by: Lei YU <yulei.sh@bytedance.com>
2023-09-18pkgconfig: Set PKG_CONFIG in env for devenv and g-ir-scannerXavier Claessens1-2/+2
2023-09-18pkgconfig: Restore logging of pkg-config versionXavier Claessens1-1/+1
While at it, make more methods private by storing the version found on the instance. That avoids having to call check_pkgconfig() as static method from unittests.
2023-09-18Remove get_configtool_variable()Xavier Claessens1-1/+1
This also makes it more consistent with get_pkgconfig_variable() which always return empty value instead of failing when the variable does not exist. Linking that to self.required makes no sense and was never documented any way.