Граф коммитов

162 Коммитов

Автор SHA1 Сообщение Дата
Mitchell Hentges 14386d0c7e Bug 1717104: Activate virtualenv before running command r=perftest-reviewers,ahal,AlexandruIonescu
All commands declaring a virtualenv will have them activated before the
command executes. Removes all now-redundant manual activations of
declared virtualenvs.

Commands that don't declare a virtualenv will still implicitly be
associated with the "common" virtualenv, but unlike explicit
virtualenv declarations it'll have to be activated manually, just
like it was before this patch.

To smooth the migration with existing usages, virtualenv activation
behaviour was changed slightly: if attempting to activate a new
virtualenv, but the source venv is already command venv, then raise an
exception. (In the future, we should improve testability of
virtualenv scaffolding logic so that tests can be added for this
sort of thing.) This did cause some issues with some tests, which
will be solved more cleanly with bug 1724273. In the meantime,
minimal modifications were made to failing tests to keep them green:
* `test_command_line.py` was activating the `common` virtualenv so
  that it could install `mozproxy`, and use its CLI. Instead, I
  modified the test to use `mozproxy` using the "module" interface
  (`python -m mozproxy ...`). At that point, `MozbuildObject` was
  unnecessary and usages were replaced with simpler variants.
* `test_vendor.py` needed its explicit `activate_virtualenv()` call
  patched out. It still needs to use a virtualenv's Python
  executable, but due to `sys.executable` now being kept up-to-date
  as of bug 1717051, it could be used directly.

Differential Revision: https://phabricator.services.mozilla.com/D122892
2022-03-23 14:50:45 +00:00
ahochheiden f405f02655 Bug 1753795 - Add progress bar (via tqdm) to running Python Tests r=ahal
This will give additional feedback to the user. Now they will have
immediate feedback in regards to the progress of the test run, instead
of being unsure of what's happening until the first test run completes.

Differential Revision: https://phabricator.services.mozilla.com/D137925
2022-02-11 18:51:46 +00:00
ahochheiden ac7433fc00 Bug 1754726 - Add capturing for `stderr` when running Python Tests r=ahal
Since stdout is being piped, redirecting stderr to stdout causes it
to end up in the same pipe interleaved, which is what we want.

Also added a non-zero return code to be set when there is no test output.

Differential Revision: https://phabricator.services.mozilla.com/D138481
2022-02-11 18:04:18 +00:00
ahochheiden 85715645b0 Bug 1753555 - Replaced `ProcessHandler` in `run_python_test` with a more standard solution r=ahal
There's a bug with `ProcessHandler` on Windows that sometimes causes
tests to hang for an additional 3 minutes. This is a workaround that
just replaces `ProcessHandler` with a standard Python3 approach that
achieves the same thing.

Also added some logging output as the threads are created as some
additional feedback. Prior to this, the tests silently started
running without any indication.

Differential Revision: https://phabricator.services.mozilla.com/D137822
2022-02-08 23:46:12 +00:00
ahochheiden d4958f0b9c Bug 1750693 - Update string paths to Pathlib objects in Mozversioncontrol module r=firefox-build-system-reviewers,mhentges
Differential Revision: https://phabricator.services.mozilla.com/D136301
2022-01-31 15:26:17 +00:00
Andrew Halberstadt 64eea7ceb7 Bug 1748457 - Drop usages of six in |mach python-test|, r=mhentges
Depends on D135274

Differential Revision: https://phabricator.services.mozilla.com/D135275
2022-01-07 03:59:33 +00:00
Andrew Halberstadt 72ce29c06a Bug 1748457 - [python-test] Log output from failed tests at the end, r=mhentges
The python-test infra runs each test file in a separate process for
parallelization.  This is expedient, but it means that when a test fails, the
output is often buried 1000s of lines in scrollback and difficult to find.

In the future, we could look into using 'pytest-async' rather than rolling our
own parallelization, this way Pytest would output the failures again at the end
of the run.

But for now, it's easier to simply defer outputting failed tests until the very
end. This is done in a try/finally block so even if there was a
KeyboardInterrupt or other exception, we'll still print the failed tests.

Differential Revision: https://phabricator.services.mozilla.com/D135274
2022-01-07 03:59:32 +00:00
Mitchell Hentges 144daeecaf Bug 1731836: Simplify `./mach python` arguments r=ahal
`--no-virtualenv` was needed for one use case: the
`get_and_diffoscope` task, despite not needing `psutil`, would
run into failures during virtualenv-creation because we used to
unconditionally build the `psutil` package, and `get_and_diffoscope`
didn't have the environment needed for such a build.

Since we no longer build and install `psutil` into every virtualenv,
it's no longer needed for its one usage, which means that it can be
removed.

`--requirements` is replaced by `--virtualenv`, which removes an
ad-hoc pip package installation and embraces the centralized dep
system.

`--no-activate` is now implied by default: a virtualenv is only
created and activated if `--virtualenv` is provided.`

`ipython==7.16.1` was the chosen version because it is the last
one compatible with Python 3.6.

Differential Revision: https://phabricator.services.mozilla.com/D131529
2021-11-24 20:06:33 +00:00
Mitchell Hentges 8f554a6da0 Bug 1730712: Ensure virtualenv up-to-date before activation r=ahal
Rather than requiring that consumers remember to `ensure()` before
calling `activate()`, we can do so automatically during activation.
There isn't a valid use case in which we want obsolete virtualenvs to be
activateable.

Usages of `MozSiteManager` have been updated accordingly.

Differential Revision: https://phabricator.services.mozilla.com/D129688
2021-11-17 20:54:25 +00:00
Mitchell Hentges b7b1442242 Bug 1730712: Remove external use of `_run_pip()` r=perftest-reviewers,ahal,sparky
As `_run_pip()` is being removed from `VirtualenvManager` in an upcoming
patch, its usages need to be removed. Besides, they're using an
"internal" function, which is a bit of a smell.

Note that this _could_ have been solved by exposing a public `run_pip()`
function. However, I felt like that was worse because:
* Friction here is good as we try to migrate the codebase to embrace the
  "requirements definition file" technique to install dependencies.
* There could be confusion about the relationship between
  `install_pip_package()` (only works if venv already activated)
  and `_run_pip()`, which works "in general".

Differential Revision: https://phabricator.services.mozilla.com/D130120
2021-11-16 21:14:41 +00:00
Mitchell Hentges fc4d4c2f41 Bug 1730712: Python tests should use Python 3 automatically r=ahal
The virtualenv python is always Python 3, so inline the `version_info()`
function.

Differential Revision: https://phabricator.services.mozilla.com/D129324
2021-11-16 21:14:40 +00:00
Mitchell Hentges 67be954a8c Bug 1739177: Add `requirements.pths_as_absolute()` r=ahal
There were a bunch of locations where we were doing path shenanigans
with `requirements.pth/.vendored` items.

There was a bit of complexity because we were specifically making each
`pthfile` line be a relative path to support moving the Firefox
topsrcdir without causing issues.

However, now that we're more intelligent about checking if `pthfile`
lines are up-to-date (and since moving your topsrcdir will still require
re-generating the Mach virtualenv), this behaviour became less useful.

So, generalize `MachEnvRequirements` -> "sys.path lines" logic and
reuse it everywhere.

Differential Revision: https://phabricator.services.mozilla.com/D129693
2021-11-04 14:35:08 +00:00
Mitchell Hentges 9c77153d02 Bug 1723031: Allow flexible dependency-specification in the Mach venv r=ahal
There's some trade-offs in play here: the major issue is that we can't
pin `psutil`'s because it's pre-installed on some CI workers with a
different version (5.4.2).

Additionally, we can't "just" bump that version, because CI workers jump
between different revisions to do work, so a specific pinned version
won't work when we try to update such a package.

One option is that we could avoid validating package versions in CI, but
then that will cause surprises (heck, I didn't know we were still using
`psutil==5.4.2` instead of `5.8.0` until now). By doing validation, we
make it more explicit and avoid accidentally depending on behaviour of
too new of such a package.

However, in most cases, we manage the installation environment and can
pin dependencies. So, I've made the top-level Mach virtualenv the _only_
one that is able to use requirement specifiers other than "==".

Differential Revision: https://phabricator.services.mozilla.com/D122889
2021-09-28 14:59:29 +00:00
Mitchell Hentges ff01350ad5 Bug 1712151: Add test to verify virtualenv compatibility r=ahal
This adds two main compatibility guarantees:
1. Vendored dependencies <=> Pypi-downloaded dependencies
2. Global Mach dependencies <=> command-specific dependencies

As part of this, a new `vendored:` action was added to the virtualenv
definition format. Otherwise similar to `pth:` paths, `vendored:`
packages are assumed to be "pip install"-able.

Some validation (the `.dist-info`/`PKG-INFO` checks) was added to
`requirements.py` to verify that `pth:` and `vendored:` are correctly
used.

Differential Revision: https://phabricator.services.mozilla.com/D122900
2021-09-28 14:59:28 +00:00
Mitchell Hentges 0eb329a6f8 Bug 1717051: Reuse "requirements" logic in mach_initialize r=ahal
Rather than re-implementing it as `search_path()`, use the existing
`MachEnvRequirements` tool to parse `mach_virtualenv_requirements.txt`

Differential Revision: https://phabricator.services.mozilla.com/D126280
2021-09-28 14:59:28 +00:00
criss f2dcba95fa Backed out 10 changesets (bug 1712151, bug 1724279, bug 1730712, bug 1717051, bug 1723031, bug 1731145) for causing failures on test_yaml.py
Backed out changeset 7f64d538701b (bug 1723031)
Backed out changeset 394152994966 (bug 1723031)
Backed out changeset 9bfeb01bcc9a (bug 1723031)
Backed out changeset 3d283616a57d (bug 1730712)
Backed out changeset bc677b409650 (bug 1724279)
Backed out changeset 784c94c2f528 (bug 1723031)
Backed out changeset 6e1bde40e3b4 (bug 1723031)
Backed out changeset 7adf7e2136a3 (bug 1712151)
Backed out changeset 2aef162b9a1b (bug 1717051)
Backed out changeset 9beeb6d3d95b (bug 1731145)
2021-09-28 00:32:38 +03:00
Mitchell Hentges f3f13dfc13 Bug 1723031: Allow flexible dependency-specification in the Mach venv r=ahal
There's some trade-offs in play here: the major issue is that we can't
pin `psutil`'s because it's pre-installed on some CI workers with a
different version (5.4.2).

Additionally, we can't "just" bump that version, because CI workers jump
between different revisions to do work, so a specific pinned version
won't work when we try to update such a package.

One option is that we could avoid validating package versions in CI, but
then that will cause surprises (heck, I didn't know we were still using
`psutil==5.4.2` instead of `5.8.0` until now). By doing validation, we
make it more explicit and avoid accidentally depending on behaviour of
too new of such a package.

However, in most cases, we manage the installation environment and can
pin dependencies. So, I've made the top-level Mach virtualenv the _only_
one that is able to use requirement specifiers other than "==".

Differential Revision: https://phabricator.services.mozilla.com/D122889
2021-09-27 20:27:20 +00:00
Mitchell Hentges 74b09f92ce Bug 1712151: Add test to verify virtualenv compatibility r=ahal
This adds two main compatibility guarantees:
1. Vendored dependencies <=> Pypi-downloaded dependencies
2. Global Mach dependencies <=> command-specific dependencies

As part of this, a new `vendored:` action was added to the virtualenv
definition format. Otherwise similar to `pth:` paths, `vendored:`
packages are assumed to be "pip install"-able.

Some validation (the `.dist-info`/`PKG-INFO` checks) was added to
`requirements.py` to verify that `pth:` and `vendored:` are correctly
used.

Differential Revision: https://phabricator.services.mozilla.com/D122900
2021-09-27 20:27:19 +00:00
Mitchell Hentges b9d0572034 Bug 1717051: Reuse "requirements" logic in mach_initialize r=ahal
Rather than re-implementing it as `search_path()`, use the existing
`MachEnvRequirements` tool to parse `mach_virtualenv_requirements.txt`

Differential Revision: https://phabricator.services.mozilla.com/D126280
2021-09-27 20:27:19 +00:00
Alex Lopez 63022efc7a Bug 1696251: Allow mach commands as stand-alone functions and adapt existing commands. r=mhentges,webdriver-reviewers,perftest-reviewers,sparky,whimboo
This removes the `@CommandProvider` decorator and the need to implement
mach commands inside subclasses of `MachCommandBase`, and moves all
existing commands out from classes to module level functions.

Differential Revision: https://phabricator.services.mozilla.com/D121512
2021-09-27 18:12:51 +00:00
Butkovits Atila eb735ac57e Backed out changeset 53b1fa0faa6d (bug 1696251) for breaking the static-analysis integration. a=backout 2021-09-23 13:06:40 +03:00
Alex Lopez a8e7083c84 Bug 1696251: Allow mach commands as stand-alone functions and adapt existing commands. r=mhentges,webdriver-reviewers,perftest-reviewers,sparky,whimboo
This removes the `@CommandProvider` decorator and the need to implement
mach commands inside subclasses of `MachCommandBase`, and moves all
existing commands out from classes to module level functions.

Differential Revision: https://phabricator.services.mozilla.com/D121512
2021-09-21 20:38:16 +00:00
Butkovits Atila c06a3dd9fa Backed out changeset 510dd46a9de7 (bug 1696251) for causing Android build bustages. 2021-09-21 05:16:50 +03:00
Alex Lopez fe61e94ec8 Bug 1696251: Allow mach commands as stand-alone functions and adapt existing commands. r=mhentges,webdriver-reviewers,perftest-reviewers,sparky,whimboo
This removes the `@CommandProvider` decorator and the need to implement
mach commands inside subclasses of `MachCommandBase`, and moves all
existing commands out from classes to module level functions.

Differential Revision: https://phabricator.services.mozilla.com/D121512
2021-09-20 20:21:07 +00:00
Noemi Erli 91aa2e2b9c Backed out changeset 5f5b612878f3 (bug 1696251) for causing multiple bustages 2021-09-18 02:22:39 +03:00
Alex Lopez bf860fe7dc Bug 1696251: Allow mach commands as stand-alone functions and adapt existing commands. r=mhentges,webdriver-reviewers,perftest-reviewers,sparky,whimboo
This removes the `@CommandProvider` decorator and the need to implement
mach commands inside subclasses of `MachCommandBase`, and moves all
existing commands out from classes to module level functions.

Differential Revision: https://phabricator.services.mozilla.com/D121512
2021-09-17 19:00:39 +00:00
Mitchell Hentges f5b0cb5bc1 Bug 1717051: Rename "mach_bootstrap.py" to "mach_initialize.py" r=firefox-build-system-reviewers,glandium
We've overloaded "bootstrap" to mean three different things:
* The "standalone bootstrap script": `python/mozboot/bin/bootstrap.py`.
  This is to freshly clone a new repo, then run `./mach bootstrap`.
* `./mach bootstrap`: Install necessary dependencies and set up the
  system for development.
* "Mach bootstrap": do the in-process initialization work Mach needs
  before it can run commands.

By using the term "initialize" instead, perhaps we can remove
ambiguity when discussing Mach.

I'm not attached to the name (or this change at all), but I'm interested
in reviewer thoughts :)

Differential Revision: https://phabricator.services.mozilla.com/D120410
2021-09-03 20:46:22 +00:00
Alex Lopez 77ce415604 Bug 1696251 - Replace self with command_context where possible in existing mach commands. r=mhentges,webdriver-reviewers,perftest-reviewers,whimboo
This step removes all the dependencies of mach commands to
having a MachCommandBase as the `self` by using the `command_context`
argument instead. This also removes any remaining statefulness from those
classes that implement mach commands, ultimately making it easier to move
existing commands out of classes in a follow-up.

Differential Revision: https://phabricator.services.mozilla.com/D118058
2021-07-19 16:04:25 +00:00
Butkovits Atila a07f790e42 Backed out changeset e1921c5112d8 (bug 1696251) for causing bustages complaining about 'CommandContext'. CLOSED TREE 2021-07-16 20:35:55 +03:00
Alex Lopez 190e03aaab Bug 1696251 - Replace self with command_context where possible in existing mach commands. r=mhentges,webdriver-reviewers,perftest-reviewers,whimboo
This step removes all the dependencies of mach commands to
having a MachCommandBase as the `self` by using the `command_context`
argument instead. This also removes any remaining statefulness from those
classes that implement mach commands, ultimately making it easier to move
existing commands out of classes in a follow-up.

Differential Revision: https://phabricator.services.mozilla.com/D118058
2021-07-16 15:51:29 +00:00
Mitchell Hentges 722ac646db Bug 1713857: Don't set PYTHONEXECUTABLE environment variable r=glandium
After some testing in `try` and locally, the manual
`PYTHONEXECUTABLE` definitions shouldn't be needed
anymore.

There's been some work on Brew's
Python to improve its `sitecustomize` behaviour.
The most likely improvement is:
https://github.com/Homebrew/homebrew-core/pull/65297

However, I'm not fully confident in this change.
If it fails, it's more likely to affect developers
than CI. I think it's worth attempting a landing,
because if the variable is indeed obsolete, then
deleting it will avoid some spicy "action-at-a-
distance" behaviour.

Differential Revision: https://phabricator.services.mozilla.com/D117452
2021-06-17 13:28:29 +00:00
Mitchell Hentges 79c56399e1 Bug 1712819: Fix VirtualenvManager not being expandable in debugger r=ahal
At least in PyCharm, expanding a `VirtualenvManager` instance means
resolving all the properties and fields of the instance.
However, if that property is doing non-trivial work, the debugger
wouldn't run that subprocess while we're stopped at a breakpoint.
So, the instance would sit there with the "Collecting data..." text.

Differential Revision: https://phabricator.services.mozilla.com/D115935
2021-05-27 23:04:06 +00:00
Dorel Luca 61aa3325c5 Backed out 2 changesets (bug 1712819) for Python failures. CLOSED TREE
Backed out changeset f51d72e5f0b8 (bug 1712819)
Backed out changeset 40c109bb5f9a (bug 1712819)
2021-05-27 19:05:15 +03:00
Mitchell Hentges f8ce33772c Bug 1712819: Fix VirtualenvManager not being expandable in debugger r=ahal
At least in PyCharm, expanding a `VirtualenvManager` instance means
resolving all the properties and fields of the instance.
However, if that property is doing non-trivial work, the debugger
wouldn't run that subprocess while we're stopped at a breakpoint.
So, the instance would sit there with the "Collecting data..." text.

Differential Revision: https://phabricator.services.mozilla.com/D115935
2021-05-27 15:16:16 +00:00
Alex Lopez 455d9a088b Bug 1696251 - Pass MachCommandBase object as first argument for Mach Commands. r=mhentges,remote-protocol-reviewers,marionette-reviewers,webdriver-reviewers,perftest-reviewers
As an intermediate step to allow mach commands as standalone functions, the MachCommandBase
subclass instance that currently corresponds to self has to be made available as a separate
argument (named command_context).

Differential Revision: https://phabricator.services.mozilla.com/D109650
2021-05-17 16:15:58 +00:00
Butkovits Atila 2e34e363b9 Backed out 2 changesets (bug 1696251) for causing js-bench-sm failures. CLOSED TREE
Backed out changeset 1c84c9a34575 (bug 1696251)
Backed out changeset e169193b7423 (bug 1696251)
2021-04-23 02:53:36 +03:00
Alex Lopez d1a82b8092 Bug 1696251 - Pass MachCommandBase object as first argument for Mach Commands. r=mhentges,remote-protocol-reviewers,marionette-reviewers,webdriver-reviewers,perftest-reviewers
As an intermediate step to allow mach commands as standalone functions, the MachCommandBase
subclass instance that currently corresponds to self has to be made available as a separate
argument (named command_context).

Differential Revision: https://phabricator.services.mozilla.com/D109650
2021-04-22 18:56:15 +00:00
Cosmin Sabou 785f9b8a87 Backed out changeset d4a5d8567977 (bug 1696251) for non-unified build bustages. CLOSED TREE 2021-04-19 19:43:31 +03:00
Alex Lopez 75dfe35468 Bug 1696251 - Pass MachCommandBase object as first argument for Mach Commands. r=mhentges,remote-protocol-reviewers,marionette-reviewers,webdriver-reviewers,perftest-reviewers
As an intermediate step to allow mach commands as standalone functions, the MachCommandBase
subclass instance that currently corresponds to self has to be made available as a separate
argument (named command_context).

Differential Revision: https://phabricator.services.mozilla.com/D109650
2021-04-19 16:15:11 +00:00
Alex Lopez ad68ed0ba9 Bug 1682959 - Remove legacy_resolver support from mach. r=mhentges
Now that all the conflicts in python dependencies that made the
new pip resolver fail have been resolved, we no longer need to support
the legacy resolver that was added as a temporary measure.

Depends on D106154

Differential Revision: https://phabricator.services.mozilla.com/D106503
2021-02-25 18:37:00 +00:00
Mitchell Hentges f4a03e538f Bug 1680802: Install pylint requirements with legacy resolver r=firefox-build-system-reviewers,sheehan,glandium
pylint_requirements.txt fail to install with the new pip resolver due
to a conflict between astroid and lazy-object-proxy.
Rather than bumping those packages and handling the potential fallout,
the package-upgrade has been deferred and we will use the legacy
resolver in the interrim.

Differential Revision: https://phabricator.services.mozilla.com/D99940
2021-01-05 20:14:25 +00:00
Cosmin Sabou 8a46d2e9d6 Backed out 3 changesets (bug 1680802, bug 1680630) for turning Bug 1521378 into permafail. CLOSED TREE
Backed out changeset 3464c8f10994 (bug 1680630)
Backed out changeset 591d32364c0f (bug 1680802)
Backed out changeset 3e9350fd509d (bug 1680802)
2021-01-04 18:47:44 +02:00
Mitchell Hentges cdf668d1ae Bug 1680802: Install pylint requirements with legacy resolver r=firefox-build-system-reviewers,sheehan,glandium
pylint_requirements.txt fail to install with the new pip resolver due
to a conflict between astroid and lazy-object-proxy.
Rather than bumping those packages and handling the potential fallout,
the package-upgrade has been deferred and we will use the legacy
resolver in the interrim.

Differential Revision: https://phabricator.services.mozilla.com/D99940
2021-01-04 15:20:21 +00:00
Ricky Stewart b2952039f9 Bug 1667152 - Add `--requirements` argument to `mach python` r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D91313
2020-11-20 19:29:26 +00:00
Noemi Erli f24bd4fcff Backed out 4 changesets (bug 1666345, bug 1661624, bug 1667152, bug 1666347) for causing mochitest failures CLOSED TREE
Backed out changeset 8ce536574e74 (bug 1666347)
Backed out changeset 7cc5b13a3bf6 (bug 1666345)
Backed out changeset e112876ba18b (bug 1661624)
Backed out changeset 0f03ce337449 (bug 1667152)
2020-11-16 21:06:12 +02:00
Ricky Stewart 3bc837a830 Bug 1667152 - Add `--requirements` argument to `mach python` r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D91313
2020-11-13 20:21:43 +00:00
Mihai Alexandru Michis 06103d0e92 Backed out 3 changesets (bug 1666345, bug 1667152, bug 1661624) for causing mochitest timeouts.
CLOSED TREE

Backed out changeset baa1f7a615e4 (bug 1666345)
Backed out changeset b6646baa866d (bug 1661624)
Backed out changeset e4d550db6037 (bug 1667152)
2020-11-13 22:14:45 +02:00
Ricky Stewart 7bf2fa711b Bug 1667152 - Add `--requirements` argument to `mach python` r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D91313
2020-11-12 18:02:17 +00:00
smolnar 1e6e466d99 Backed out 4 changesets (bug 1666347, bug 1667152, bug 1661624, bug 1666345) for causing mingw bustage. CLOSED TREE
Backed out changeset 19f707f5c097 (bug 1666347)
Backed out changeset 3732ee259759 (bug 1666345)
Backed out changeset 353d3c9e74b9 (bug 1661624)
Backed out changeset a651515586a8 (bug 1667152)
2020-11-12 19:55:58 +02:00
Ricky Stewart fe799c848a Bug 1667152 - Add `--requirements` argument to `mach python` r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D91313
2020-11-12 16:06:15 +00:00