Commit Graph

59 Commits

Author SHA1 Message Date
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
Dave Reisner 96f8842b79 Report expected failures and unexpected passes separately
This makes it clear in the results that tests marked "should_fail"
exist. We also avoid the all caps output and make the classifications
unambigous compared to pytest or autotools' XFAIL/XPASS.

Before:

  OK:       329
  FAIL:       1
  SKIP:       0
  TIMEOUT:    0

After:

  Ok:                 323
  Expected Fail:        1
  Fail:                 6
  Unexpected Pass:      0
  Skipped:              0
  Timeout:              0
2018-11-08 20:43:42 +02:00
Dylan Baker e921e38301 mtest: Check that stdout is not None before seeking
As can be the case if additional_error is None and verbose is used.

Fixes #4470
2018-11-07 10:27:58 +02:00
Marcel Hollerbach 253c581412 test: do not use PIPE
as instructed in the python docs, you should not use PIPE here. This can
lead to deadlocks, with massive testsuite output. Which was the case for efl.
For now the output of the tests is redirected into the a temp file, the
content from there can then be used to fill the TestRun structure.

This fixes test running problems in efl.
2018-11-04 18:46:50 +02:00
Xavier Claessens 37067a53c4 Use a single ArgumentParser for all subcommands
This has the adventage that "meson --help" shows a list of all commands,
making them discoverable. This also reduce the manual parsing of
arguments to the strict minimum needed for backward compatibility.
2018-10-04 09:40:21 -04:00
Jussi Pakkanen 8ca463f9f1 Guard against the process redirecting stdout. Closes #3967. 2018-09-06 19:19:32 +03:00
Jussi Pakkanen 7e75451867 Try to kill processes even more thoroughly. Closes #4127. 2018-09-06 19:19:32 +03:00
Nirbheek Chauhan fc90c4a331 Print only custom env vars in the test log for each test
We still print the inherited env at the top of the test log because it
is useful when inspecting test results from a CI.

Fixes https://github.com/mesonbuild/meson/issues/3924
2018-08-11 09:15:05 -07:00
Nirbheek Chauhan e8dae2b966 cross: Be more permissive about not-found exe_wrapper
We used to immediately try to use whatever exe_wrapper was defined in
the cross file, but some people generate the cross file once and use
it for several projects, most of which do not even need an exe wrapper
to build.

Now we're a bit more resilient. We quietly fall back to using
non-exe-wrapper paths for compiler checks and skip the sanity check.
However, if some code needs the exe wrapper, f.ex., if you run a built
executable using custom_target() or run_target(), we will error out
during setup.

Tests will, of course, continue to error out when you run them if the
exe wrapper was not found. We don't want people's tests to silently
"pass" (aka skip) because of a bad CI setup.

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

This commit also adds a test for the behaviour of exe_wrapper in these
cases, and refactors the unit tests a bit for it.
2018-07-09 05:39:40 +05:30
Nirbheek Chauhan 416a00308f cross: Use ExternalProgram for cross-file exe_wrapper
We already have code to fetch and find binaries specified in a cross
file, so use the same code for exe_wrapper. This allows us to handle
the same corner-cases that were fixed for other cross binaries.
2018-07-09 04:09:46 +05:30
Kurtis Rader 5290f41f31 Report exit status or signal that killed the test
When a test fails due to a signal (e.g., SIGSEGV) it can be somewhat
mysterious why the test failed. Also, even when a test fails due to a
non-zero exit status it would help if the exit status was reported. This
augments the result string to include the non-zero exit status or
signal number and name.

Resolves #3642
2018-06-17 21:22:42 +03:00
Nirbheek Chauhan efa9b75d5d Set WINEPATH when running serialized executables
When the exe runner is `wine` or `wine32` or `wine64`, etc.
This allows people to run tests with wine.

Note that you also have to set WINEPATH to point to your custom
prefix(es) if your tests use external dependencies.

Closes https://github.com/mesonbuild/meson/issues/3620
2018-06-05 10:50:22 +00:00
George Koehler 64906b0755 Don't call getpgid() when killing a test.
OpenBSD's getpgid(2) fails with EPERM (PermissionError) because the
test is in a different session: https://man.openbsd.org/getpgid

Use p.pid as the process group ID, because setsid() created a process
group with the same ID as the process.  See setsid(2) manuals:

 - FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=setsid
 - illumos: https://illumos.org/man/setsid
 - Linux: http://man7.org/linux/man-pages/man2/setsid.2.html

This change fixes 'manual tests/8 timeout' on OpenBSD.  To verify this
change, one must run the manual test.  For example,

    $ cd 'manual tests/8 timeout'
    $ meson build
    $ ninja -C build test

It should report that the test timed out, and not show
PermissionError.

Fixes https://github.com/mesonbuild/meson/issues/3569
2018-05-29 02:14:52 +02:00
Alberto Sartori 717f7db67e improve suite of meson test (#3369) 2018-04-14 22:17:02 +03:00
Jussi Pakkanen be3387d937
Merge pull request #3322 from sarum9in/run_timeout 2018-03-29 21:48:09 +03:00
Aleksey Filippov ddc6f72507 Use consistent quotes 2018-03-28 21:31:04 +00:00
Aleksey Filippov 827d33c8b6 Split SingleTestRunner.run() 2018-03-28 18:57:50 +00:00
Aleksey Filippov 0e8c69b796 Split SingleTestRunner._get_cmd() out of run() 2018-03-28 18:34:02 +00:00
Aleksey Filippov 9596fd6c24 Move run_single_test() into separate class 2018-03-28 18:34:02 +00:00
Aleksey Filippov 3eebb1f83a Make run_single_test() method static
Closes #3318
2018-03-28 18:34:02 +00:00
Aleksey Filippov 9c01fc0e49 Do not access counters from parallel code 2018-03-28 18:34:02 +00:00
Aleksey Filippov 2aa1c3d575 Use enum instead of string constants 2018-03-28 18:33:50 +00:00
Aleksey Filippov 84e3cadc70 Use hermetic parameters in run_single_test(), initialize them before in the caller 2018-03-28 16:44:49 +00:00
Jussi Pakkanen 9b2e533d87 Always build parser objects anew to avoid leaking old data. 2018-03-27 00:39:45 +03:00
nyorain dd614015e0 Open mesontest logfiles in utf-8 mode
Otherwise unit tests fail on windows when they output some
non-utf8 data.
2018-03-20 22:28:59 +02:00
Alicia Boya García 70270d874d meson test: let gdb handle ^C instead of us
Fixes https://github.com/mesonbuild/meson/issues/3156
2018-03-05 00:04:28 +02:00
Hemmo Nieminen 275c737d57 Fix test setup's timeout_multiplier handling. 2018-03-03 21:23:33 +02:00
Hemmo Nieminen e0d0c0166a Avoid unnecessary unpickling of build data during testing. 2018-03-01 01:06:51 +02:00
Hemmo Nieminen 7fb8e518b2 Harmonize data pickling.
Try to be more consistent on using save() and load() methods to pickle
data.
2018-03-01 01:06:51 +02:00
Hemmo Nieminen 060560bf62 Use test setups from the active (sub)project by default.
Replace the logic where a test setup with no project specifier defaults to
the main project with one that takes the test setup from the same
(sub)project from where the to-be-executed test has been read from.
2018-02-25 21:44:59 +02:00
Hemmo Nieminen abcaf7c222 Namespace test setups.
Use $project_name:$test_setup namespace scheme for test setups. This
allows one to choose from which (sub)project a test setup is taken from
should there be several sharing the same name. Defaults to the main
project. E.g. "meson test --setup subproj:valgrind".
2018-02-25 21:44:59 +02:00
Alex Hirsch 3e8eab66a1 Do not set MALLOC_PERTURB_ for benchmarks
Setting MALLOC_PERTURB_ to a non-zero value is fine for regular test
cases. It helps catching bugs, but also comes with some runtime
overhead.

This overhead is noticeable for benchmarks when compared to running them
directly instead of through Meason.

Therefore, MALLOC_PERTURB_ is not touched for benchmarks.

closes #3034
2018-02-12 21:39:28 +02:00
Robert Doolittle 9b27f07002 don't use bare except 2018-01-30 10:17:45 -08:00