Commit Graph

91 Commits

Author SHA1 Message Date
Paolo Bonzini 492afe50a4 environment: use ExternalProgram to find ninja
This allows the NINJA environment variable to support all the Windows special
cases, especially allowing an absolute path without extension.

Based on a patch by Yonggang Luo.

Fixes: #7659
Suggested-by: Nirbheek Chauhan <nirbheek@centricular.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-09-04 15:38:12 +02:00
Christoph Reiter 0710ad18d9 Be stricter when detecting Windows/Cygwin
This removes the check for "mingw" for platform.system(). The only case I know
where "mingw" is return is if using a msys Python under a msys2 mingw environment.
This combination is not really supported by meson and will result in weird errors,
so remove the check.

The second change is checking sys.platform for cygwin instead of platform.system().
The former is document to return "cygwin", while the latter is not and just
returns uname().

While under Cygwin it uname() always starts with "cygwin" it's not hardcoded in MSYS2
and starts with the environment name. Using sys.platform is safer here.

Fixes #7552
2020-08-30 23:37:46 +03:00
Nirbheek Chauhan cdc2a67687 mtest: Actually call colorize_console() 2020-08-13 22:54:19 +03:00
Marc-André Lureau 8e98819b06 mtest: fix skipping with various prefixes
According to the specification:
https://testanything.org/tap-specification.html#skipping-tests

  The harness should report the text after # SKIP\S*\s+ as a reason for
  skipping.

(it's not exactly like the TODO directive, the phrasing/presentation of
the spec could be improved).
2020-08-08 01:25:05 +03:00
Simon McVittie 7db49db67d
mtest: TestResult.SKIP is not a failure (#7525)
* mtest: TestResult.SKIP is not a failure

If some but not all tests in a run were skipped, then the overall result
is given by whether there were any failures among the non-skipped tests.

Resolves: https://github.com/mesonbuild/meson/issues/7515
Signed-off-by: Simon McVittie <smcv@debian.org>

* Add test-cases for partially skipped TAP tests

issue7515.txt is the output of one of the real TAP tests in gjs, which
failed as a result of #7515. The version inline in meson.build is
a minimal reproducer.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-08-05 23:08:05 +03:00
Camilo Celis Guzman 8da1b29899 mtest: report failures and overall summary *after* test(s) logs 2020-07-30 16:38:07 +03:00
Dylan Baker af787874a8 pass exe_wrapper to test scripts through the environment
This adds a new MESON_EXE_WRAPPER environment variable containing the
string form of the exe_wrapper, if there is an exe_wrapper defined.

Fixes #4427
2020-05-18 13:53:58 -07:00
Dylan Baker 0ec94ca062 backends: Consider arguments passed to a test when cross compiling
Otherwise a wrapper script which takes an executable as an argument will
mistakenly run when that executable is cross compiled. This does not
wrap said executable in an exe_wrapper, just skip it.

Fixes #5982
2020-05-18 13:53:58 -07:00
Dylan Baker 754080843b mtest: don't use len() to test container emptiness
It's not idiomatic python and is significantly slower than not using the
bool protocol.
2020-05-18 13:53:58 -07:00
Dylan Baker 083c5f6357 Add native support for gtest tests
Gtest can output junit results with a command line switch. We can parse
this to get more detailed results than the returncode, and put those in
our own Junit output. We basically just throw away the top level
'testsuites' object, then fixup the names of the tests, and shove that
into our junit.
2020-05-04 11:33:19 -07:00
Dylan Baker 28e3ce67ae Convert test protocol into an enum
This gives us better type safety, and will be important as we add more
test methods
2020-04-30 13:54:46 -07:00
Dylan Baker fe46515630 mtest: use argparse.type to simplify some code 2020-04-30 13:30:37 -07:00
Dylan Baker 542255993c mtest: Replace if (bool) { return bool; } with return bool; 2020-04-30 13:29:16 -07:00
Dylan Baker 7b7f93a09f mtest: Generate a JUnit xml result file
JUnit is pretty ubiquitous, lots of services and results viewers
understand it, in particular gitlab and jenkins know how to consume
JUnit xml. This means projects using CI services can have their test
results consumed automatically.

Fixes: #6972
2020-04-23 13:26:01 -07:00
Dylan Baker 0c3bb15357 mtest: Store individual results for TAP tests
This will be used by the Junit writer
2020-04-23 13:26:01 -07:00
Dylan Baker 4dcbb9254a mtest: Use textrwap.dedent for large block
This allows editors like vim to properly fold the code, and makes it
generally easier to read.
2020-04-22 13:55:19 -07:00
Hemmo Nieminen 30ba9cca72 mtest: Improve test output formatting.
Remove some weirdness from test output such as extra commas, missing
spaces and way too precise time durations. Also improve the overall
alignment of the output.
2020-04-03 00:51:52 +03:00
Camilo Celis Guzman 18373cba74 mtest: terminate a test via SIGTERM first then (if needed) via SIGKILL 2020-03-19 23:04:36 +02:00
Michael Brockus 98ddd52ced
Cherry-picking - (rm python2 % add python3 .format) (#6725) 2020-03-03 21:45:43 +02:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Camilo Celis Guzman 7a76fecdf7 mesonbuild/mtest: plumb and report a test's start time 2019-11-07 22:22:14 +02:00
Michael Hirsch, Ph.D 6e708208dd CI: add initial type annotation checking 2019-11-07 22:18:21 +02:00
Wolfgang Stöggl f037e7ef45 Fix typos found by codespell
- Typos were found by codespell v1.16.0
2019-11-06 09:55:30 -05:00
Gerion Entrup 7d01629580 mtest: add gdb_path option
When using the '--gdb' argument of meson test the executed binary can
now be specified with '--gdb-path'.

Closing: #4373
2019-10-04 01:10:07 +03:00
Dylan Baker d6c4e79c84 mtest: Don't require an exe wrapper for if the cross file says we don't need one
Fixes #5970
2019-09-28 18:11:06 +03:00
Marc-André Lureau 6a12f3fc16 mtest: TAP: ignore empty lines
According to http://testanything.org/tap-specification.html

"Any output line that is not a version, a plan, a test line, a
diagnostic or a bail out is considered an “unknown” line. 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 [...] TAP::Harness
reports TAP syntax errors at the end of a test run".

(glib gtest can generate empty lines)
2019-09-23 13:28:11 -04:00
Aleksey Gurtovoy 75daed27bc mesonlib.split_args/quote_arg/join_args 2019-09-05 23:42:47 +03:00
Thibault Saunier 42c5e4fe2b wine: Try to get the short paths when generating WINEPATH
The size of WINEPATH is limited (1024 [until recently]), we
can very easily reach that limit, and even the new one (2048) so
try to keep path as small as possible by using the shortPath
version of paths.

Also assert that we do not reach the new hard limit.

And avoid having duplicates in the list of path.

[until recently]: https://bugs.winehq.org/show_bug.cgi?id=45810
2019-08-24 06:43:47 -04:00
Michael Hirsch, Ph.D 148a3a83a6 DOC: meson test multiple --suite specifications [skip ci]
docs:wrap < 80 col
2019-07-30 19:08:48 +03:00
Michael Hirsch, Ph.D c904d3eefe remove vestigial $ from test error msg
Also:

* cleanup os.path use to pathlib.Path in associated code
* cleanup subprocess.Popen to subprocess.run
2019-07-27 13:06:41 +00:00
Christoph Weiss 185238fdb4 Change meson test's build failure exit code to 125 2019-07-12 21:51:17 +03:00
Jussi Pakkanen b2cdf528b8 Made TestHarness a context manager to ensure files get closed. 2019-06-21 19:59:09 +03:00
Dylan Baker c571b0b185 mtest: annotate and fix bugs found by annotating
This started out with a bug report of mtest trying to add bytes + str,
which I though "Oh, mypy can help!" and turned into an entire day of
awful code traversal and trying to figure out why attributes were
changing type. Hopefully this makes everything cleaner and easier to
follow.
2019-05-15 09:58:53 -07:00
Dylan Baker df44c86b2f mtest: precompile regular expressions
This should make the matching a little bit faster, and is nicer to look
at.
2019-05-14 11:41:41 -07:00
Dylan Baker 5dca885c5c mtest: reorder imports
I wanted to look at the imports for annotations but was having hard time
reading them because they're just all over the place. This is purely a
human readability issue.
2019-05-14 11:10:18 -07: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
Jussi Pakkanen dc2044c56d Report xpass results as failures. 2019-04-21 03:01:04 +03:00
Paolo Bonzini a2c3ba474a mtest: fix TAP with --verbose (#5160)
* mtest: fix TAP with --verbose

TAP needs to process the test stdout even if --verbose is passed.
Capture it to a separate temporary file, and print it at the end
of the test if --verbose was passed.

In the future, we could parse it on the fly and print the result of
each TAP test point in verbose mode.

* Prefer "stderr is stdout" to "=="

The previous commit used "==" in accordance with the preexisting code,
but reviewers preferred using "is" instead. Fix both occurrences.
2019-04-07 02:42:44 +03:00
Paolo Bonzini 1e7ce3553b do not use Executor if only one process was requested
This will make verbose output nicer, since it will not interleave the test
stdout/stderr and the test results.
2019-03-27 14:04:02 +00:00
Jussi Pakkanen ee863d33c1
Merge pull request #2601 from 1ace/feature/completion
Add completion scripts for Bash and Zsh
2019-03-04 18:40:13 +02:00
Paolo Bonzini 91f847d308 mtest: implement TAP parsing
This provides an initial support for parsing TAP output.  It detects failures
and skipped tests without relying on exit code, as well as early termination
of the test due to an error or a crash.

For now, subtests are not recorded in the TestRun object.  However, because the
TAP output goes on stdout, it is printed by --print-errorlogs when a test does
not behave as expected.  Handling subtests as TestRuns, and serializing them
to JSON, can be added later.

The parser was written specifically for Meson, and comes with its own
test suite.

Fixes #2923.
2019-03-02 09:07:54 +01:00
Paolo Bonzini f2e513791e mtest: add support for hard errors
Hard errors also come from the GNU Automake test protocol.  They happen when
e.g., the set-up of a test case scenario fails, or when some
other unexpected or highly undesirable condition is encountered.

TAP will use them for parse errors too.  Add them to the exitcode protocol
first.
2019-03-02 09:07:54 +01:00
Paolo Bonzini d830945224 mtest: do not use return code to look for failed tests
--print-errorlogs is using the test's return code to look for failed
tests, instead of just looking at the TestResult.  Simplify the code and
make it work for TAP too.
2019-03-02 09:07:54 +01:00
Paolo Bonzini 1264f03637 mtest: refactor TestRun creation
Parse the error code outside SingleTestRunner's run() method.  This
will let us add TAP support without complicating that long method
further.
2019-03-02 09:07:54 +01:00
Eric Engestrom 182eb2ba3a mtest: make `meson test --list` return whether there was any test to list 2019-02-20 18:48:39 +00:00
Yeongjin Jeong a75bda7154 mtest: Don't use thread executor when enabled gdb in test_setup
If the global gdb option of mesontest is disabled (e.g. not set '--gdb')
and the gdb option of test_setup is enabled, an exception will be thrown.

Because signal.signal function can only be called from the main thread.
If attempting to call it from other threads will cause a ValueError exception to be raised.
2019-02-09 00:32:01 +02:00
Olivier Crête 7993747e13 Save surrogates as-is in log files
When python sees an invalid character in a filename for the current locale,
instead of clobbering it, it saves is as an invalid codepoint called a
surrogate.  We need to explicitly instruct the encoder to write those out
as-is. In the JSON file, we replace them instead to produce valid json.
2019-01-06 19:55:55 -05:00
Jussi Pakkanen c6e022b560 Print ASCII version of unrepresentable text. Closes #4600. 2018-12-07 23:12:44 +02:00
Jon Turney 4c4e3c8600 Fix flake8 whitespace reports
$ flake8
./mesonbuild/mtest.py:524:9: E122 continuation line missing indentation or outdented

per PEP8, this line requires more indentation to distinguish it from the
following line
2018-11-19 21:07:37 +02:00
Stian Selnes 0821462ce3 Add kwarg is_default to add_test_setup()
is_default may be used to set the name of the test setup that will be
used by default whenever the option --setup is not given.

Fixes #4430
2018-11-12 16:23:59 +05:30