Commit Graph

167 Commits

Author SHA1 Message Date
Eli Schwartz d0054f2c3c
mtest: warn on invalid TAP output
In commit a7e458effa we stopped erroring
out on invalid TAP stream contents, with the rationale that "prove" has
become more lenient.

A close reading of the TAP spec indicates why, though:

> A TAP parser is required to not consider an unknown line as an error but
> may optionally choose to capture said line and hand it to the test
> harness, which may have custom behavior attached. This is to allow for
> forward compatability. Test::Harness silently ignores incorrect lines,
> but will become more stringent in the future. TAP::Harness reports TAP
> syntax errors at the end of a test run.

The goal of treating unknown lines as an error in the TAP parser is not
because unknown lines are fine and dandy. The goal is to allow
implementing future versions of TAP, and handling it via existing
parsers. Since Meson has both a parser and a harness, let's do exactly
that -- pass these lines as a distinctive status to the test harness,
then have the test harness complain.
2022-12-05 15:46:46 -05:00
Eli Schwartz da23630a97
refactor pkg-config dependency to allow statically finding the program
The pkg-config dependency class has some interesting logic for finding a
good pkg-config that will be used for dependency lookups. We sometimes
need to use it, though, outside of the class. Make that possible.
2022-12-04 17:56:03 -05:00
David Robillard 81d7c24a59 Add warning_level=everything
Adds a new maximum warning level that is roughly equivalent to "all warnings".
This adds a way to use `/Wall` with MSVC (without the previous broken warning),
`-Weverything` with clang, and almost all general warnings in GCC with
strictness roughly equivalent to clang's `-Weverything`.

The GCC case must be implemented by meson since GCC doesn't provide a similar
option.  To avoid maintenance headaches for meson, this warning level is
defined objectively: all warnings are included except those that require
specific values or are specific to particular language revisions.  This warning
level is mainly intended for new code, and it is expected (nearly guaranteed)
that projects will need to add some suppressions to build cleanly with it.

More commonly, it's just a handy way to occasionally take a look at what
warnings are present with some compiler, in case anything interesting shows up
you might want to enable in general.

Since the warnings enabled at this level are inherently unstable with respect
to compiler versions, it is intended for use by developers and not to be set as
the default.
2022-11-27 16:50:48 -05:00
Marvin Scholz 7cbc15b812 unittests: add and use get_meson_log_raw function
This is like get_meson_log but returns the whole contents
not split into individual lines.
2022-11-22 22:53:07 -05:00
Marvin Scholz 49cd97c434 unittests: add and use _open_meson_log function
Factors out opening the meson log into its own function so that
it can be used in the places where with was done before.

Additionally instead of checking if the file exists before opening it,
try to open it and handle the exception when it is not found.
2022-11-22 22:53:07 -05:00
Jussi Pakkanen 3ae89a7150 Handle freezing tests. Fixes #10752. 2022-11-21 16:44:24 +02:00
Eli Schwartz b40e4de3c6
tests: fix potential failure to verify pkg-config generation
We use a dummy project with a vague name and try to find flags for it
based on the installable pkg-config files. This sort of works,
generally, because it attempts to match `-lct` which doesn't exist
because the test case isn't installed, and that link argument is passed
directly through.

Except, sometimes that library does exist. It is provided by the
"freetds" project, which may be a dependency other tools. In that case,
Meson finds a library, and the `dependency()` resolves to
`/usr/lib/libct.so` and the test fails.

Fortunately, we do have an API to say that we really want to get back
the same flags pkg-config returned. Use this.
2022-11-17 19:10:51 -05:00
Xeonacid 47d1a55e78 Fix test_rust_clippy for rust 1.65
clippy changed output message
fix #11004
2022-11-16 13:16:47 -05:00
Xavier Claessens f5871e240d backends: Try guessing install tag for all installed files
It was only trying to guess install tag, and log missing tags, for files
installed by install_data(). Do it also for all other files, especially
custom_taget() that commonly installs generated headers.
2022-11-02 14:53:35 +02:00
L. E. Segovia 7e5b0760ce minstall: make do_strip run with -Sx for macOS targets
This commit also adds some extra symbol noise to lib.c, in order to aid
detection of the debug information with nm.

Fixes #10943
2022-11-01 17:56:18 +02:00
Xavier Claessens 2961adb8c8 Compilers: Keep ccache and exelist separated
Only combine them in the Compiler base class, this will make easier to
run compiler without ccache.
2022-10-25 17:24:56 -04:00
Jussi Pakkanen 3c0ac626d7 Skip wrapdb test if there is no connectivity. 2022-10-25 11:21:37 +03:00
Jussi Pakkanen 458dcf8aac Condense test directory numbers. 2022-10-25 00:03:32 +03:00
Elliott Sales de Andrade 9c4d6088b1 Accept disablers in summary values
They are commonly used as a replacement for a `dependency`, and not
accepting them in `summary` breaks the last example in [1] when used as
a value.

[1] https://mesonbuild.com/Disabler.html#disabling-parts-of-the-build
2022-10-24 11:17:18 +02:00
Xavier Claessens 8c3a87847e Document and test new WrapDB auto fallback 2022-10-10 12:47:32 -04:00
Xavier Claessens 2dfd952eb9 Move classes used by scripts to their own module
Those classes are used by wrapper scripts and we should not have to
import the rest of mesonlib, build.py, and all their dependencies for
that.

This renames mesonlib/ directory to utils/ and add a mesonlib.py module
that imports everything from utils/ to not have to change `import
mesonlib` everywhere. It allows to import utils.core without importing
the rest of mesonlib.
2022-09-28 19:36:13 -04:00
Dylan Baker 1917b9253e modules/gnome: make_native_glib_version an instance var
This removes the need for the use of the global statement. I've also
updated the test that overrides this to use mock.patch instead of hand
monkey patching.
2022-09-22 18:17:43 -04:00
Eli Schwartz d3dac3cfb2
compilers: don't export every compiler as a top-level property
This is wasteful and generally unneeded, since code can just use the
compiler they detected instead of manually poking at the internals of
this subpackage.

It also avoids importing an absolute ton of code the instant one runs
`from . import compilers`
2022-09-19 15:19:00 -04:00
Eli Schwartz 0a9048e554
compilers: don't use instance checks to determine properties
In various situations we want to figure out what type of compiler we
have, because we want to know stuff like "is it the pgi one", or "does
it use msvc style". The compiler object has this property already, via
an API specifically designed to communicate this info, but instead we
performed isinstance checks on a compiler class.

This is confusing and indirect, and has the side effect of requiring
more imports everywhere. We should do away with it.
2022-09-19 15:18:59 -04:00
Daniel Carson 004575874f Warn if wrap file changes
Save off the hash of the wrap file when first configuring a subproject.
When reconfiguring a subproject, check the hash of the wrap file
against the stored hash. If they don't match then warn the user.
2022-09-18 22:48:50 -04:00
Yang Bo 83d18d137d Use os.path.realpath for default include paths testing in -isystem.
This ensures correct removal of default include paths in -isystem
options when symbolic links are involved.

A test for this is also added.
2022-09-13 02:24:38 -04:00
Thomas Li a4d5442207 Fix install_subdirs not showing up in intro-install_plan.json 2022-09-06 02:09:38 -04:00
Andres Freund 628effb369 mtest: Run ninja build.ninja before loading tests
When the build definition has changed since the last ninja invocation meson
test operated on an outdated list of tests and their dependencies. That could
lead to some tests not being run / not all dependencies being built. This was
particularly confusing because the user would see the output of
reconfiguration and rebuilding, and the next mtest invocation would have the
updated configuration.

One issue with this is that that we will now output more useless ninja output
when nothing needs to be done (the "Entering directory" part is not repeated,
as we happen to be in the build directory already). It likely is worth
removing that output, perhaps by testing if anything needs to be done with
ninja -n, but that seems better addressed separately.

Fixes: #9852
2022-09-04 19:05:14 -04:00
Eli Schwartz f8ebfdf7b1
install modes should not apply sticky bit to files
This is generally a bad idea, e.g. it causes OSError on freebsd.

It also gets ignored by solaris and thus causes unittest failures.

The proper solution is to simply reject any attempt to set this, and log a
warning.

The install_emptydir function does apply the mode as well, and since it
is a directory it actually does something. This is the only place where
we don't reset the mode.

Although install_subdir also installs directories, and in theory it
could set the mode as well, that would be a new feature. Also it doesn't
provide much granularity and has mixed semantics with files. Better to
let people use install_emptydir + install_subdir.

Fixes #5902
2022-08-23 21:07:00 -04:00
Eli Schwartz 3e73d4d77d
introspection: untangle install_plan implemetation, fix a bunch of wrong ones
Generally plumb through the values of get_option() passed to
install_dir, and use this to establish the install plan name. Fixes
several odd cases, such as:

- {datadir} being prepended to "share" or "include"

- dissociating custom install directories and writing them out as
  {prefix}/share/foo or {prefix}/lib/python3.10/site-packages

This is the second half of #9478
Fixes #10601
2022-08-22 14:15:22 -04:00
Dylan Baker f10967e3f4 unittests: Add additional tests for KwargInfo::since values
The first test is checking the added support for keys as either `dict`
or `list`.

The second checks that a default value which would otherwise trigger a
value_since check doesn't, and that passing the default value explicitly
does.
2022-08-18 21:57:36 -04:00
Dylan Baker a78992dd81 interpreter: move handling of module stability to interpreter
Thanks to `ModuleInfo`, all modules are just named `foo.py` instead of
`unstable_foo.py`, which simplifies the import method a bit. This also
allows for accurate FeatureNew/FeatureDeprecated use, as we know when
the module was added and if/when it was stabilized.
2022-08-17 16:25:36 -04:00
Dylan Baker e062dcdfcc allplatformstests: use subTests with test_warning_location 2022-08-17 16:25:36 -04:00
Eli Schwartz 3c7ab542c0
deprecate running "meson builddir" without setup subcommand
This is ambiguous, if the build directory has the same name as a
subcommand then we end up running the subcommand. It also means we have
a hard time adding *new* subcommands, because if it is a popular name of
a build directory then suddenly scripts that try to set up a build
directory end up running a subcommand instead.

The fact that we support this at all is a legacy design. Back in the
day, the "meson" program was for setting up a build directory and all
other tools were their own entry points, e.g. `mesontest` or
`mesonconf`. Then in commit fa278f351f we
migrated to the subcommand mechanism. So, for backwards compatibility,
we made those tools print a warning and then invoke `meson <tool>`. We
also made the `meson` tool default to setup.

However, we only warned for the other tools whose entry points were
eventually deleted. We never warned for setup itself, we just continued
to silently default to setup if no tool was provided.

`meson setup` has worked since 0.42, which is 5 years old this week.
It's available essentially everywhere. No one needs to use the old
backwards-compatible invocation method, but it continues to drag down
our ability to innovate. Let's finally do what we should have done a
long time ago, and sunset it.
2022-08-16 17:40:03 -04:00
Hemmo Nieminen 952dd7773d mtest: unify parsed and non-parsed output handling
Use the same routines to handle output both when parsing the output and
when not. Also fixes broken stderr handling for parsed tests.
2022-08-07 20:48:42 +03:00
Daan De Meyer f774609b09 Only reconfigure if configure options actually changed
Currently, if we run "meson configure -Doption=value", meson will
do a reconfigure when running "ninja build" afterwards, even if
the new value is the same one that was already configured previously.

To avoid this unnecessary reconfigure, let's use replace_if_different()
instead of unconditionally replacing the conf file in coredata's save()
function.
2022-07-31 20:43:27 +03:00
Justin Blanchard ec388fe7c2 ar linker: detect the "osx ld" case (where generating thin archives won't work) based on host OS, not build OS. 2022-07-21 22:00:00 -07:00
Eli Schwartz 8afcca2d26
tests: skip template test for windows shared fortran
This is only supported with gfortran, see "test cases/fortran/6 dynamic"
for more details. Skip it explicitly here too.
2022-07-11 17:58:02 -04:00
Jussi Pakkanen befd26985c Fix test case numbers. 2022-07-07 10:04:51 -07:00
Xavier Claessens d85a9733e6 Fix crash when a reconfigure adds a new subproject
When a subproject is disabled on the initial configuration we should not
add it into self.coredata.initialized_subprojects because that will
prevent calling self.coredata.init_builtins() on a reconfigure if the
subproject gets enabled.

Fixes: #10225.
2022-06-14 16:01:20 -04:00
Eli Schwartz 036181ef6a
unittests: do more accurate check for ninja "nothing to do"
We only want to scan stdout for these strings, and particularly, if we
allow `-d explain` to be mingled into stdout, then buffering issues
across OSes can lead to inaccurate results.
2022-06-13 17:17:53 -04:00
Eli Schwartz 2acb6ee79e
unittests: allow test commands to suppress returning stderr
Add better logging of commands by printing stdout and stderr separately,
if relevant. Also while we are at it, print the actual command being
run.
2022-06-13 17:17:53 -04:00
Eli Schwartz c151988b39
intro-install_plan: fix destinations for build_targets with custom install_dir
There are a couple issues that combine to make the current handling a
bit confusing.

- we call it "install_dir_name" but it is only ever the class default

- CustomTarget always has it set to None, and then we check if it is
  None then create a different variable with a safe fallback. The if is
  useless -- it cannot fail, but if it did we'd get an undefined
  variable error when we tried to use `dir_name`

Remove the special handling for CustomTarget. Instead, just always
accept None as a possible value of outdir_name when constructing install
data, and, if it is None, fall back to {prefix}/outdir regardless of
what type it used to be.
2022-06-09 20:37:26 -04:00
Vili Väinölä 18e2f8b2b3 Fix sandbox violation when using subproject as a symlink
Fix "Tried to grab file outside current (sub)project" error when subproject exists within
a source tree but it is used through a symlink. Using subprojects as symlinks is very useful
feature when migrating an existing codebase to meson that all sources do not need to be
immediately moved to subprojects folder.
2022-06-01 12:32:53 -07:00
Paolo Bonzini a7e458effa mtest: ignore invalid input
TAP version 14 introduced subtests, that are supposedly backward compatible
because "TAP13 specifies that non-TAP output should be ignored".  Meson
reported TAP syntax errors based on behavior of "prove" at the time,
but it seems that now "prove" has become a lot more lenient; it even
accepts the following completely bogus input just fine:

---
ok 1
    ok 2
x
1..1
---

So do the same and make Meson's parser accept invalid TAP input silently.

Fixes: #10032
2022-05-24 20:15:34 +03:00
Zbigniew Jędrzejewski-Szmek 8afdecb039 Reword message in warning
"targetting" is verb-derived adjective, which sort-of-works here, but
makes the whole sentence awkward, because there's no verb. Let's just
use present simple.
2022-05-19 07:18:43 -04:00
Simon McVittie 65ea833d58 Require CMake 3.14 for all tests that use the cmake module
Older versions are not supported by the cmake module since 0.62.

This avoids having to hard-code the linux-bionic-gcc CI job as being
unable to run these tests, which leaves other older environments like
Debian 10 still trying to run them (and failing).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-10 07:56:59 -04:00
Simon McVittie 42327eacbc unittests: Skip prelinking test with gcc 8 or older
This was already skipped when running on the Ubuntu 18.04 version of gcc,
but it also fails with gcc 8.3.0 on Debian 10. Instead of hard-coding
specific versions to look for, do a version comparison.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-06 07:49:32 -04:00
Xavier Claessens 18bec0d3e3 pkgconfig: Use EnvironmentVariables to build PKG_CONFIG_* env
The new get_env() method that returns an EnvironmentVariables object
will be needed in next commit that will pass it to CustomTarget.

This has the side effect to use the proper os specific path separator
instead of hardcoding `:`. It is the obvious right thing to do here, but
has caused issues in the past. Hopefully issues have been fixed in the
meantime. If not, better deal with fallouts than keep doing the wrong
thing forever.
2022-04-30 15:01:28 -04:00
Fini Jastrow c16fdaeeca linkers: Add support for mold linker
[why]
Support for the relatively new mold linker is missing. If someone wants
to use mold as linker `LDFLAGS="-B/path/to/mold"` has to be added instead
of the usual `CC_LD=mold meson ...` or `CXX_LD=mold meson ...`.

[how]
Allow `mold' as linker for clang and newer GCC versions (that versions
that have support).

The error message can be a bit off, because it is generic for all GNU
like compilers, but I guess that is ok. (i.e. 'mold' is not listed as
possible linker, even if it would be possible for the given compiler.)

[note]
GCC Version 12.0.1 is not sufficient to say `mold` is supported. The
expected release with support will be 12.1.0.
On the other hand people that use the un-released 12.0.1 will probably
have built it from trunk. Allowing 12.0.1 is helping bleeding edge
developers to use mold in Meson already now.

Fixes: #9072

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-04-30 10:06:22 -04:00
Fredrik Salomonsson 442fd7dc73 docs: Add documentation on pkgconfig.relocatable
- Documentation for the pkgconfig.relocatable module option in
Builtin-options. Gives an explanation on what it does, usefulness and
what error that can occur when using it.

- Add pkgconfig.relocatable release snippet. Similar to the
documentation in Builtin-options. Just a bit more brief.

- Add Pkgconfig to DataTests.test_builtin_options_documented in the
docs unit tests.
2022-04-19 17:35:08 -04:00
Fredrik Salomonsson ef0c38f90a unittests: Add test_pkgconfig_relocatable to allplatformstests
Test that the pkgconfig prefix is actually relocatable when
pkgconfig.relocatable=true and is not when
pkgconfig.relocatable=false.
2022-04-19 17:35:08 -04:00
Eli Schwartz 5df0fb45ca
unittests: make datatests capable of parsing module subsections properly
We will need to update the tests for each module that gets newly added,
apparently, but the basic structure for doing so is hopefully there.
2022-04-14 18:37:04 -04:00
Jussi Pakkanen 2fcd3a4174 Add regression test for Python dist. 2022-04-13 21:27:22 +03:00
Eli Schwartz b5a81ff634
qt dependency: adapt to the qmake command changed name
Qt now has official guidance for the symlinked names of the tools, which
is great.

Qt now officially calls the tools `fooX` instead of `foo-qtX` where the
major version of Qt is X. Which is not great, because a bit of an
unofficial standard had prior art and now needs to change, and we never
adapted.

Prefer the official name whenever looking up qmake, and in the
testsuite, specifically look only for the official name on versions of
qt which we know should have that.
2022-04-12 20:44:07 -04:00