Commit Graph

676 Commits

Author SHA1 Message Date
Dylan Baker 3fbb450166 environment: Detect dynamic linker class 2019-08-14 13:13:23 -07:00
Dylan Baker 9b3a1fabc5 unittests: add b_lundef=false to address sanitizer test
Clang doesn't really like having no-undefined plus the address sanitizer, but
gcc doesn't mind. This all happens to work with clang + gnu ld, but with clang
+ apple ld this turns into a dumpster fire. Just add b_lundef=false to make
everyone happy.
2019-08-14 13:13:22 -07:00
Dylan Baker a6ab28b199 run_unittests: extend binary wrapper creater for Wl,--version
which is needed by swift.
2019-08-14 13:13:22 -07:00
James Hilliard b21fd95f73 Add is_disabler function
This is useful if one needs to check if a variable is a disabler.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2019-08-12 01:05:45 +03:00
Jussi Pakkanen 5fd4963766 Made build. options alias basic ones when native building. 2019-08-06 21:34:15 +03:00
Jussi Pakkanen 534c95cc3e Made set_option kwargs named-only. 2019-08-06 21:34:15 +03:00
Jussi Pakkanen f39600647d Condense test directory names. 2019-08-03 02:29:44 +03:00
Nirbheek Chauhan fcecedc10e unit tests: Convert unittest args to pytest
Allows people to run specific tests and/or enable verbose mode.
2019-07-26 11:56:39 +03:00
Jussi Pakkanen f2e018c7f3 Create multiple different archive types with dist. 2019-07-23 23:26:46 +03:00
Nirbheek Chauhan 4200afc74d unit tests: Check whether pytest-xdist is available
Also, always run pytest using the module format to ensure that we're
always using the Python interpreter selected by the user.

Fixes issue reported in https://github.com/mesonbuild/meson/pull/5621#issuecomment-513034198
2019-07-20 07:39:18 +00:00
Nirbheek Chauhan 81b6c9ef8c unit tests: Use a timeout for tests that use the network
It's better to quickly skip when the network is unavailable or slow.
2019-07-20 06:14:22 +00:00
Nirbheek Chauhan 43aae8243c unit tests: Test more syntax highlighting data
@TingPing has a repository that contains a grammar for meson which is
used by linguist (GitHub), and by many editors such as Atom, VS Code,
TextMate, Sublime Text, etc. Add CI so that we notice that the
function list in it is out of date, such as https://github.com/TingPing/language-meson/pull/3

It's harder to do this generically for other syntax such as the `in`
keyword, but it's better than nothing.
2019-07-18 23:44:45 +03:00
Daniel Mensinger 3b3f53ab55 mintro: Fix section key in buildoptions
This reverts the changes to the `section` key for the
buildoptions and moves the machine choice into it's
own `machine` key.

With this commit the __undocumented__ breaking change
to the introspection format (introduced in 0.51.0) is
reverted and a new key is added instead.
2019-07-17 19:20:33 +03:00
Dylan Baker 7803056ef2 run_unittests: use sys.executable on Windows for python
Instead of trying to guess whether we need py or python3, and then
falling over when whatever we guessed isn't in the path or isn't right,
just use sys.executable which should always work.
2019-07-15 10:59:22 -07:00
David Seifert cd12a6fc39 Add test to catch `-Werror=unused-parameter` brittleness 2019-07-14 15:12:16 +00:00
Nirbheek Chauhan 264533cb67 unit tests: Don't keep builddirs inside source tree on Cygwin
Seems to cause the umask tests to fail:
https://github.com/mesonbuild/meson/pull/5546#issuecomment-509666523
2019-07-12 21:49:48 +03:00
Michael Hirsch, Ph.D d5cb1c2f19
Merge pull request #5560 from scivision/cstd18_bug
add clang c_std=c18 alias and cleanup logic for compiler version unit tests
2019-07-11 19:23:05 -04:00
Jussi Pakkanen 19cda6b7c9
Merge pull request #5606 from xclaesse/alias_target
Add alias_target() function
2019-07-11 00:34:40 +03:00
Xavier Claessens 12d4031f52 Add alias_target() function 2019-07-10 15:01:18 -04:00
Jussi Pakkanen b1fbbde0b0 Use pytest parallelisation if available. 2019-07-09 22:38:30 +03:00
Nirbheek Chauhan 716140ddb4 unit tests: Fix CI failures in NativeFileTests
We can't rely on 'py' always being available in PATH, use
sys.executable which is the real path to Python 3.
2019-07-09 19:28:51 +05:30
Michael Hirsch, Ph.D 2dc11bcb53
typo 2019-07-08 22:33:34 -04:00
Michael Hirsch, Ph.D 763b05e074
cleanup clang version minimum 2019-07-08 22:28:25 -04:00
Michael Hirsch, Ph.D c756d06fbb
add clang c_std=c18 alias
fix unit test skips for clang c18

correct unittests clang minimum version

cleanup unittest clang skip c_std

finesse unittest vs. clang version
2019-07-08 22:27:35 -04:00
Jussi Pakkanen 380dcedb86 Hack envvar override when running tests in-process. 2019-07-08 22:57:04 +03:00
Jussi Pakkanen b9a771fef8 Use environment variable overrides. 2019-07-08 22:57:04 +03:00
Jussi Pakkanen 84ac5ce51e Convert some methods to use mandatory named kwargs. 2019-07-08 19:36:15 +03:00
Jussi Pakkanen 74611ecb1f Fix unittests. 2019-07-05 22:27:10 +03:00
Daniel Mensinger 54b1c43277 mintro: Add installed subdirs introspection (fixes #5556) 2019-07-01 11:28:54 -07:00
Aleksey Gurtovoy 7423247413 Fix failing test_find_program test (Windows-only)
Skip finding a .py script w/o extension on Windows if `.PY` isn't in
PATHEXT; closes #4355
2019-06-27 21:30:34 +03:00
Aleksey Gurtovoy 8ebe3d46bb Fix faling test_msvc_toolset_version test
VCToolsVersion is not always set, and MS docs  recommend getting the
info from a file
2019-06-27 20:44:29 +03:00
Dylan Baker 42bef8d418 run_unitests: Skip the native_file_is_pipe test on cygwin
Since it hangs and causes azure to time out.
2019-06-24 13:51:34 -07:00
Jussi Pakkanen 59e5ad66f2 Keep all build dirs inside the source tree.
VS and virus scanners complain when generating executables
in temporary directories.
2019-06-24 01:52:54 +03:00
Dylan Baker 56f7e5c74f coredata: Correctly handle receiving a pipe for native/cross files
* coredata: Correctly handle receiving a pipe for native/cross files

In some cases a cross/native file may be a pipe, such as when using bash
process replacement `meson --native-file
<([binaries]llvm-config='/opt/bin/llvm-config')`, for example. In this
case we copy the contents of the pipe into a file in the meson-private
directory so we can create a proper ninja dependency, and be able to
reload the file on --wipe/--reconfigure. This requires some extra
negotiation to preserve these native/cross files.

Fixes #5505

* run_unitests: Add a unit test for native files that are pipes

Using mkfifo.
2019-06-23 17:53:17 +03:00
Nirbheek Chauhan 9042130e9a compilers: Fix bitcode and other options for objc code
We were setting the base options for the Objective-C compiler
manually, due to which options such as b_bitcode and b_ndebug were not
getting set at all.

The base options here are the same as for C code with the Clang
compiler, so just use the same inherited list.

Also expand the bitcode test to ObjC and ObjC++ so this doesn't happen
again.
2019-06-23 16:50:24 +03:00
John Ericson 6d6af46edc Make test for identity
(cherry picked from commit ae6426cd8acfe0ccc5d7958d55edb613b4a5bf01)
2019-06-09 13:14:55 -04:00
John Ericson 07777e15d4 Purge `is_cross` and friends without changing user interfaces
In most cases instead pass `for_machine`, the name of the relevant
machines (what compilers target, what targets run on, etc). This allows
us to use the cross code path in the native case, deduplicating the
code.

As one can see, environment got bigger as more information is kept
structured there, while ninjabackend got a smaller. Overall a few amount
of lines were added, but the hope is what's added is a lot simpler than
what's removed.
2019-06-09 13:13:25 -04:00
Jussi Pakkanen 82e36a6bfe Add tests for std usage. Closes #5097.
(cherry picked from commit 27ae70dfaaff1298e68df70098acaa96f7ca748a)
2019-06-05 23:05:49 -04:00
John Ericson af2d7af998 Per machine do 'build.' and '' option prefixes
See the docs/ changes for details.
2019-06-05 23:05:34 -04:00
Dylan Baker 2e2c3c968c tests: Test the cmake parser more thuroughly
It turns out there are bugs, in particular with spaces in variables...
2019-05-29 11:25:27 -07:00
Dylan Baker 0714ba58c7 coredata: add cmake_prefix_path option 2019-05-27 01:24:08 +03:00
Christoph Reiter 7ce9e56a4b Fix path splitting in get_compiler_dirs() with GCC/clang on Windows
It was using ':' as a path separator while GCC uses ';' resulting in bogus
paths being returned. Instead assume that the compiler uses the platform native
separator.

The previous splitting code still worked sometimes because splitting
"C:/foo;C:/bar" resulted in the last part "/bar" being valid if "<DriveOfCWD>:/bar"
existed.

The fix also exposes a clang Windows bug where it uses the wrong separator:
https://reviews.llvm.org/D61121 . Use a regex to fix those first.

This resulted in linker errors when statically linking against a library which
had an external dependency linking against system libs.

Fixes #5386
2019-05-16 23:05:49 +03:00
Dylan Baker 61750494f5 run_unittests: make cross file location test robust against environment
Currently this test assumes that the user doesn't have XDG_DATA_HOME
set in their path, but this isn't a good assumption, and can result in
the test not actually testing what it means to.
2019-05-16 22:51:38 +03:00
John Ericson 957d8e051c Make `PerMachine` and `MachineChoice` have just `build` and `host`
Meson itself *almost* only cares about the build and host platforms. The
exception is it takes a `target_machine` in the cross file and exposes
it to the user; but it doesn't do anything else with it. It's therefore
overkill to put target in `PerMachine` and `MachineChoice`. Instead, we
make a `PerThreeMachine` only for the machine infos.

Additionally fix a few other things that were bugging me in the process:

 - Get rid of `MachineInfos` class. Since `envconfig.py` was created, it
   has no methods that couldn't just got on `PerMachine`

 - Make `default_missing` and `miss_defaulting` work functionally. That
   means we can just locally bind rather than bind as class vars the
   "unfrozen" configuration. This helps prevent bugs where one forgets
   to freeze a configuration.
2019-05-16 00:27:57 +03:00
Jussi Pakkanen 7b8ef78bc0
Merge pull request #5331 from dcbaker/icl
ICL (Intel for Windows) support
2019-05-14 00:24:48 +03:00
Dylan Baker 080f59cf43 compilers: rename IntelCompiler to IntelGnuLikeCompiler
The Intel compiler is strange. On Linux and macOS it's called ICC, and
it tries to mostly behave like gcc/clang. On Windows it's called ICL,
and tries to behave like MSVC. This makes the code that's used to
implement ICC support useless for supporting ICL, because their command
line interfaces are completely different.
2019-05-13 11:22:31 -07:00
Antoine Jacoutot e2f6f47fa3 unittests: adapt pkg-config test for OpenBSD
pkg-config(1) on OpenBSD is not the one from freedesktop.org and hence has
subtle differences (which don't impact real usage). The meson test fails
because white space between operators are stripped by our pkg-config:

$ grep Require /usr/local/lib/pkgconfig/xmlsec1.pc
Requires: libxml-2.0 >= 2.8.0 libxslt >= 1.0.20
$ pkg-config --print-requires xmlsec1
libxml-2.0>=2.8.0
libxslt>=1.0.20
2019-05-13 02:46:51 +03:00
Dylan Baker dcfd918548 run_unittests: assume that on windows that intel means icl
There actually is an ICC for windows that can be used to cross compile
from Windows to Linux, but it's not supported in meson currently and I
don't plan to enable it.
2019-05-10 13:51:24 -07:00
Dylan Baker 3e82a4b517 run_unittests: intel-cl links like msvc 2019-05-10 13:43:20 -07:00
Dylan Baker 73eca8255b run_unittests: Don't assume that VS like compilers have MSVC versions 2019-05-10 13:38:20 -07:00
Dylan Baker c72fd1e333 run_unittests: ICL also doesn't do proper resource dependency detection 2019-05-10 13:38:20 -07:00
Dylan Baker 541523eeba compilers: Split C-Like functionality into a mixin classes
Currently C++ inherits C, which can lead to diamond problems. By pulling
the code out into a standalone mixin class that the C, C++, ObjC, and
Objc++ compilers can inherit and override as necessary we remove one
source of diamonding. I've chosen to split this out into it's own file
as the CLikeCompiler class is over 1000 lines by itself. This also
breaks the VisualStudio derived classes inheriting from each other, to
avoid the same C -> CPP inheritance problems. This is all one giant
patch because there just isn't a clean way to separate this.

I've done the same for Fortran since it effectively inherits the
CCompiler (I say effectively because was it actually did was gross
beyond explanation), it's probably not correct, but it seems to work for
now. There really is a lot of layering violation going on in the
Compilers, and a really good scrubbing would do this code a lot of good.
2019-05-03 10:36:50 -07:00
Martin Hostettler ed109801c6 munstable_coredata: Adapt to coredata changes. 2019-05-02 23:55:53 +03:00
Jussi Pakkanen 1f4023fa47
Merge pull request #5311 from mensinda/flake8Plugins
Added flake8 plugins and some code fixes
2019-05-02 23:30:29 +03:00
Peter Hutterer 70997ca969 mtest: check for an empty suite list
For consistency, it can be useful to have an explicit empty test suite list
for a test:

   test('test-name', binary, suite: [])

This currently passes meson but fails when running meson tests:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 122, in run
    return options.run_func(options)
  File "/usr/lib/python3.7/site-packages/mesonbuild/mtest.py", line 1005, in run
    return th.doit()
  File "/usr/lib/python3.7/site-packages/mesonbuild/mtest.py", line 756, in doit
    self.run_tests(tests)
  File "/usr/lib/python3.7/site-packages/mesonbuild/mtest.py", line 896, in run_tests
    visible_name = self.get_pretty_suite(test)
  File "/usr/lib/python3.7/site-packages/mesonbuild/mtest.py", line 875, in get_pretty_suite
    rv = TestHarness.split_suite_string(test.suite[0])[0]
IndexError: list index out of range

Fix it by simply checking for the test suite to be a valid list we can pass on

Fixes #5340

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-05-02 22:12:58 +03:00
Daniel Mensinger 236221061a
Fixed unnecessary .items() 2019-04-29 12:23:13 +02:00
Daniel Mensinger e75211d321
Fix builtin variable names 2019-04-29 12:17:40 +02:00
Daniel Mensinger bf98ffca9e
Fix blind exceptions 2019-04-29 12:16:06 +02:00
Dylan Baker 914b591692 run_unittets: extend version tests to cover other cases
Before this we only covered >, <, and ==, but we an apply some basic
logic to know that a > b == !(a <= b), or that if a > b then a != b.
This uncovered some bugs I wrote while working on this code.
2019-04-25 12:28:51 -07:00
Dylan Baker 397ac5921a run_unittests: rewrite version test to not call private methods
We really should be testing using the operators themselves, not the
internal implementations, ie we should use a > b not a.__cmp__(b) == 1
in our tests, because __cmp__ is just an implementation detail.
2019-04-25 12:28:51 -07:00
Dylan Baker add821db64 Don't use mutable types as default arguments
This isn't safe given the way python implements default arguments.
Basically python store a reference to the instance it was passed, and
then if that argument is not provided it uses the default. That means
that two calls to the same function get the same instance, if one of
them mutates that instance every subsequent call that gets the default
will receive the mutated instance. The idiom to this in python is to use
None and replace the None,

def in(value: str, container: Optional[List[str]]) -> boolean:
   return src in (container or [])

if there is no chance of mutation it's less code to use or and take
advantage of None being falsy. If you may want to mutate the value
passed in you need a ternary (this example is stupid):

def add(value: str, container: Optional[List[str]]) -> None:
    container = container if container is not None else []
    container.append(value)

I've used or everywhere I'm sure that the value will not be mutated by
the function and erred toward caution by using ternaries for the rest.
2019-04-23 02:03:19 +03:00
Dylan Baker 3edc7f343b coredata: store cross/native files in the same form they will be used (#5224)
* coredata: store cross/native files in the same form they will be used

Currently they're forced to absolute paths when they're stored in the
coredata datastructure, then when they're loaded we de-absolute path
them to check if they're in the system wide directories. This doesn't
work at all, since the ninja backend will generat a dependency on a
file that is in the source directory unless the path was already given
as absolute. This results in builds being retriggereed forever due to
a non-existant file.

The right way to do this is to figure out whether the file is in the
build directory, is absolute, or is in one of the system paths at
creation time, and store that path as absolute. Then the code that
reads the file and the code that generates the dependencies in the
ninja backend just takes the computed list and there is no mismatch
between them.

Fixes #5257

* run_unittests: Add a test for correct native file storage

This tests the bug in #5257
2019-04-21 23:10:02 +03:00
makise-homura 94b7ff3823 Correctly find lfortran for Elbrus compiler 2019-04-19 18:39:04 +03:00
Nirbheek Chauhan 2795f942be interpreter: Check the meson version before parsing options
Also add a test for it so we don't regress this in the future.

Closes https://github.com/mesonbuild/meson/issues/5281
2019-04-18 19:18:21 +00:00
Nirbheek Chauhan 2e93ed58c3 unit tests: Skip toolset version test on VS2015 and older 2019-04-18 09:01:23 +00:00
Nirbheek Chauhan 7654db511c vs: Update toolset table for VS 2019
Also add a test to ensure that we don't forget it in the future.
2019-04-18 09:01:23 +00:00
Paolo Bonzini 2942467148 add test case for generator dependencies 2019-04-16 01:46:31 +00:00
Nirbheek Chauhan 10468b3a28 interpreter: Warn when environment() ops are overriden
Warn when someone tries to use append() or prepend() on an env var
which already has an operation set on it. People seem to think that
multiple append/prepend operations stack, but they don't.

Closes https://github.com/mesonbuild/meson/issues/5087
2019-04-13 22:53:33 +03:00
TheQwertiest 2499e25476 Added a unit test for built-in options docs 2019-04-12 00:24:07 +03:00
Daniel Mensinger d72d98d3af mintro: removed deprecated --target-files API 2019-04-08 21:06:15 +03:00
Nirbheek Chauhan ef87d11dcd
Merge pull request #4931 from dcbaker/pkg-config-builtin
dependencies: Add command line option for pkg_config_path
2019-04-07 07:55:36 +00:00
Dylan Baker 91b2475e30 dependencies/pkg-config: Add support for different cross_flags 2019-04-05 15:08:17 -07:00
Dylan Baker 569e646e1e dependencies: Add command line option for pkg_config_path
This creates a new command line option to store pkg_config_path into,
and store the environment variable into that option. Currently this
works like the environment variable, for both cross and native targets.
2019-04-05 15:08:17 -07:00
Antoine Jacoutot d4cece3b34 test_pkgconfig_formatting: OpenBSD, libintil is a separate library 2019-04-03 08:54:06 -07:00
Daniel Mensinger 1937bbafac
mintro: Fix crash when required is a function (closes #5177) 2019-04-02 11:21:05 +02:00
Jussi Pakkanen 75219989ca
Merge pull request #5128 from Ericson2314/sanity-check-with-flags
Sanity check with external args
2019-04-02 00:40:05 +03:00
Jussi Pakkanen e3e83e2acd Also format headers with Clang-Format. Closes #5184. 2019-04-01 01:26:53 +03:00
John Ericson 507b1dc40e Fix test_compiler_*_stds tests after last commit
Since sanity check now includes CFLAGS, the test fails earlier.

But if the compiler is ICC, it will only fail during the build proper as
before, since that's where where the flag making `-std=unknown` an error
not warning is used.
2019-03-27 10:54:56 -04:00
John Ericson d361da991b Change test to reflect new semantics 2019-03-27 14:45:42 +00:00
Jussi Pakkanen f46b485fc2
Merge pull request #5083 from rossburton/crossfiles
Support multiple --cross-file options
2019-03-20 18:46:32 +02:00
Dylan Baker ac627bcea7 replace library type strings with an enum
This patch creates an enum for selecting libtype as static, shared,
prefer-static, or prefer-shared. This also renames 'static-shared'
with 'prefer_static' and 'shared-static' with 'prefer_shared'. This is
just a refactor with no behavioral changes or user facing changes.
2019-03-20 18:45:56 +02:00
Ross Burton a87b51f75c Add test case for multiple cross files 2019-03-20 10:06:17 +00:00
Ross Burton 1a2b5d3b53 run_unittest: update for cross_file being a list 2019-03-20 10:06:17 +00:00
Nirbheek Chauhan 07818dac6a compilers: Try harder to dedup builtin libs
Compiler internal libs should always be de-duplicated, no matter what.

Closes https://github.com/mesonbuild/meson/issues/2150

Test case is by Bruce Richardson in the issue.
2019-03-14 12:21:05 +00:00
Antoine Jacoutot 5d3e20984d compilers: -fsanitize is not supported on OpenBSD (second pass)
Similar to https://github.com/mesonbuild/meson/pull/5067
This part was missed in my previous commit.
2019-03-13 08:57:46 +00:00
Antoine Jacoutot f7af1a6285 compilers: -fsanitize is not supported on OpenBSD
OpenBSD doesn't have any support for the compiler sanitizers yet.
While this may change in the future, better fix test suite run in "failfast"
mode for now. This can be revisited once (if) we get support in the future.

* clang 7.0.1
$ make CFLAGS=-fsanitize=address foo
cc -fsanitize=address   -o foo foo.c
cc: error: unsupported option '-fsanitize=address' for target 'amd64-unknown-openbsd6.5'

* gcc 4.2.1
*** Error 1 in /tmp (<sys.mk>:85 'foo')
$ make CC=gcc CFLAGS=-fsanitize=address foo
gcc -fsanitize=address   -o foo foo.c
cc1: error: unrecognized command line option "-fsanitize=address"

* gcc 8.2.0
$ make CC=egcc CFLAGS=-fsanitize=address foo
egcc -fsanitize=address   -o foo foo.c
ld: error: unable to find library -lasan
collect2: error: ld returned 1 exit status
2019-03-13 06:35:58 +00:00
John Ericson 9409155d5a Avoid module patching in `test_find_library_patterns`
This is less hacky, and also prepares the way for #4010.
2019-03-12 04:03:47 +00:00
Niklas Claesson dd2c44cdf6 Add static as keyword to find_library 2019-03-11 20:56:52 +02:00
Ignacio Casal Quinteiro c6f84a223c Add unit test for pkgconfig relative paths 2019-03-11 17:38:22 +00:00
Antoine Jacoutot c1c699eda4 Fix unit test: test_find_library_patterns 2019-03-11 06:02:17 +00:00
Jussi Pakkanen 7589471978 Condense directory numbering for release. 2019-03-10 18:39:03 +02:00
Daniel Mensinger 91918262e7
rewriter: Fixed unit tests 2019-03-04 13:14:48 +01:00
Daniel Mensinger 594bf678c7
rewriter: Require '/' for the project ID 2019-03-04 13:00:30 +01:00
Daniel Mensinger 609a21ff9f
rewriter: Abort on error by default 2019-03-04 13:00:30 +01:00
Daniel Mensinger 5d2f14fce7
rewriter: Quiet logging by default 2019-03-04 13:00:30 +01:00
Daniel Mensinger e724fd5438
rewriter: Handle duplicate target 2019-03-04 13:00:29 +01:00
Daniel Mensinger b55dbf0fae
rewriter: Dump JSON to stderr instead of stdout 2019-03-04 13:00:07 +01:00
Daniel Mensinger 740f6b8f06
rewriter: Implemented a CLI 2019-03-04 13:00:05 +01:00
Daniel Mensinger 2582f311b0
rewriter: Make sure target sources are relative 2019-03-04 13:00:05 +01:00
Daniel Mensinger 760d1bff9c rewriter: Sort source files (#5010)
* rewriter: Sort source files

* rewriter: Natural sorting

* rewriter: Fix flake8

* rewriter: Fixed sorting

* rewriter: Make sorting key more readable

* rewriter: Even simpler key
2019-03-04 13:58:35 +02:00