-
Notifications
You must be signed in to change notification settings - Fork 326
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
Introducing "testing" object #1740
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Fabrice Macagno <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1740 +/- ##
==========================================
+ Coverage 58.29% 58.51% +0.22%
==========================================
Files 126 126
Lines 17159 17095 -64
Branches 3505 3506 +1
==========================================
+ Hits 10002 10003 +1
+ Misses 6493 6382 -111
- Partials 664 710 +46 ☔ View full report in Codecov by Sentry. |
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.
Just by looking at this PR, I'm struggling to see if it also applies to early bound functions. The description says that it's only for @late, but we have building in @early.
If the changes inject testing in @early, then the documentation should be adapted as such. If it doesn't then I think we should change the PR so that testing will also be available in @early.
Additionally, I would like to see a test or two.
Thanks!
Co-authored-by: Jean-Christophe Morin <[email protected]> Signed-off-by: Fabrice Macagno <[email protected]>
I think early bound attributes are not relevant to I thought about adding some unit tests but I couldn't find counterparts for |
I also think that |
Oh, yeah, you are right about As for the tests, I don't think there is any for |
Sounds good, we've carved out some time to add a few unit tests. |
Signed-off-by: nathan-cheung <[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.
Looks great! The tests are failing, but I added instructions on how to make them pass.
Also, you will need to run the ./src/build_utils/license/apply_copyright
script and fix flake8 warnings.
|
||
def test_1(self): | ||
"""package.py unit tests are correctly run in a testing environment""" | ||
context = ResolvedContext(["testing_obj"]) |
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.
context = ResolvedContext(["testing_obj"]) | |
self.inject_python_repo() | |
context = ResolvedContext(["testing_obj"]) |
This will add a usable python
package and make it available to the tests (only this test). Without this, the tests won't be portable across platforms because we can't rely on python being available on the system. We need python to run the test suite, but that doesn't mean that calling python
should work because it doesn't have to be on PATH
, and by experience, it will sometimes not be on PATH.
The magic happens in
Lines 89 to 93 in 9094b08
repo = os.path.join(os.getcwd(), "__tests_pkg_repo") | |
os.makedirs(repo, exist_ok=True) | |
create_python_package(os.path.join(os.getcwd(), "__tests_pkg_repo")) | |
os.environ["__REZ_SELFTEST_PYTHON_REPO"] = repo |
Signed-off-by: Fabrice Macagno <[email protected]>
Introducing a
testing
object available in late bindings, similar to thebuilding
object, but indicating arez-test
context.