aboutsummaryrefslogtreecommitdiff
path: root/unittests
AgeCommit message (Collapse)AuthorFilesLines
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-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
2023-07-05Merge pull request #11742 from xclaesse/link-whole-casesJussi Pakkanen2-2/+18
Fix niche cases when linking static libs
2023-07-02remove CI workaround for clang+msys2Eli Schwartz1-1/+0
Reverts part of commit 4e17d60d47357b7e3a4fd772ce031cd7cd7bc57e. msys2 is now fixed, so clang works well with the python headers.
2023-06-28Experimental 'genvslite' WIP. (#11049)GertyP2-3/+91
* Capture all compile args from the first round of ninja backend generation for all languages used in building the targets so that these args, defines, and include paths can be applied to the .vcxproj's intellisense fields for all buildtypes/configurations. Solution generation is now set up for mutiple build configurations (buildtypes) when using '--genvslite'. All generated vcxprojs invoke the same high-level meson compile to build all targets; there's no selective target building (could add this later). Related to this, we skip pointlessly generating vcxprojs for targets that aren't buildable (BuildTarget-derived), which aren't of interest to the user anyway. When using --genvslite, no longer inject '<ProjectReference ...>' dependencies on which a generated .vcxproj depends because that imposes a forced visual studio build dependency, which we don't want, since we're essentially bypassing VS's build in favour of running 'meson compile ...'. When populating the vcxproj's shared intellisense defines, include paths, and compiler options fields, we choose the most frequent src file language, since this means more project src files can simply reference the project shared fields and fewer files of non-primary language types need to populate their full set of intellisense fields. This makes for smaller .vcxproj files. Paths for generated source/header/etc files, left alone, would be added to solution projects relative to the '..._vs' build directory, where they're never generated; they're generated under the respective '..._[debug/opt/release]' ninja build directories that correspond to the solution build configuration. Although VS doesn't allow conditional src/header listings in vcxprojs (at least not in a simple way that I'm aware of), we can ensure these generated sources get adjusted to at least reference locations under one of the concrete build directories (I've chosen '..._debug') under which they will be generated. Testing with --genvslite has revealed that, in some cases, the presence of 'c:\windows\system32;c:\windows' on the 'Path' environment variable (via the make-style project's ExecutablePath element) is critical to getting the 'meson compile ...' build to succeed. Not sure whether this is some 'find and guess' implicit defaults behaviour within meson or within the MSVC compiler that some projects may rely on. Feels weird but not sure of a better solution than forcibly adding these to the Path environment variable (the Executable Path property of the project). Added a new windows-only test to windowstests.py ('test_genvslite') to exercise the --genvslite option along with checking that the 'msbuild' command invokes the 'meson compile ...' of the build-type-appropriate-suffixed temporary build dir and checks expected program output. Check and report error if user specifies a non-ninja backend with a 'genvslite' setup, since that conflicts with the stated behaviour of genvslite. Also added this test case to 'WindowsTests.test_genvslite' I had problems tracking down some problematic environment variable behaviour, which appears to need a work-around. See further notes on VSINSTALLDIR, in windowstests.py, test_genvslite. 'meson setup --help' clearly states that positional arguments are ... [builddir] [sourcedir]. However, BasePlatformTests.init(...) was passing these in the order [sourcedir] [builddir]. This was producing failures, saying, "ERROR: Neither directory contains a build file meson.build." but when using the correct ordering, setup now succeeds. Changed regen, run_tests, and run_install utility projects to be simpler makefile projects instead, with commands to invoke the appropriate '...meson.py --internal regencheck ...' (or install/test) on the '[builddir]_[buildtype]' as appropriate for the curent VS configuration. Also, since the 'regen.vcxproj' utility didn't work correctly with '--genvslite' setup build dirs, and getting it to fully work would require more non-trivial intrusion into new parts of meson (i.e. '--internal regencheck', '--internal regenerate', and perhaps also 'setup --reconfigure'), for now, the REGEN project is replaced with a simpler, lighter-weight RECONFIGURE utility proj, which is unlinked from any solution build dependencies and which simply runs 'meson setup --reconfigure [builddir]_[buildtype] [srcdir]' on each of the ninja-backend build dirs for each buildtype. Yes, although this will enable the building/compiling to be correctly configured, it can leave the solution/vcxprojs stale and out-of-date, it's simple for the user to 'meson setup --genvslite ...' to fully regenerate an updated, correct solution again. However, I've noted this down as a 'fixme' to consider implementing the full regen behaviour for the genvslite case. * Review feedback changes - - Avoid use of 'captured_compile_args_per_buildtype_and_target' as an 'out' param. - Factored a little msetup.py, 'run(...)' macro/looping setup steps, for genvslite, out into a 'run_genvslite_setup' func. * Review feedback: Fixed missing spaces between multi-line strings. * 'backend_name' assignment gets immediately overwritten in 'genvslite' case so moved it into else/non-genvslite block. * Had to bump up 'test cases/unit/113 genvslites/...' up to 114; it collided with a newly added test dir again. * Changed validation of 'capture' and 'captured_compile_args_...' to use MesonBugException instead of MesonException. * Changed some function param and closing brace indentation.
2023-06-27modules/rust: Add a machine file property for extra clang args with bindgenDylan Baker1-4/+29
It's currently impossible to inject extra clang arguments when using bindgen, which is problematic when cross compiling since you may need critical arguments like `--target=...`. Because such arguments must be passed after the `--` it's impossible to inject them currently without going to something like a wrapper script. Fixes: #11805
2023-06-26mintro: record subproject in install_planDaniele Nicolodi1-0/+45
2023-06-26Revert "modules: move gnome targets into gnome module"Eli Schwartz1-1/+1
This reverts commit a2def550c586aeba4269588e79a1a308467f2582. This results in a 2k line file being unconditionally imported at startup, and transitively loading two more (for a total cost of 2759 lines of code), and it's not clear it was ever needed to begin with...
2023-06-26linkers: delay implementations import until detect is runEli Schwartz2-17/+19
This saves on a 1500-line import at startup and may be skipped entirely if no compiled languages are used. In exchange, we move the implementation to a new file that is imported instead. Followup to commit ab20eb5bbc21ae855bcd211131132d2778602bcf.
2023-06-26stop importing cmake when it isn't usedEli Schwartz1-1/+1
We don't need a CMakeInterpreter until and unless we actually attempt to use a cmake subproject via the cmake module. Minus 10 files and 3679 lines of code imported at startup.
2023-06-26dependencies: defer importing a custom dependency until it is usedEli Schwartz4-4/+4
This lessens the amount of code imported at Meson startup by mapping each dependency to a dictionary entry and using a programmable import to dynamically return it. Minus 16 files and 6399 lines of code imported at startup.
2023-06-26dependencies: delay often-unused importsEli Schwartz1-1/+1
We expose detect.py as the mesonbuild.dependencies entrypoint and import it upfront everywhere. But unless the `dependency()` function is actually invoked, we don't need *any* of the private implementations for this. Avoid doing so until, as part of actual dependency lookup, we attempt that specific dependency method. This avoids importing big modules if `method:` is specified, and in most cases hopefully pkg-config works and we can avoid importing the cmake implementation particularly. Actually avoiding most of these imports requires more refactoring. But even so, the garden path no longer needs to import the dub dependency impl.
2023-06-26add profiling startup import check and testcase to count itEli Schwartz1-0/+27
2023-06-25tests: move script loaded modules test to platform-agnosticEli Schwartz2-30/+31
We have the same platform startup logic here for all platforms and I do not believe it's important to test this on the slow CI machines.
2023-06-16unittests: fix test_scripts_loaded_modules matching exactly our own modulesCharles Brunet1-1/+1
When meson is installed as editable, setuptools adds `__editable___meson_1_0_99_finder` to the list. This contains the string "meson" which isn't really accurate to what we want, which is modules that are part of the `mesonbuild.*` namespace.
2023-06-16unittests: skip test using symlink if not availableCharles Brunet1-1/+4
2023-06-16unittests: ensure terminal has 80 chars widthCharles Brunet1-0/+1
2023-06-14WIP: refactor loggable popen calls for consistencyEli Schwartz1-3/+4
2023-06-07cargo/cfg: Add a parser for the rust/cargo cfg() expressionsDylan Baker1-0/+125
This uses a recursive descent parser + lexer to create an IR from cfg() expressions, which it then converts into meson IR.
2023-06-07cargo/version: add a function to convert cargo versioning to mesonDylan Baker1-0/+61
2023-06-07unittests: fix incorrect calculation of bytecompile outputsEli Schwartz1-4/+5
If py2 is not found *and* the compiler is MSVC, we didn't take into account that py2 is not found. This also meant that we didn't take into account the expected count when it *is* found, because the python module has a better finder than just "is the binary on PATH".
2023-05-31mlog: use a hidden class for stateDylan Baker2-11/+11
This is a pretty common pattern in python (the standard library uses it a ton): A class is created, with a single private instance in the module, and then it's methods are exposed as public API. This removes the need for the global statement, and is generally a little easier to reason about thanks to encapsulation.
2023-05-25mtest: wildcard selectionCharles Brunet1-0/+24
Allow the use of wildcards (e.g. *) to match test names in `meson test`. Raise an error is given test name does not match any test. Optimize the search by looping through the list of tests only once.
2023-05-22intro: add more details to generated files(part 2)Charles Brunet1-1/+4
- add `extra_paths` to intro-tests.json to know paths needed to run a test on Windows; - add `depends` to alias targets in intro-targets.json to know what targets does an alias point to; - add `depends` to intro-dependencies.json to know libraries linked with an internal dependency; - renamed `deps` to `dependencies` in `intro-dependencies.json` for more uniformity.
2023-05-17summary: Add from which subproject each subproject have been calledXavier Claessens1-1/+1
2023-05-13During reconfigure, show that no compiler was found, if compiler fails ↵Volker Weißmann1-7/+7
sanity check.
2023-05-05Fix unit test that hardcoded `/` and hence broke on WindowsRalf Gommers1-4/+4
2023-05-03tests: fix `test_always_prefer_c_compiler_for_asm`Benoit Pierre1-1/+1
Handle the case where `sccache` is installed and used over `ccache`.
2023-05-02unittests: add magic flag global to integrate utility methods with unittestEli Schwartz1-0/+5
The stdlib unittest module has a magic flag (undocumented) which indicates that a module is part of a unittest framework. > Truncates usercode tb at the first unittest frame. > > If the first frame of the traceback is in user code, > the prefix up to the first unittest frame is returned. > If the first frame is already in the unittest module, > the traceback is not modified. This avoids some ugliness, e.g. the following test error logs: ``` > self.assertPathListEqual(intro[0]['install_filename'], ['/usr/lib/libstat.aaa']) unittests/allplatformstests.py:432: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ unittests/baseplatformtests.py:393: in assertPathListEqual self.assertPathEqual(i[0], i[1]) unittests/baseplatformtests.py:384: in assertPathEqual self.assertEqual(PurePath(path1), PurePath(path2)) E AssertionError: PurePosixPath('/usr/lib/libstat.a') != PurePosixPath('/usr/lib/libstat.aaa') ``` Since assertPathListEqual is our own assertion helper, we don't need to give trace information about its internals. This change causes the error log to become: ``` > self.assertPathListEqual(intro[0]['install_filename'], ['/usr/lib/libstat.aaa']) E AssertionError: PurePosixPath('/usr/lib/libstat.a') != PurePosixPath('/usr/lib/libstat.aaa') unittests/allplatformstests.py:432: AssertionError ``` which is a lot more readable.