Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

fabal
Copy link

@fabal fabal commented May 1, 2024

Introducing a testing object available in late bindings, similar to the building object, but indicating a rez-test context.

@fabal fabal requested a review from a team as a code owner May 1, 2024 02:42
Copy link

linux-foundation-easycla bot commented May 1, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Signed-off-by: Fabrice Macagno <[email protected]>
Copy link

codecov bot commented May 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.51%. Comparing base (36e0537) to head (6466a13).
Report is 18 commits behind head on main.

Current head 6466a13 differs from pull request most recent head 471b065

Please upload reports for the commit 471b065 to get more accurate results.

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@JeanChristopheMorinPerso JeanChristopheMorinPerso left a 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!

docs/source/package_commands.rst Outdated Show resolved Hide resolved
Co-authored-by: Jean-Christophe Morin <[email protected]>
Signed-off-by: Fabrice Macagno <[email protected]>
@fabal
Copy link
Author

fabal commented May 6, 2024

I think early bound attributes are not relevant to rez-test scenarios because they're flattened upon install, meaning any logic will go away anyway. Unless I'm missing something?

I thought about adding some unit tests but I couldn't find counterparts for building use cases? Unless there aren't any?

@fnaum
Copy link

fnaum commented May 6, 2024

I also think that testing does not make sense in @early, as we early decorated functions are evaluated at build time.
so even if we add the object there it would always be false.

@JeanChristopheMorinPerso
Copy link
Member

Oh, yeah, you are right about @early, by bad.

As for the tests, I don't think there is any for building and we also don't have tests for rez-test. So it could be a good occasion to add some rez-tests tests.

@fabal
Copy link
Author

fabal commented May 12, 2024

Sounds good, we've carved out some time to add a few unit tests.

Signed-off-by: nathan-cheung <[email protected]>
Copy link
Member

@JeanChristopheMorinPerso JeanChristopheMorinPerso left a 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.

docs/source/package_commands.rst Outdated Show resolved Hide resolved
docs/source/package_commands.rst Outdated Show resolved Hide resolved

def test_1(self):
"""package.py unit tests are correctly run in a testing environment"""
context = ResolvedContext(["testing_obj"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

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

@JeanChristopheMorinPerso JeanChristopheMorinPerso added this to the Next milestone Jun 22, 2024
Signed-off-by: Fabrice Macagno <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants