Commit Graph

85 Commits

Author SHA1 Message Date
Eli Schwartz a009eacc65
treewide: string-quote the first argument to T.cast
Using future annotations, type annotations become strings at runtime and
don't impact performance. This is not possible to do with T.cast though,
because it is a function argument instead of an annotation.

Quote the type argument everywhere in order to have the same effect as
future annotations. This also allows linters to better detect in some
cases that a given import is typing-only.
2022-03-07 19:01:04 -05:00
Eli Schwartz 812ad2e6d1
fix type annotations for mlog nesting
In commit 8cd4d0b283 we added a feature
that took True/False but said it took str.
2021-12-30 15:15:25 -05:00
Eli Schwartz f4b91c4306 Revert "mark a couple of typing-only imports as noqa, to appease pyflakes"
This reverts commit 6cc1b8441c.

The latest version of pyflakes learned to detect that correctly.
2021-10-27 09:51:52 -04:00
Eli Schwartz 8947352889 fix various flake8 whitespace errors 2021-10-27 09:51:52 -04:00
Eli Schwartz b1f0eec38f
fix lgtm.com "Use of the return value of a procedure"
we return _log even though this entire family of functions returns None,
because a side effect of returning is that the other version of the
function is not run.

We can do that more obviously, using an else clause that doesn't attach
meaning to return values.
2021-10-26 20:53:43 -04:00
Paolo Bonzini 65b144bc85 Revert "mtest: fix test output issues (in console)"
This reverts commit 5fcb0e6525.
The commit is a massive change that should have been split in
separate pieces, and it also removes a few features:

* in verbose mode, subtests are not printed as they happen

* in non-verbose mode the progress report does not include the
number of subtests that have been run

* in non-parallel mode, output is batched rather than printed as
it happens

Furthermore, none of these changes are not documented in the release
notes.  Revert so that each proposal can be tested, evaluated and
documented individually.
2021-09-29 21:47:31 +03:00
Hemmo Nieminen 5fcb0e6525 mtest: fix test output issues (in console)
This change set aims to fix various "issues" seen with the current
implementation. The changes can be summarized with the following list:

* Replace emojis and spinners with multiline status displaying the name
  and running time of each currently running test.
* The test output (especially in verbose mode or when multiple failing
  tests' output gets printed out) can get confusing. Try to make the
  output easier to read and grasp. Most notable change here is the
  addition of the test number to the beginning of each printed line.
* Print exit details (i.e. exit code) of the test in verbose mode.
* Try to make the verbose "live" output from tests to match the look and
  feel of otherwise produced (verbose) test output.
2021-09-25 13:42:45 +03:00
Dylan Baker 9bca4a4b94 mlog: fix annotation 2021-09-24 09:44:40 -07:00
Eli Schwartz 6cc1b8441c
mark a couple of typing-only imports as noqa, to appease pyflakes
Since it cannot resolve `import typing as T` in order to figure out that
T.* is doing annotation-worthy stuff.

Since T.cast('Foo') is not actually using Foo except in an annotation
context (due to being a string) it requires extra work to resolve, and
the only thing that would currently work is actually using
'typing.cast'. However, we have decided to not use it except as T...

Since this import is only imported during mypy it's not so bad to noqa
it.
2021-09-14 15:55:03 -04:00
Paolo Bonzini 516c871bec summary: fix dependencies
Dependencies are currently printed as

   [<mesonbuild.mlog.AnsiDecorator object at 0x7faa85aeac70>, ' ', <mesonbuild.mlog.AnsiDecorator object at 0x7faa85aeab50>]

This was introduced in commit adb1b2f3f6, due to
an incorrect type annotation on the AnsiText constructor.  Fix both the
annotation and the usage.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-09-07 14:18:58 -04:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Daniel Mensinger 27bb5f536a typing: mlog use StringProtocol 2021-06-05 12:35:48 +02:00
Daniel Mensinger f502a38d1c typing: mlog: Simplify some typing with a TV_ variables 2021-06-03 10:23:27 -07:00
Xavier Claessens 8cd4d0b283 mlog: Do not print 'subproject|' for the message 'Executing subproject'
It already contains the full callstack and it's more visible when it's
standing on its own line.
2021-03-22 21:29:14 -04:00
Xavier Claessens 60c2c25d5b mlog: Do not print 'subproject|' on empty lines 2021-03-22 21:29:14 -04:00
Xavier Claessens b33e7bca73 mlog: Add a space after 'subproject|' 2021-03-22 21:29:14 -04:00
Xavier Claessens 3c1ccb923f logs: Prepend current subproject name to all messages
Meson used to prepend '|' for each nested subproject to distinguish in
the logs where a subproject start and ends. It is more useful to print
the current subproject name.

Also print the call stack when starting a new subproject to better see
which subproject chain leads to to.
2021-03-22 21:29:14 -04: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
Paolo Bonzini adb1b2f3f6 interpreter: accept external programs and dependencies for summary 2021-01-21 08:54:35 -05:00
Paolo Bonzini 021068a8b7 mlog: add __len__ to AnsiDecorator 2021-01-21 08:54:35 -05: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 a9ff308d27 mlog: make mlog helper take once keyword argument
We really want to have this in the log method as well.

Fixes: #8002
2020-12-16 21:15:09 +00: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
Paolo Bonzini f1ce78d77f mtest: cleanup and fix print_stats
Avoid calling self.collected_failures.append twice, and avoid
inflated indentation by adding a "plain" decorator to mlog.

Fixes: ba71fde18 ("mtest: collect failures regardless of colorized console", 2020-10-12)
2020-11-18 22:49:41 +02:00
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Daniel Mensinger ce042f318e
typing: Add run_mypy.py for easier mypy invocation 2020-09-08 20:15:56 +02:00
Nirbheek Chauhan 4ad4565ddd Add a notice about Python 3.5 support
This will be printed in bold at the end of interactive meson
sub-commands that won't be parsed by a program. Specifically: setup,
compile, test, and install.

NOTICE: You are using [...]
2020-09-02 10:37:40 +00:00
Nirbheek Chauhan 40319c9634 Don't make unactionable warnings fatal
Some warnings are out of the user's control, such as the RCC QT bug,
or the GNU windres bug, or our informational warning about
auto-disabling of options when -Db_bitcode is enabled.

Such warnings should not be fatal when --fatal-meson-warnings is
passed because there's no action that the user can take to fix it. The
only purpose it serves is to prevent people who use those features
from using --fatal-meson-warnings.
2020-07-05 16:13:00 +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
Michael c53b637959 switch python2 %s for python3 .format 2020-04-21 00:16:21 +03:00
Jussi Pakkanen 9e5c881b06 Add property to disable compiler sanity checks during cross compilation. 2020-03-22 23:07:53 +02:00
Dylan Baker 1bb66d1568 fix conversion of hasattr to getattr
getattr() requires a default (return if missing) value or it raises an
AttributeError. In a few cases I changed hasattr to getattr and didn't
set a default value, so those cases could except. This corrects that.
2020-03-15 22:30:19 +02:00
Dylan Baker 1a82880730 mesonbuild/mesonlib: Add type annotations 2020-03-05 09:31:29 -08:00
Jussi Pakkanen 200738a3e6
Merge pull request #6692 from xclaesse/summary-warnings
Summary improvements
2020-03-01 19:30:10 +02:00
Jussi Pakkanen 25cbcb19a9
Merge pull request #6627 from jon-turney/cwd-relative-file-locations
Consistently report file locations relative to cwd
2020-03-01 18:17:41 +02:00
Dylan Baker 74452f2a1c mlog: fix remaining mypy errors and add to mypy check
There were two things mypy was warning about:
1) it doesn't understand hasattr()
2) It was possible for mlog.{error,warning,deprecation} to get passed
   multiple values for the once keyword argument.
2020-02-29 00:55:46 +02:00
Jon Turney c8f8d58273
Rename 'subdir' -> 'filename' in location objects 2020-02-28 11:54:08 +00:00
Jon Turney c3163040ae
Display filename cwd relative in warning location
Format the filename relative to cwd in a warning location.
2020-02-28 11:54:05 +00:00
Jon Turney 346b5c4be7
Store filename in node location
Warnings have a location node object (with subdir and lineno
attributes), which is passed as a location: kwarg to mlog.warning() and
formatted in _log_error().

Re-purpose the subdir attribute (path relative to the source root dir,
with an implied filename of 'meson.build'), which is stored into the
node by parser(), to contain a pathname.

(Properly I should rename 'subdir' -> 'file' everywhere, but that's a
lot of churn just to see if this works)

Notes:
The warning location node may also have a colno attribute, which is
currently ignored by _log_error().

We can't currently issue warnings with locations in meson_options.txt
because the filename isn't part of the location (as it's assumed to be
'meson.build).
2020-02-28 11:54:04 +00:00
Jon Turney 4895830c28
Fix typos in comments about type annotations 2020-02-28 11:54:03 +00:00
Jon Turney fa928e803b
Remove unused MesonException.get_msg_with_context()
After that, the only remaining user of get_error_location_string() is mlog,
so move that there.
2020-02-28 11:54:03 +00:00
Xavier Claessens 8101b0ddab summary: Add more info in Subprojects section
This adds a warnings counter for subprojects that passed. This is to
encourage developpers to check warnings in the logs and hopefully fix
them. Otherwise they could be hidden in hundreds lines of logs.

This also print the error message for subprojects that did not pass. The
error message is often enough to fix the issue (e.g. missing
dependency) and it's easier than searching in the logs why a subproject
failed.
2020-02-26 14:24:12 -05:00
Nirbheek Chauhan c05b725122 Split console colourization into a separate function
Use it instead of making a direct call to mlog._windows_ansi().
2020-02-16 00:26:08 +05:30
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Dylan Baker 614372aa55 mlog: Add a log_once function
There are a number of cases where we end up spamming users with the same
message over and over again, which is really annoying. This solves that.
2019-12-13 09:57:05 -05:00
Dylan Baker eb30c493f6 mlog: remove incorrect uses of global keyword
global is only needed to allow replacement of global values, they're
always in scope to read.
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 9435f11b17
ci: Add CI command to include text files in the CI log 2019-11-19 15:21:13 +01:00
Daniel Mensinger e39d570d3a
mlog: add non bold version of colors 2019-11-14 17:05:18 +01:00