aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mtest.py
AgeCommit message (Collapse)AuthorFilesLines
2023-03-29Make --vsenv a readonly builtin optionXavier Claessens1-1/+2
We need to remember its value when reconfiguring, but the Build object is not reused, only coredata is. This also makes CLI more consistent by allowing `-Dvsenv=true` syntax. Fixes: #11309
2023-03-20backends: add a new "none" backendEli Schwartz1-2/+6
It can only be used for projects that don't have any rules at all, i.e. they are purely using Meson to: - configure files - run (script?) tests - install files that exist by the end of the setup stage This can be useful e.g. for Meson itself, a pure python project.
2023-03-20mtest: move the detection of rebuild compatibility out into the entry pointEli Schwartz1-6/+6
What we are mainly doing here is checking that the options make sense, or fixing that up if they don't. And in the next commit we will want to do that by also checking the build object.
2023-02-08mtest: fix annotaion of stdo_task and stde_taskDylan Baker1-2/+2
Which are `Task`s, not `Future`s, and they return `None`, not `str`. Spotted by newer versions of mypy
2023-02-01pylint 2.16: remove pointless parens around equality assignmentsEli Schwartz1-1/+1
Given the construct `foo = (bar == baz)` some people like parentheses and some do not. They're pointless and don't mean anything, though. I don't feel this is particularly helpful to code clarity, tbh, and pylint now notices this and warns about it in our current pylint config. I think this is reasonable, so let's remove the odd parens.
2023-02-01micro-optimize: define typing-only objects in TYPE_CHECKINGEli Schwartz1-7/+9
Union types that exist solely for use as annotations don't need to be created in normal runs.
2023-02-01treewide: add future annotations importEli Schwartz1-0/+1
2023-01-22mtest: do not warn when the TAP stream version is 12Eli Schwartz1-4/+1
Partial rollback of commit b7a5c384a1f1ba80c09904e7ef4f5160bdae3345. The rationale was based on a confusing wording of the TAP14 spec, which is under discussion for clarification / amendment. TAP14 doesn't (shouldn't) really say that missing a version line is potentially an error. Rather, this is the correct way to denote TAP12, which a TAP14 harness may not understand or try to parse. The intention was never to suggest that harnesses "should" take exception to the missing version line on the grounds that one should really add a version line. So, stop emitting an annoying warning for something that's valid usage. Meson understands TAP12 and that's okay. However, we do need to keep the part of that commit which set the version to 12 if it was otherwise unspecified. But instead of distinguishing between None and a version, just default to 12.
2023-01-04mtest: simplify deprecated access to current loopEli Schwartz1-9/+11
These functions constantly want the current asyncio loop, and we run a function call each time to get it. And the function call is a deprecated one. Python 3.7 brings the more explicit get_running_loop for use when we know we're inside one, with the aim of getting rid of get_event_loop once support for python <3.7 disappears. Meson no longer supports python <3.7 either. Switch to the new API, and save the reference for reuse instead of constantly re-calculating it.
2023-01-04mtest: clean up asyncio event loop instantiationEli Schwartz1-7/+6
Fix a TODO comment about moving to asyncio.run, now that we use sufficiently new python to do it. Note that we create an event loop for Windows using the new python defaults, but in a completely different part of the code from where we need to use it. Since asyncio.run creates the loop on its own, we need to set the default policy instead -- which we probably should have done all along.
2023-01-04mtest: delay creation of asyncio lock until event loop existsEli Schwartz1-1/+4
In https://bugs.python.org/issue42392 this stopped implicitly creating an event loop if none exists. We created it before running _run_tests(), so it would auto-create an event loop and set the default, which means we cannot create one explicitly on our own schedule or we end up with two of them. Delay this until we actually start the logger. This happens inside the actual testsuite loop, so it finds the running loop and doesn't create a new one, even on python <3.10.
2022-12-17mtest: handle TAP tests with unknown version.Eli Schwartz1-1/+4
TAP 14 states: > Harnesses may treat any TAP stream lacking a version as a failed test. TAP 13 states: > In the absence of any version line version 12 is assumed. It is an > error to explicitly specify any version lower than 13. So, modern TAP is saying that we should treat a missing version as a test definition bug, it's no longer okay to use a missing version as saying "let's use TAP 12". But, we can choose whether to treat it that way or error out. Let's do a diagnostic, as we do elsewhere. But allow TAP streams that aren't well defined, if they used to be well defined (back in TAP 12).
2022-12-05mtest: warn on invalid TAP outputEli Schwartz1-1/+32
In commit a7e458effadbc884eacf34528df3a57b60e43fe3 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-05mtest: early return when parsing blank lines in TAPEli Schwartz1-1/+1
Just like comment lines, blank lines do nothing. Before commit a7e458effadbc884eacf34528df3a57b60e43fe3 we ended off the parser by returning if the line was blank, because we needed to in order to catch non-blank lines as errors. But really, we should have always returned much earlier and not wasted time attempting to process anything.
2022-11-21Handle freezing tests. Fixes #10752.Jussi Pakkanen1-3/+3
2022-09-23mtest: implement a maxfail optionEli Schwartz1-0/+6
This allows early exit of the project tests once a certain number of failures are detected. For example `meson test --maxfail=1` will abort as soon as a single test fails. Currently running tests are marked as failed via INTERRUPT. Resolves #9352
2022-09-19pylint: enable use-dict-literalDylan Baker1-4/+4
2022-09-19pylint: enable use-list-literalDylan Baker1-1/+1
2022-09-04mtest: Run ninja build.ninja before loading testsAndres Freund1-0/+10
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-04mtest: pull detection of ninja into TestHarnessAndres Freund1-10/+24
A later commit will add a second invocation of ninja, no point in having the detection code twice. This changes the exit code in case ninja isn't found from 125 to 127, which seems more appropriate given the justification for returning 125 (to make git bisect run skip that commit). If we can't find ninja we'll not succeed in other commits either.
2022-09-04mtest: Move loading of test data into its own functionAndres Freund1-10/+13
A subsequent commit will do a bit more during test data loading, making a dedicated function seem advisable. The diff looks a bit odd, using git show --diff-algorithm=patience will make it clearer.
2022-08-12mesonbuild/mtest.py: filter more invalid googletest JUnit4 attributesDimitri John Ledkov1-0/+4
googletest 1.12.1 generates new JUnit4 invalid attributes file and line. Maybe all gtest "invalid" attributes are actually valid JUnit5 attributes, and maybe schema should be upgraded to JUni5. Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
2022-08-07mtest: unify parsed and non-parsed output handlingHemmo Nieminen1-25/+13
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-01Inline try_wait_one using asyncio.wait_forElliott Sales de Andrade1-8/+7
Although the former accepts multiple awaitables, it is only ever called with a single one, so just use `wait_for` instead. Additionally, the `try_wait_one` fails in Python 3.11, as `Process.wait()` returns a coroutine, and `asyncio.wait` only accepts tasks, so it errors out.
2022-06-17Improve WINEPATH reductionXavier Claessens1-1/+2
- Remove duplicated code in mdevenv.py - Change the limit to 1024 instead of 2048 which is what has been tested. - Skip shortening if it is already short enough. - Skip shortening with wine >= 6.4 which does not seems to have that limitation any more. - Downgrade exception to warning in the case WINEPATH cannot be shortened under 1024 chars, it is possible that it will still work.
2022-06-09mtest: do not process zero byte reads in read_decode()Hemmo Nieminen1-4/+5
AsyncIO.StreamReader.readuntil() occasionally raises IncompleteRead exception before a byte of data has been read. Do not process the "read" data in those cases.
2022-06-09mtest: enable access to the console logger instanceHemmo Nieminen1-3/+7
Store a reference to the console logger instance in a test harness' member variable to allow accessing it (and its logging utilities) from any other functions in test harness. This added functionality will be used in future commits.
2022-06-09mtest: store all test results directly to TestRunHemmo Nieminen1-60/+57
Store return code, test result and additional error directly to the relevant TestRun instance. This reduces the number of individual arguments to other relevant functions that need to be passed around and thus simplifies the code. The test output (and error) were earlier similarly moved to be stored directly to the TestRun instance for the same reason.
2022-06-09mtest: store test output directly to a TestRun objectHemmo Nieminen1-33/+48
By storing test output directly to the TestRun instance we avoid the need to pass the outputs around in individual function arguments thus simplifying the code. The amount of individual arguments will be further reduced in a future commit.
2022-06-09mtest: print only one empty line before test summaryHemmo Nieminen1-1/+0
2022-06-09mtest: improve text test log formattingHemmo Nieminen1-13/+17
Write additional metadata such as exit details and try to visually differentiate the tests better from each other in the (textual) test logs.
2022-06-09mtest: differentiate stdout and stderr in test log text filesHemmo Nieminen1-2/+7
Make --no-stdsplit option affect test log text files as well. This means that if the option --no-stdsplit is used only "output" is seen not only on the console but in the test log text file as well.
2022-06-09mtest: print "live" test output when verbose with only 1 testHemmo Nieminen1-0/+2
Since running only one test sort of implies --num-processes=1 the "live" output of the test should be printed out when --verbose option has been given and running only a single test.
2022-06-09mtest: remove unused arguments from read_decode_lines()Hemmo Nieminen1-7/+5
The only time the argument would matter (console_mode == ConsoleUser.STDOUT) never happens as the only time the function is ever called is when parsing of the output is needed which in turns implies that console_mode != ConsoleUser.STDOUT.
2022-06-09mtest: introduce get_test_num_prefix() helper functionHemmo Nieminen1-5/+6
2022-06-09mtest: split TestRun's get_details() to multiple functionsHemmo Nieminen1-5/+11
These new functions will be used individually in later commits.
2022-06-09mtest: make ConsoleLogger's detail property a functionHemmo Nieminen1-8/+7
As fetching the returned data is non-trivial (we e.g. iterate over all subtest results) it is best not to hide that fact from the caller of the property / function.
2022-06-09mtest: show "timed out" messages with --print-errorlogs optionHemmo Nieminen1-1/+2
2022-06-09mtest: fix a couple of minor whitespace / typing issuesHemmo Nieminen1-5/+9
2022-05-24mtest: ignore invalid inputPaolo Bonzini1-5/+0
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-17mtest: stop disrespecting the gdb config fileEli Schwartz1-1/+1
This was added in commit 01be50fdd90851f17de5499537f10b5b62c9fb49 with zero explanation as a side effect of moving code around. It seems like a really bad idea and it causes people to view debugging Meson projects on e.g. debuginfod systems as "painful".
2022-03-14mtest: fix logic bug that broke tests where the cmd is a Windows found programEli Schwartz1-3/+3
In this case, the test fname might have an implicit extension and cannot be found by `os.path.isfile()`. We cannot use `shutil.which()` to handle platform differences, because not all test fnames are executable -- for example Java jars. The test representation does have an "is built" attribute which in theory should work here, because all built targets definitely have their full filename known to Meson, but it turns out to be misnamed. Rename it correctly and add an actual "is built" attribute to check. Tests which aren't built by Meson can be assumed to exist without consulting their existence on the filesystem. Fixes #10027
2022-02-27Merge pull request #10004 from bonzini/mtest-tap-stderrJussi Pakkanen1-8/+9
mtest: print stderr of TAP/Rust tests in verbose/non-parallel mode
2022-02-20mtest: refactor common condition into a property of TestRunPaolo Bonzini1-6/+8
For a test to be displayed to stdout without buffering, it has to be 1) in verbose mode 2) not executed in parallel with others 3) not parsed, i.e. not TAP or Rust. Include these three conditions in a new property of stdout and use it in the three places where it matters: when printing the initial and final delimiters of the output, and when deciding the console mode to use. Suggested-by: Jussi Pakkanen <jpakkane@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-02-20mtest: raise informative error message when test program doesn't existEli Schwartz1-2/+5
If --no-rebuild is used, the test program might not exist, spawning a FileNotFoundError inside a long traceback rooted in subprocess.Popen trying to run that test program. Current versions of Meson even say it's an "unhandled python exception". But we can do one better and actually tell the user what is wrong, why, and what to do to fix it. And we can do so before getting waist deep in partially running tests. Fixes #10006
2022-02-20mtest: print stderr of TAP/Rust tests in verbose/non-parallel modePaolo Bonzini1-3/+2
Verbose, non-parallel tests generally print their output as they run, rather than after they finish. This however is not the case if stdout of the test is parsed as is the case for TAP and Rust tests. In this case, the output during the run is the list of the subtests, but stderr still has to be printed after the test finishes.
2022-02-01mtest: support for forcibly verbose logging of some testsPaolo Bonzini1-12/+14
Store in TestSerialisation whether a particular test must always be logged verbosely. This is particularly useful for long-running tests or when a single Meson test() is wrapping an external test harness. In this case, TAP can be used by the external harness and Meson will log each subtest as it runs. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-12-11Activate VS env when running `meson test`William Toohey1-1/+4
2021-12-05rename exe_runner to exe_wrapper everywhereEli Schwartz1-6/+6
I don't understand the purpose of this confusing API naming split.
2021-11-16mtest: add an ASCII-only version of the spinnerPaolo Bonzini1-4/+7
While the horizontal line and the other pictograms in mtest have an ASCII-only version, the spinner does not. This causes mtest to fail with a UnicodeEncodeError exception on non-Unicode locales. Fixes: #9538 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>