aboutsummaryrefslogtreecommitdiff
path: root/unittests
AgeCommit message (Collapse)AuthorFilesLines
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.
2023-09-18Remove get_pkgconfig_variable()Xavier Claessens2-7/+7
Make sure that pkgconfig_define is a pair of strings and not a list with more than 2 strings.
2023-09-14Revert "tests: skip a test that fails with new Python 3.11 from MSYS2"Christoph Reiter1-3/+0
This reverts commit 68dce66bf9a2bcb3d23c291beb2354225a74b954. The upstream issues https://github.com/msys2-contrib/cpython-mingw/issues/141 has been fixed now.
2023-09-12Merge pull request #12152 from bruchar1/ast-preserve-allJussi Pakkanen1-0/+22
Preserve whitespaces and comments in AST
2023-09-12fix bug with openssl when cmake is missingCharles Brunet1-0/+7
Fixes #12098 DependencyFactory was returning a lambda, but it has no log_tried() function
2023-09-11raw printerCharles Brunet1-0/+22
this printer preserves all whitespaces and comments in original meson.build file. It will be useful for rewrite and potential auto-formatter
2023-09-05wrap: Use MESON_PACKAGE_CACHE_DIR as default packagecache pathXavier Claessens1-0/+10
Allow packagecache to contain already extracted directory to match what some distro does with Cargo source packages in /usr/share/cargo/registry. Note that there is no need to lock the cache directory because we download into a temporary name and atomically rename afterward. It means we could be downloading the same file twice, but at least integrity is guaranteed. Fixes: #12211
2023-08-30Merge pull request #10332 from xclaesse/std-optJussi Pakkanen1-0/+33
c_std, cpp_std: Change to a list of desired versions in preference order
2023-08-25msetup: Update options when builddir is already configuredXavier Claessens2-0/+14
`meson setup -Dfoo=bar builddir` command was returning success ignoring new option values. This now also update options. It is useful because it means `meson setup -Dfoo=bar builddir && ninja -C builddir` works regardless whether builddir already exists or not, and when done in a script, changing options in the script will automatically trigger a reconfigure if needed. This was already possible by always passing --reconfigure argument, but that triggers a reconfigure even when options did not change.
2023-08-23machine file: Add @GLOBAL_SOURCE_ROOT@ and @DIRNAME@Xavier Claessens1-1/+7
2023-08-18tests: fix assertion rewriting when pytest is usedBenoit Pierre1-0/+0
2023-08-17tests: consolidate MESON_SKIP_TEST reporting and use it in unittestsEli Schwartz1-7/+7
Previously, we only reported the skip reason when running project tests.
2023-08-17Remove XML filter from testlog.{json,txt} and std streamsTristan Partin1-4/+10
This was an unintended consequence of the original patch in #11977. Co-authored-by: Benoit Pierre <benoit.pierre@gmail.com>
2023-08-08correct cmakedefine behaviorJan2001011-3/+35
- allow defines with leading whitespace - always do replacement for cmakedefine - output boolean value for cmakedefine01 - correct unittests for cmakedefine - add cmakedefine specific unittests
2023-08-07Error when an installed static library links to internal custom targetXavier Claessens1-0/+3
When an installed static library A links to an internal static library B built using a custom_target(), raise an error instead of a warning. This is because to be usable, A needs to contain B which would require to extract the archive to get its objects files. This used to work, but was printing a warning and was installing a broken static library, because we used to overlink in many cases, and that got fixed in Meson 1.2.0. It now fails at link time with symbols from the custom target not being defined. It's better to turn the warning into a hard error at configure time. While at it, noticed this situation can happen for any internal custom or rust target we link to, recursively. get_internal_static_libraries_recurse() could be called on CustomTarget objects which do not implement it, and even if we did not call that method, it would still fail when trying to call extract_all_objects() on it. Fixes: #12006
2023-08-07c_std, cpp_std: Change to a list of desired versions in preference orderXavier Claessens2-0/+40
Projects that prefer GNU C but can fallback to ISO C can now set for example `default_options: 'c_std=gnu11,c11'` and it will use gnu11 when available, fallback to c11 otherwise. It is an error only if none of the values are supported by the current compiler. This allows to deprecate gnuXX values from MSVC compiler, that means that `default_options: 'c_std=gnu11'` will now print warning with MSVC but still fallback to 'c11' value. No warning is printed if at least one of the values is valid, i.e. `default_options: 'c_std=gnu11,c11'`. In the future that deprecation warning will become an hard error because `c_std=gnu11` should mean GNU is required, for projects that cannot be built with MSVC for example.
2023-08-06tests: Assert that mips64 kernel is detected as mips64 with no compilersSimon McVittie1-0/+19
Reproduces: https://github.com/mesonbuild/meson/issues/12017 Signed-off-by: Simon McVittie <smcv@debian.org>
2023-08-06tests: Pass a mock C compiler to detect_cpu(), detect_cpu_family()Simon McVittie1-4/+8
In some cases the desired result can be different if there are no compilers at all. The expectations here are based on there being at least one compiler, so reflect that by providing one; a later test enhancement can cover the case where there are no compilers provided. As a result of the mock any_compiler_has_define(), all that matters will be the distinction between an empty or non-empty dict: the compiler object itself is unused. Signed-off-by: Simon McVittie <smcv@debian.org>
2023-08-03PkgConfigDependency: Move CLI handling into its own abstractionXavier Claessens2-27/+18
This makes the code cleaner and will allow to have other implementations in the future.
2023-08-02convert booleans in summary function to correct representationEli Schwartz1-4/+4
str() is going to return titlecased "True" which is not how meson works. This is misleading, so use the meson-specific format instead.
2023-08-02treewide: internally avoid deprecated machine file uses of "pkgconfig"Eli Schwartz1-2/+2
We support this in a machine file: ``` [binaries] pkgconfig = 'pkg-config' pkg-config = 'pkg-config' ``` and you can use either one, because internally we look up both. If you only set *one* of them, this plays awkwardly with setting $PKG_CONFIG, since we don't know which one you set in the machine file and the *other* one will be initialized from the environment instead. In commit 22df45a31981874310a78dde0df59a6a7c5ebb29 we changed program lookup of config-tool style dependencies to use the regular tool names and only fall back on the strange internal names. This affected the pkg-config class too. The result is that instead of preferring `pkgconfig =` followed by $PKG_CONFIG followed by `pkg-config =`, we inverted the lookup order. This is a good idea anyway, because now it behaves consistently with `find_program('pkg-config')`. Unfortunately, we documented the wrong name in a bunch of places, and also used the wrong name in various testsuite bits, which meant that if you set $PKG_CONFIG and then ran the testsuite, it would fail. Correct these references, because they are buggy. One test case expected to find_program() a native copy for convenience of testing against natively installed glib. Force it to resolve a native copy.
2023-07-31Rename variables that clash with pdb commandsDan Hawson2-13/+13
By default, pdb assumes that any command run is python code to be evaluated, but only if that code isn't a builtin pdb command. You can force it to be evaluated as python code by prefixing it with `!`. It's handy to simply name a python variable and have its variable be printed. But single letter variables like 's' and 'p' make debugging with pdb commands (i.e. 's'tep, and 'p'rint evaluated expressions) less convenient, and potentially confusing.
2023-07-31Merge pull request #11986 from williamspatrick/clang-enable-cpp23Jussi Pakkanen1-0/+15
add support for newer C++ -std= flags on Clang/GCC
2023-07-30tests: skip a test that fails with new Python 3.11 from MSYS2Christoph Reiter1-0/+3
For some (atm unknown) reason mingw Python fails to load some modules when MSYS2 is removed from PATH, like in this test. Skip for now to make the test suite pass again. Once https://github.com/msys2-contrib/cpython-mingw/issues/141 is fixed this can be reverted.
2023-07-26Fix install_data() default install pathDaniele Nicolodi1-6/+7
This fixes two issues in constructing the default installation path when install_dir is not specified: - inside a subproject, install_data() would construct the destination path using the parent project name instead than the current project name, - when specifying preserve_path, install_data() would construct the destination path omitting the project name. Fixes #11910.
2023-07-25unittests: test the vala templateDylan Baker1-1/+1
2023-07-25unittests: use subtests for template testsDylan Baker1-25/+26
Which gives more exact errors
2023-07-14tests: add support for c++23/c++26 detectionSteven Noonan1-0/+15
Signed-off-by: Steven Noonan <steven@uplinklabs.net> Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-07-13macos: map arm64e to aarch64, map "whole" architecture stringsAndres Freund1-0/+5
Some macos libraries use arm64e instead of arm64 as architecture. Due to the string replace approach taken so far, we'd end up with aarch64e as architecture, which the rest of meson doesn't know. Move architecture mapping to map whole architecture names and add arm64e -> aarch64 mapping. This change doesn't touch the case for armv7[s], where we add arm, rather than replace armv7[s], but it's certainly not in line with the other mappings. Fixes: #9493 Co-authored-by: Tristan Partin <tristan@partin.io>
2023-07-13Silence some encoding warningsTristan Partin5-16/+16
By specifiying explicit encodings, we can silence warnings like: /__w/meson/meson/test cases/common/100 postconf with args/postconf.py:15: EncodingWarning: 'encoding' argument not specified with open(input_file) as f: in CI.
2023-07-13mtest: fix unencodable XML charsNazir Bilal Yavuz1-0/+51
Replace unencodable XML chars with their printable representation, so that, xmllint can parse test outputs without error. Closes #9894 Co-authored-by: Tristan Partin <tristan@partin.io>
2023-07-10build: dependencies should come after link_with on link commandXavier Claessens1-0/+1
This fixes regression caused by https://github.com/mesonbuild/meson/commit/3162b901cab46d66a30c66a4406195523714ecdc that changes the order in which libraries are put on the link command. In addition, that commit was wrong because libraries from dependencies were processed before process_compiler() is called, which that commit wanted to avoid.
2023-07-10build: Fix linking multiple libraries and some are promotedXavier Claessens1-0/+1
When a link() is promoted to link_whole() we still have to handle the rest of the list. Fixes: #11956
2023-07-05Renumber test dirs for rc2.Jussi Pakkanen2-2/+2