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

infra: Improve testing usability #117

Merged
merged 5 commits into from
Feb 4, 2025
Merged

infra: Improve testing usability #117

merged 5 commits into from
Feb 4, 2025

Conversation

DropD
Copy link
Collaborator

@DropD DropD commented Jan 31, 2025

Improve testing usability

mark slow tests and deselect them by default (but not on CI)

Mark the test running AiiDA as slow. Change the default test args to include -m "not slow", which can be overridden by passing -m "".

Now to run the fast tests during development we can use the default

hatch test

Whereas on CI or to manually run everything we use

hatch test -m ""

which overrides any selection based on marks (consequently selecting everything).

ignore warnings from libraries and default to treating warnings as errors

This will save us from building up third party warnings from code out of our control in the test output until the actual test results get pushed out of the console history (tends to happen in python projects over time).
Now we have to decide for every warning we get, whether we can / need to deal with it or should ignore it explicitly in the config.

cmdline option for regenerating serialized references

The skipped tests which could be manually un-skipped to update references had their logic moved into a config hook for pytest, which checks for a custom cmdline option. We can now:

hatch test --reserialize

to regenerate everything (can be differenciated in the future by type of data if regenerating everything ever becomes too slow).

parallelize tests on CI

--parallel option was added to hatch test on CI (github runners can typically not run many workers, so the speedup is probably small)

@DropD DropD requested review from leclairm and agoscinski January 31, 2025 14:12
@DropD DropD changed the title disable slow tests by default, enable on CI Improve testing usability Jan 31, 2025
@DropD
Copy link
Collaborator Author

DropD commented Feb 3, 2025

now hatch test does not run doctests, but hatch test -v does, while neither runs the "slow" tests.

@leclairm
Copy link
Contributor

leclairm commented Feb 3, 2025

now hatch test does not run doctests, but hatch test -v does, while neither runs the "slow" tests.

Some observations:

  • hatch test -v enables the doctests again
  • setting extra-args = ["--doctest-modules", '-m not slow', '-v'] doesn't help, doctests are still skipped while the output is verbose.
  • Now, still with -v in the extra-args, running hatch test -v, which should make no difference, does enable the doctests again.

So, apparently, appending an extra arg (probably random) re-enables doctests

@leclairm
Copy link
Contributor

leclairm commented Feb 3, 2025

Also hatch test --doctest-modules activates the doctests as expected

@leclairm
Copy link
Contributor

leclairm commented Feb 3, 2025

Finally found workarounds there and there. This seems to work:

default-args = []
extra-args = ["--doctest-modules", "-m not slow"]

Copy link
Contributor

@leclairm leclairm left a comment

Choose a reason for hiding this comment

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

Fix the doctest issue, potentially with my proposition. Otherwise all good.

Copy link
Collaborator

@agoscinski agoscinski left a comment

Choose a reason for hiding this comment

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

I am happy with it but I did not rigorously review it, since @leclairm already had a look

@@ -38,7 +38,7 @@ jobs:
env:
PYTEST_ADDOPTS: "--durations=0"
run: |
hatch test --cover
hatch test -m "" --parallel --cover # override default exclusion of slow tests with -m ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

ah super nice that hatch already comes with pytest-xdist and coverage

@DropD DropD changed the title Improve testing usability infra: Improve testing usability Feb 4, 2025
@DropD
Copy link
Collaborator Author

DropD commented Feb 4, 2025

Finally found workarounds there and there. This seems to work:

default-args = []
extra-args = ["--doctest-modules", "-m not slow"]

I had deleted that line without checking whether it was needed. Turns out it was, thanks for finding the source of the problem, @leclairm.

@DropD DropD merged commit 2064daa into C2SM:main Feb 4, 2025
6 checks passed
@DropD DropD deleted the mark-slow-tests branch February 4, 2025 13:08
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.

3 participants