aboutsummaryrefslogtreecommitdiff
path: root/unittests
AgeCommit message (Collapse)AuthorFilesLines
2025-01-27compilers: Check if GCC has support for ObjC and/or ObjC++Dylan Baker2-9/+26
Since this is optional, we should not accept that GCC is a valid ObjC or G++ is a valid ObjC++ Compiler unless we've tested that they can actually do a basic compile. This requires fixing a number of tests that have broken assumptions. In some cases I've split tests where issues with one language would hide the other. It would be great if we had a competent test framework that allowed subtests to skip, unfortunately we have python's unittest instead. Because of that we can't avoid extra tests by use of subtests.
2025-01-27unit tests: Test ObjC and ObjC++ as well as C and C++Dylan Baker1-4/+31
This tests ObjC and ObjC++ both with and without C enabled. I did this because I ran into issues where ObjC only worked when C was enabled, and then a later bug where C was disabled, due to the fact that C and ObjC both use `c_std` and not `objc_std`.
2025-01-27unit tests: make the test_c_cpp_stds test more robustDylan Baker1-2/+2
Check clang-cl as well as cl, and clang as well as gcc.
2025-01-27tests: mock the environment in setUpClassDylan Baker1-1/+9
When used as a class decorator VSCode can no longer see that BasePlatformTest is a TestCase. I hate having to adapt the code to the tools, but it's really annoying to not have completion and syntax highlighting.
2025-01-27tests: Add annotations for `assertMesonRaises`Dylan Baker1-6/+9
2025-01-09Condensed directory names for release.Jussi Pakkanen6-35/+35
2025-01-08programs: fix regex to match multi-digit major versionPatrick Steinhardt1-0/+1
In a3679a64e (programs: favor version numbers with dots, 2025-01-03) we have changed the regex used to extract version numbers to favor dotted versions. It was reported though that the regex doesn't match major version numbers that start with multiple digits correctly. Fix this. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-01-08programs: favor version numbers with dotsPatrick Steinhardt1-1/+28
When using `find_program('perl')` we misdetect its version number: Program perl found: YES 40 40 (/usr/bin/perl) This is caused by Perl outputting the version information in a somewhat weird format: $ perl --version This is perl 5, version 40, subversion 0 (v5.40.0) built for x86_64-linux-thread-multi ... The problem here is that our version number detection picks the first match of at one digit followed by at least one more digit and/or dot. Consequently, as "40" matches that regular expression, we'd return its value as the version number. Naturally, the version number detection we perform is best-effort, only, as there is no standardized format used by all programs. That being said, we can do better here by first trying to match a dotted version number so that we'd match the "5.40.0" string, not the "40". And given that most projects use dotted version numbers this should be a strict improvement in cases where we have multiple digits in-text. The old behaviour continues to be used as a fallback though in case we weren't able to match anything to not regress functionality. The new regex also fixes another case: when the version information ends with a trailing dot, like "foo version 1.2.3.", then we'd also have matched that trailing dot. This can be for example the case when version numbers end with ".rc1" or something similar. While we'd ideally include such suffixes into the detected version, that issue is left for another day. Add a couple of tests. Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-01-07fix trailing whitespace issuesEli Schwartz1-6/+6
2025-01-07mtest: fix rebuilding all before running testsEli Schwartz1-0/+15
Inconsistency in the original implementation of commit 79e2c52a15e896e46ff3cfa3ec16fbf3f132ee01. If an explicit list of targets is passed on the CLI, then that is passed to rebuild_deps. If not, we pass every loaded test to rebuild_deps instead. This means we cannot distinguish between "trying to run all tests" and "trying to run specific tests". We then load all the deps for all tests, and try to build them all as explicit arguments to the underlying ninja. There are two situations where this falls flat: - given underspecified deps - given all (selected?) tests legitimately happen to have no dependencies In both cases, we calculate that there are no deps to rebuild, we run ninja without any targets, and this invokes the default "all" rule and maybe builds a few thousand targets that this specific test run does not need. Additionally, in large projects which define many tests with many dependencies, we could end up overflowing ARG_MAX when processing *all* tests. Instead, pass no tests to rebuild_deps. We then specially handle this by directly running the relevant ninja target for "all test deps", which is overall more elegant than specifying many many dependencies by name. Given a subset of tests to guarantee the freshness of, we instead skip running ninja at all if there are indeed no test dependencies.
2025-01-07Revert "make the testsuite handle MSYS2's addition of cmd"Christoph Reiter1-13/+13
This reverts commit 3c38e4720f7df0a9d0138363a9a995b31e848401.
2025-01-07tests: Avoid modifying '17 prebuild shared' test dirJan Alexander Steffens (heftig)1-1/+1
Tests can tread on each other's toes when parallelism is high enough. In this case, `test_prebuilt_shared_lib` creates an object file in the `17 prebuilt shared` test dir. `test_prebuilt_shared_lib_rpath_same_prefix` uses `shutil.copytree` to copy that same test dir to a temporary location. If the former test cleans up its object file while `copytree` is running, the copy can fail with a fatal ENOENT `shutil.Error`. Use `copy_srcdir` to prevent this from happening.
2024-12-31Fail gracefully when compiler cache is specified without compilerJoel Rosdahl1-0/+5
With CC=ccache meson ... meson crashes with [...] File "/usr/lib/python3.10/site-packages/mesonbuild/compilers/detect.py", line 364, in _detect_c_or_cpp_compiler compiler_name = os.path.basename(compiler[0]) IndexError: list index out of range Improve this by throwing an EnvironmentException to fail gracefully when no compiler is specified. Fixes #9933 Fixes #13589
2024-12-20print out which command needs an exe_wrapperRolf Eike Beer1-1/+1
It's not the first time I run into an issue with an intentionally missing exe_wrapper during cross compilation. In pretty much all the cases the project I tried to build already had code available to not need one in the first place. Print out what command was actually the culprit to make debugging this easier.
2024-12-19mtest: tap: accept out-of-order or partly-numbered testsPaolo Bonzini1-3/+53
Resolves: #13802 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-12-19ninjabackend: add support for "ninja clippy"Paolo Bonzini1-0/+18
Add a target that builds all crates that could be extern to others, and then reruns clippy. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-12-19introspect: add machine to target_sourcesPaolo Bonzini1-2/+10
Even though the "targets" introspection info already includes the command line arguments used to invoke the compiler, this is not enough to correlated with the "compilers" introspection info and get extra information from there. Together with the existing "language" key, adding a "machine" key is enough to identify completely an entry in the compilers info. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-12-16Handle top level options set in subprojects. Closes #13847.Jussi Pakkanen1-0/+4
2024-11-19rust: avoid warnings from rust.testPaolo Bonzini1-0/+7
Any argument from the base target is copied to the test target, but some keyword arguments for libraries are not available in executable. Remove them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-11-19make the testsuite handle MSYS2's addition of cmdMihailJP1-13/+13
In some reason, recent version of MSYS2 is shipped with /usr/bin/cmd which makes the test fail
2024-10-23pkgconfig: fix use of uninstalled librariesAndoni Morales Alastruey1-0/+36
Prepend the path of uninstalled libraries to PKG_CONFIG_PATH so they have preference over other search paths set by the user. see: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3247
2024-10-22env2mfile: Use a cross valac on Debian if possibleSimon McVittie1-0/+1
This is functionally equivalent to the logic used to locate the cross exe_wrapper, but puts it below the "Compilers" heading rather than "Other binaries". Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-22env2mfile: Automatically set exe_wrapper on Debian if possibleSimon McVittie1-0/+1
Recent versions of the architecture-properties package provide a cross-exe-wrapper package containing ${DEB_HOST_GNU_TYPE}-cross-exe-wrapper, which is currently a wrapper around qemu-user but could use different emulators on each architecture if it becomes necessary in the future. Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-22env2mfile: Use Debian cross-prefixed GObject-Introspection toolsSimon McVittie1-0/+6
In Debian testing/unstable, there are wrappers available for various GObject-Introspection tools during cross-builds, using qemu internally. Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-21backend/ninja: Fix inconsistent rule descriptionsDavid Robillard1-3/+3
Remove some trailing periods and always use present continuous tense (since these appear as status messages).
2024-10-20Add GNU/Hurd kernel resultsSamuel Thibault1-5/+1
uname -s does return gnu there. Resolves: https://github.com/mesonbuild/meson/issues/13740 Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2024-10-20Condense test directories.Jussi Pakkanen3-17/+17
2024-10-13mintro: Add license and license_files to project introspection dataDaniele Nicolodi1-1/+10
2024-10-04programs: Allow excluding certain paths when searching in PATHNirbheek Chauhan1-2/+2
2024-10-02env2mfile: Base cpu on DEB_HOST_GNU_CPU unless DEB_HOST_ARCH is specialSimon McVittie1-9/+4
`DEB_HOST_ARCH` encodes both the CPU family and the OS, so using it to get the CPU type gives the wrong answer for non-Linux ports. However, `DEB_HOST_GNU_CPU` gives less detailed information about the CPU: it's `arm` for all 32-bit ARM CPUs, and doesn't distinguish between the differing baselines of `armel` (ARMv5 softfloat) and `armhf` (ARMv7 hardfloat). When cross-compiling for x86_64 Linux, this changes the `cpu()` from `amd64` to `x86_64`, which is consistent with the answer we get during native builds on that architecture. When cross-compiling for `ppc64el`, this changes the `cpu()` from `ppc64el` to `ppc64`, which is a reasonable change but is still not consistent with what we see during native builds (which is `ppc64le`): see #13741 for that. Resolves: https://github.com/mesonbuild/meson/issues/13742 Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-02env2mfile: Don't hard-code Debian as always being LinuxSimon McVittie1-3/+4
All official Debian release architectures use the Linux kernel, but unofficial ports like hurd-i386 and kfreebsd-amd64 use the Hurd and FreeBSD kernel, respectively. Map Linux to 'linux' and kFreeBSD ports to 'freebsd' as per the reference tables in Meson's documentation. For now, use the Debian system name such as 'hurd' for anything else (see #13740 for the question of whether Hurd should identify its kernel differently). Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-02env2mfile: Map Debian GNU/Hurd to system() -> gnuSimon McVittie1-4/+2
As per <https://mesonbuild.com/Reference-tables.html>, and matching what happens when running Meson for a native build on Debian GNU/Hurd. Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-02unittests: Test env2mfile's dpkg_architecture_to_machine_infoSimon McVittie1-0/+391
This test parses several possible outputs of dpkg-architecture and asserts that they produce the expected MachineInfo. To avoid depending on suitable cross-tools being installed, use unittest.mock to override locate_path with a version that pretends that all of the tools we're interested in are in /usr/bin. Similarly, use mock environment variables to exercise what happens when we have those set. The test data used here exercises most variations: * big- and little-endianness * GNU CPU (x86_64) differing from dpkg CPU (amd64) * Linux, kFreeBSD and Hurd * special-cased architectures: x86, arm, mips64el, ppc64el expected_compilers() intentionally doesn't assume that every compiler is gcc (even though they all are, right now), because #13721 proposes adding valac which does not take a gcc suffix. Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-27linkers: Fix linker detection with clang on SolarisAlan Coopersmith1-0/+2
Fixes: #13711
2024-09-24qt module: allow has_tools to specify which tools to checkPierre Lamot1-0/+14
This allows checking for tools that may not be available in older version of qt or avoiding requesting tools that may not be necessary for a given project Co-authored-by: Nirbheek Chauhan <nirbheek@centricular.com>
2024-09-20rewriter: don't output target info to stderrBenoit Pierre1-4/+4
Send the info to stdout, where it belongs.
2024-09-11Fix typosspaette3-15/+15
2024-09-06mformat: detect invalid configCharles Brunet1-2/+35
- detect unknown config keys in format config - add test for detection of invalid config values - detect invalid .editorconfig values Fixes #13569
2024-09-03intro: add install_rpath to intro-install_plan.jsonDaniele Nicolodi1-0/+20
2024-08-30update various deprecation notices to call out meson 2.0Eli Schwartz1-1/+1
2024-08-26compilers: Allow prelinking with Apple ClangL. E. Segovia1-5/+2
2024-08-20linkers: skip -export_dynamic flag before MacOS 10.7Wolfgang Walther1-1/+3
The flag was only introduced in ld 224.1, as mentioned in the initial PR #13291. Resolves #13543
2024-08-20format: fix indentation of commentsCharles Brunet1-0/+15
Fixes #13508 - Fix indentation of comments in arrays - Fix indentation of comments in dicts - Fix indentation of comments in if clauses - Fix indentation of comments in foreach clauses
2024-08-15unittests: use setUpClass instead of setUp for class constant dataDylan Baker1-32/+35
for test attributes that are class constant. This reduces the work that must be done for each test case, allowing some of the setup work to be done once for the entire class.
2024-08-15unittests: use TestCase.addCleanup for cleaning up builddirsDylan Baker2-11/+4
2024-08-15unittests: use mock.patch.dict to deal with os.environDylan Baker3-12/+7
2024-08-15unittests: use os.environ.get for MESON_UNIT_TEST_BACKENDDylan Baker1-1/+1
Being unset shouldn't cause a ton of our tests to fail.
2024-08-09linkers: fix LLD linker response file handlingBenoit Pierre1-0/+9
Correct base classes so GNU-like linkers all default to supporting response files.
2024-08-04Revert "CI: skip LTO tests on cygwin"Jon Turney1-2/+0
This reverts commit 0c93149f09bbeedd03c70abc7b6d652b8e9ee9fa.
2024-08-01mformat: fix formatting of empty build fileCharles Brunet1-2/+8
Running meson format multiple times on an empty file was adding a new line each time, which is bad for pre-commit checks...