-
Notifications
You must be signed in to change notification settings - Fork 337
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
Rez test improvements (dev mode, interactive flag) #759
base: main
Are you sure you want to change the base?
Conversation
Introduced support for test env activation from command line. New flag --env set the test environment which will be sourced (base on test definitions in package.py. Support for anonymous tests invocation. You can ommit the package name from the test command 'rez test <package_name>' while running tests from the package root directory. Added auto build in case package is not built before tests rez/vendor: ----------- - added mock 2.0.0 - added funcsigs 1.0.2
Recently introduced improvement in rez test command was causing error in case when rez test command has been executed with package version eg. rez test package==1.0.0 This change repairs that situation.
This change introduces a new field in the package configuration called "run_in_root", which is optional and by default set to False. Setting it to True will store test artifacts in the package root * Review requested changes
Update: Hoping to be working on this soon, we need the same functionality at Method. Stay tuned. |
PKG_action = parser.add_argument( | ||
"--extra-packages", nargs='+', metavar="PKG", | ||
help="extra packages to add to test environment") | ||
PKG_action = parser.add_argument( | ||
"PKG", | ||
"PKG", nargs='?', |
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.
-h
does not make it clear what it means if PKG
is not provided. It also is not clear from the help that PKG
can be a path (ie .
). I'm tempted to say that we keep it simpler than this - PKG is either provided or not, and if not, then we're in "developer" mode.
help="resolves an interactive environment for running the tests.") | ||
parser.add_argument( | ||
"--variant", dest="variant", default=0, type=int, | ||
help="variant number which should be used to set the interactive env. Works only with --interactive option") |
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.
This should work in the general case also, it makes sense to specify a variant to run tests on.
|
||
Returns: True or False | ||
""" | ||
return not name or name == '.' |
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.
Too fragile. As mentioned earlier, I think it'd be better if developer mode is enabled only if PKG is not provided. Right now is odd because PKG can be a package string, or ".", but not any other valid path. There is too much variability in what PKG can be.
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.
agree
Args: | ||
path: path to the package | ||
|
||
Returns: Tuple of values (package_name, is_dev_run) |
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.
Wrong return docstring. Also not sure we need this function.
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.
probably not needed, I'm guessing was added to make the code more testable, but I'm pretty sure you can call directly get_developer_package
return None | ||
|
||
|
||
def prepare_dev_env_package(package): |
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.
I'm actually pretty hesitant about rez-test possibly implicitly installing a package like this. Package installation is always explicit everywhere else. Furthermore this feels arbitrary - the package gets installed if it wasn't there, but what if it's there but put of date due to a sourcecode change? We can't detect that and I don't think we should.
It seems simpler and less error prone to simply give an error if the current developer package isn't present as a local package, and leave it up to the user if and when to rebuild/reinstall the package.
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.
yes, we can not detect that. ATM we are only detecting changes on the packages.py and reinstalling the package when the tests are out of date.
I'll do a poll tomorrow when I'm at work, I'm guessing not many devs are really relying on this feature. So, I guess it can go away
sys.argv = original_args | ||
|
||
|
||
def update_package_in_local_packages_path(package, installed_package): |
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.
Again this feels arbitrary - the package is being kept up-to-date wrt its tests, but not its actual payload (ie if source was changed). I think we should just leave it up to the developer to reinstall the package.
Having said that, something that I think would be acceptable in developer mode is if the test definitions are always taken from the developer package, rather than from the installed package.
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.
In that case, if they are taken from the developer package, I think people will be happy
stdout=self.stdout, | ||
stderr=self.stderr, | ||
block=True) | ||
test_result_dir = os.path.abspath('build/rez_test_result' if not test_info["run_in_root"] else '.') |
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.
'build/rez_test_result' should be configurable. As mentioned earlier, we should have a tests_artifact_path
setting rather than run_in_root
. Then, to run tests in root for a given package, you do a package-level config override, like so:
with scope("config") as c:
c.tests_artifact_repository = '.'
This is more consistent with how settings are managed in other parts of the codebase.
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.
agree
|
||
|
||
@contextmanager | ||
def change_dir(dir_path): |
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.
This is very similar to existing rez.utils.filesystem.retain_cwd
. I would update this existing func to be able to chdir to a specified path, and use that instead.
So I'm freed up to work on this next week for Method. I think it would make sense to use this PR and #758 as a basis for that work, rather than updating these PRs though. Reasons are:
Fede I wanted to let you know in case you thought I'm throwing this work away! Rest assured a chunk of the work is already done here and I'll be incorporating it into the upcoming PRs. Expect to see more next week. |
Note that some of this PR has been superseded by #807. However, I'm still open to adding the dev mode functionality shown here, as long as there's consensus. It's not clear to me how this should work exactly - as mentioned above, the way the package is automatically re-installed if the tests definition changes, feels inconsistent. Wrt |
@nerdvegas @fnaum The way I see the dev mode is just to avoid some typing. So instead of doing |
Yeah I don't mind that functionality, but in
#759 'dev mode' is not quite that
simple, as it does things like automatically re-install the package if its
tests change. I am not so sure about that, because it feels a bit arbitrary
as to whether a package is reinstalled (ie yes if tests change, no if
anything else changes).
In #759, test byproducts are also written to a specific directory when in
dev mode. So the question is also whether this should happen and if so,
what that path should be.
A
…On Wed, Dec 4, 2019 at 2:58 PM Jean-Christophe Morin < ***@***.***> wrote:
@nerdvegas <https://github.com/nerdvegas> @fnaum
<https://github.com/fnaum> The way I see the dev mode is just to avoid
some typing. So instead of doing rez-build -ci && rez-test packageA==x.x.x,
you could just do rez-build -ci && rez-test .. It would make things
simpler to use IMO. So it's just a "shorthand".
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#759>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMOUSSJGRR7JWFQNGQ3RE3QW4TIHANCNFSM4I6XOR4Q>
.
|
Yeah, I wouldn't go with the auto-install. Hence why I was giving
I still haven't made my mind on this. To be frank, the first time I reviewed this PR I didn't like the idea that rez would know where my tests artifacts are. And as of today I have the same feeling. You could have 5 different test target that each run different tools that will all generate tests artifacts in a different way (and sometimes if would even be impossible to choose where to put them). That means each test would have to define it's artifact directory. Though a possible case, it might not be a super common one. It would be easy to implement though. I think the hardest part will be to agree on how to handle that... |
Marking as ON HOLD - these features are desired (interactive mode, dev mode), however the code has changed too much for this PR to be viable. Keeping for reference until an equivalent is merged. |
Sorry, I was not active when you reviewed this, we lost the only resource that was working with rez and all the other tools and we have not found a replacement yet. :( |
Some rez test improvements
rez test
in "developer mode" usingrez test .
from the root folder of the package.REZ_LOCAL_PACKAGES_PATH
tests
section changed--interactive
option, to resolve an interactive environment to run the tests. ie. (rez test --interactive TESTNAME
). In case the package has multiple variants, you can also specify the variant using--variant
build/rez_test_result
directory to run the test and store the test artifacts (this way we can pick those results from tools like sonar, that expect the nose and coverage reports in a known place). If they need to be run on the root of the packagesrun_in_root
can be set in thetests
field of thepackage.py
.--clean
to clean the test artifacts created from a previous test run.mock
module undervendor
related to #665