Commit Graph

243 Commits

Author SHA1 Message Date
Jussi Pakkanen 0b2a7300c0 Set up VS environment automatically when run. 2021-05-13 11:03:10 +03:00
Jussi Pakkanen 1d06d4ca1a Set unittest backend with an argument rather than an envvar. 2021-05-08 21:35:08 +03:00
Jussi Pakkanen 0e4c358f35 Xcode: add objective C flags to plain C because Xcode requires it. 2021-04-25 15:35:13 +03:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Eli Schwartz 4340bf34fa
various python neatness cleanups
All changes were created by running

"pyupgrade --py3-only --keep-percent-format"

and committing the results. I have not touched string formatting for
now.

- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
2021-03-04 17:11:26 -05:00
Dylan Baker 44c836e0d9 add a script to run a single test
As a Meson developer it's often frustrating to have a single functional
test with a regression. These tests can be awkward to reproduce,
especially when they make use of a test.json file. This script provides
a simmple interface to call functional tests 1 at a time, regardless of
whether they use a test.json or not. If they do use a test.json, and
have a matrix, then the `--subtest` option can be used to select spcific
combinations, for example:
```sh
./run_single_test.py "test cases/frameworks/15 llvm" --subtest 1
```
will run only the second (zero indexed of course) subtest from the llvm
test cases.

This is not a super elegent script, but this is super useful.
2021-02-23 09:08:55 -08:00
Dylan Baker 3e11da6db5 run_*_tests: Add some type annotations 2021-02-23 08:38:19 -08:00
Paolo Bonzini 9ba7b0ebd0 mlog: add __str__ method to AnsiDecorator
Automatically colorize the text when printing the AnsiDecorator, based
on the result of mlog.colorize_console().  This is how AnsiDecorator
is used most of the time anyway.
2021-01-21 08:54:35 -05:00
Dylan Baker e81acbd606 Use a single coredata dictionary for options
This patches takes the options work to it's logical conclusion: A single
flat dictionary of OptionKey: UserOptions. This allows us to simplify a
large number of cases, as we don't need to check if an option is in this
dict or that one (or any of 5 or 6, actually).
2021-01-04 12:20:58 -08:00
Dylan Baker f9b19e73a5 move OptionKey to mesonlib
There's starting to be a lot of things including coredata that coredata
needs to itself include. putting it in mesonlib makes more sense
2021-01-04 12:20:40 -08:00
Dylan Baker fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Dylan Baker f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08:00
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Dylan Baker bb3fe3c451 compilers/mixins/clike: fix mypy issues 2020-09-24 12:14:13 -07:00
Dylan Baker 80ec7ec681 tests: Make monkey patching smarter
There are two problems here. The first is that we're doing manual monkey
patching which is fragile and verbose, when unittest.mock is designed
specifically to solve this exact problem. The second is that we're
monkey patching os.environ at two different levels with the same
information. So let's only do it once.
2020-09-17 11:26:50 +00:00
Jon Turney 36600d7465 Add a test run in an environment which only has a cross compiler
Add '--cross-only' option to run_tests.py, so we can arrange not to run
tests in the 'native' suite when only a cross-compiler is available, as
they can't succeed.
2020-09-10 07:20:41 +00:00
Daniel Mensinger 8f95efe40b
typing: fixup of #7688
This bug not beeing caught in review is another reason for
adding strict typing support to meson.
2020-09-08 20:15:59 +02:00
Michael Hirsch 1ec84c570f run_*tests*.py: print Meson version at start of test suite
on some systems, tests may take over an hour to run--only to find
you might have used an unintended Meson version (e.g. release instead
of dev). This change prints the Meson version at the start of the
run_*tests*.py scripts.

Also, raise SystemExit(main()) is preferred in general over
sys.exit(main())
2020-06-15 23:33:40 +03:00
Jon Turney f107f9b396
Make colourize_console() a function
Currently, colourize_console is a constant, set at process
initialization.

To allow the actual stdout to be easily compared with the expected when
running tests, we want to allow colourization to be on for the test
driver, but not for the in-process configure done by run_configure,
which has stdout redirected from a tty to a pipe.

v2:
Cache _colorize_console per file object

v3:
Reset cache on setup_console()
2020-04-30 20:11:31 +01:00
John Ericson 278c294aa4 Compiler options per lang
A current rather untyped storage of options is one of the things that
contributes to the options code being so complex. This takes a small
step in synching down by storing the compiler options in dicts per
language.

Future work might be replacing the langauge strings with an enum, and
defaultdict with a custom struct, just like `PerMachine` and
`MachineChoice`.
2020-04-20 23:23:15 +03:00
Nirbheek Chauhan be486a2ec8 ninjabackend: List PDBs in output list for targets
This is more correct, and forces the target(s) to be rebuilt if the
PDB files are missing. Increases the minimum required Ninja to 1.7,
which is available in Ubuntu 16.04 under backports.

We can't do the same for import libraries, because it is impossible
for us to know at configure time whether or not an import library will
be generated for a given DLL.
2020-02-22 06:49:34 +05:30
Jon Turney 26d1c2a52d
Specify crossfile use in CI job configuration
Pull the crossfile specification out of run_test.py so it can be
specified in the CI job configuration.

Also make some fixes to output ordering in run_test.py.
2020-01-28 21:41:22 +00:00
Nirbheek Chauhan b9d0c7a169 run_tests: Fix detection of ninja 1.9
`get_backend_commands()` doesn't get called when we run tests as
subprocesses, so detect ninja on import. This should speed up CI.

Fixes https://github.com/mesonbuild/meson/issues/5888
2020-01-15 12:14:30 +05:30
Dylan Baker 31bb6eae45 run_tests.py: use mlog.log_once to avoid spamming ninja < 1.9 warnings 2019-12-13 09:57:05 -05:00
Daniel Mensinger 286b9f0921 lgtm: Fix Module imported with `import` and `import from` 2019-12-05 00:22:10 +02:00
Daniel Mensinger 80ec5e9d28 Fix all flake8 warnings 2019-10-20 17:44:43 +03:00
Aleksey Gurtovoy 75daed27bc mesonlib.split_args/quote_arg/join_args 2019-09-05 23:42:47 +03:00
Nirbheek Chauhan 35732dfaa1 tests: Require ninja 1.9 on CI
Also, print messages when we have to enable the timestamp resolution
workaround.
2019-09-01 22:58:33 +03:00
Nirbheek Chauhan 48f3495178 tests: Upgrade to ninja v1.9 for Linux
Also use the upstream release. This eliminates Meson CI's dependence
on my server.
2019-09-01 22:58:33 +03:00
Nirbheek Chauhan 96088d3e51 tests: Detect ninja v1.9 and disable timestamp hack
The high-res timestamp PR by QuLogic was merged in v1.9, so we can
switch back to upstream ninja.
2019-09-01 22:58:33 +03:00
Michael Hirsch, Ph.D e3b21de563 Intel-Cl tests: increase robustness of Windows Intel compilers detection (#5828)
* intel-cl tests: more rigorous detection of intent to use Intel Windows compilers

* fortran coarray test: make skipping more robust in that underlying MPI stack is .run()

This is useful for any Fortran coarray work, and especially for intel-cl where multiple Intel compiler
versions are often installed, and the wrong underlying MPI library may be dynamically linked,
and so a runtime check is needed to exercise the MPI stack underlying Fortran coarray.
This is done by

fc.run('sync all; end', dependencies: coarray)

* pep8
2019-08-24 02:33:54 +03:00
John Ericson d8335fb032 Put native file before cross file in options list
I think this makes more sense by matching how build comes before host.
Native builds are also more common than cross builds.
2019-08-12 01:21:32 +03:00
Michael Hirsch, Ph.D b5e9ab8ed0
fortran tests: non-gfortran compilers on Windows are best static libs
collapsed get_relative_files_list_from_dir to a one-liner via pathlib.Path
2019-07-30 03:17:14 -04:00
Michael Hirsch, Ph.D 667cc80f72
run_tests: ifort / intel-cl must have ninja backend 2019-07-30 03:14:25 -04:00
Daniel Mensinger 3b2126531a cmake: added test case for environment variables 2019-07-23 05:50:55 +00:00
Jussi Pakkanen 4b1ab96795 Add command line argument to skip unit tests. 2019-07-09 22:03:58 +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
Daniel Mensinger 3581839f4c
Fix unused variables warnings 2019-04-29 12:22:50 +02:00
Jon Turney 10749494c8
Flush run_tests output so it appears before the test subprocesses it runs
This makes 'System information', 'Running unittests', etc. appear before
any test output.
2019-04-15 12:07:17 +01:00
John Ericson 19f81d3e33 Never access environment.properties downstream
Instead use coredata.compiler_options.<machine>. This brings the cross
and native code paths closer together, since both now use that.

Command line options are interpreted just as before, for backwards
compatibility. This does introduce some funny conditionals. In the
future, I'd like to change the interpretation of command line options so

 - The logic is cross-agnostic, i.e. there are no conditions affected by
   `is_cross_build()`.

 - Compiler args for both the build and host machines can always be
   controlled by the command line.

 - Compiler args for both machines can always be controlled separately.
2019-02-02 13:59:14 -05:00
Nirbheek Chauhan 50b863032e find_library: Check arch of libraries on Darwin
macOS provides the tool `lipo` to check the archs supported by an
object (executable, static library, dylib, etc). This is especially
useful for fat archives, but it also helps with thin archives.

Without this, the linker will fail to link to the library we mistakenly
'found' like so:

ld: warning: ignoring file /path/to/libfoo.a, missing required architecture armv7 in file /path/to/libfoo.a
2019-01-31 20:36:49 +00:00
Nirbheek Chauhan c0166355ce Rewrite appleframework and extraframework dependency classes
Instead of only doing a naive filesystem search, also run the linker
so that it can tell us whether the -F path specified actually contains
the framework we're looking for.

Unfortunately, `extraframework` searching is still not 100% correct in
the case when since we want to search in either /Library/Frameworks or
in /System/Library/Frameworks but not in both. The -Z flag disables
searching in those prefixes and would in theory allow this, but then
you cannot force the linker to look in those by manually adding -F
args, so that doesn't work.
2019-02-01 00:14:09 +05:30
Nirbheek Chauhan 3997e8762e unit tests: Fix sdl2 failure test on macOS
Also ensure that the test's no-pkg-config codepath will always be run,
even on the CI where we always have pkg-config available.

This counts as a test case for #4728
2019-01-31 20:12:21 +05:30
Nirbheek Chauhan 58852e6290 unit tests: Simplify get_fake_env()
Almost every test already uses '' for the srcdir/builddir/etc.
Make it official.
2019-01-31 20:12:21 +05:30
John Ericson 2b22576fb6 Remove cross_info; cross file is parsed up front and discarded 2019-01-02 16:22:47 -05:00
Daniel Mensinger 194adc828f Only autodetect 'vs' backend on windows 2018-12-11 20:54:17 +02:00
Dylan Baker 3af4407a16 Get basic native config file loading working 2018-11-14 15:57:37 -08:00
Jussi Pakkanen 252bf6c52e
Merge pull request #4340 from jon-turney/azure-pipelines
Add Azure pipelines CI
2018-10-14 23:16:46 +03:00
Jon Turney 459b81de46
Use 'CI' environment variable to detect CI environment
Use the 'CI' environment variable to detect CI environment, rather than a
collection of CI-specific ones.
2018-10-14 16:01:36 +01:00
Niklas Claesson d964da79e7 tests: Merge backend guessing into one function 2018-10-10 21:32:02 +02:00