-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PIP runner introduction #6072
base: master
Are you sure you want to change the base?
PIP runner introduction #6072
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6072 +/- ##
==========================================
+ Coverage 68.67% 68.70% +0.02%
==========================================
Files 202 203 +1
Lines 21892 21937 +45
==========================================
+ Hits 15034 15071 +37
- Misses 6858 6866 +8 ☔ View full report in Codecov by Sentry. |
35f623a
to
f7e4e99
Compare
This commit introduces a new dependency runner called `pip`. With this runner, avocado will be able to manipulate with python packages in test environment based on the test dependency configuration. The runner will install pip into the test environment, and then it can call `pip install` or `pip uninstall` commands. For example, this feature can be used for running `coverage.py` inside different environments than process. Signed-off-by: Jan Richter <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @richtja ,
This is a great idea, and a have a few comments for immediate changes, and somethings that can/should follow up later.
As for immediate changes, I mentioed the req-pac
bits in the selftests.
Also, please add this variant to the nrunner-interface
suite in selftests/check.py
. While at it, add a selftests/functional/nrunner_interface.py.data/recipe_runnable_pip.json
file (which can be a link or copy of the existing example file in this PR), but consider its actual execution and network access, etc.
It'd also be nice to add a test with a dependency as an example. I found that it's possible to do something like examples/tests/dependency_pip.py
:
from avocado import Test, fail_on
class Pip(Test):
"""
:avocado: dependency={"type": "pip", "name": "pip", "action": "install"}
"""
@fail_on(ImportError)
def test(self):
import pip
It may seem pointless, but it's something that can run pretty much in every Python environment without causing disruption (installing extra modules).
As future points:
- This looks like it could be part of a replacement for the use of eggs for Avocado's own automatic deployment
- It would be nice to support the location destination where the pip modules will be installed (such as a venv). This would be especially useful for Avocado's own automatic deployment.
- Support for multiple pip packages instead of one at a time
class TaskRun(unittest.TestCase): | ||
def test_no_kwargs(self): | ||
res = process.run( | ||
f"{RUNNER} task-run -i XXXreq-pacXXX -k pip", ignore_status=True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The req-pac
bits are understandably copies from the similar existing test you used as the basis for this, but may cause confusion on people reading this code. I suggest you change it to something easier to understand.
self.assertIn(b"'time': ", res.stdout) | ||
self.assertEqual(res.exit_status, 0) | ||
|
||
@unittest.skipUnless( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An idea: I think we're at a point where we need to stop depending on the CI
environment flag, and determine whether the environment the test is running:
- can be written permanently and destructively
- has network access
Of course we can look into CI
environment variables and the like, but it would make the SKIPs
much more manageable.
This PR introduces a new dependency runner called
pip
. With this runner, avocado will be able to manipulate with python packages in test environment based on the test dependency configuration. The runner will install pip into the test environment, and then it can callpip install
orpip uninstall
commands. For example, this feature can be used for runningcoverage.py
inside different environments than process.