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

Regression manager changes #3717

Merged
merged 8 commits into from Feb 24, 2024

Conversation

ktbarrett
Copy link
Member

@ktbarrett ktbarrett commented Feb 16, 2024

Following the discussion in #3578, how tests are registered with the RegressionManager was changed again. I think this solution solves everyone's issues. cocotb.parameterize was improved and TestFactory was deprecated. Closes #3689.

@ktbarrett ktbarrett requested a review from a team February 16, 2024 17:36
src/cocotb/decorators.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Show resolved Hide resolved
@ktbarrett ktbarrett force-pushed the regression-manager-changes-again branch from 2fdcdf7 to 8bd08da Compare February 16, 2024 21:10
Copy link
Contributor

@cmarqu cmarqu left a comment

Choose a reason for hiding this comment

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

(I'm only about halfway through)

src/cocotb/decorators.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Show resolved Hide resolved
@ktbarrett ktbarrett force-pushed the regression-manager-changes-again branch 3 times, most recently from 41c6201 to 990d915 Compare February 17, 2024 23:35
Copy link

codecov bot commented Feb 17, 2024

Codecov Report

Attention: Patch coverage is 88.82353% with 19 lines in your changes are missing coverage. Please review.

Project coverage is 69.46%. Comparing base (54447c6) to head (bf05d11).

Files Patch % Lines
src/cocotb/regression.py 86.15% 15 Missing and 3 partials ⚠️
src/cocotb/utils.py 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3717      +/-   ##
==========================================
+ Coverage   69.36%   69.46%   +0.10%     
==========================================
  Files          45       45              
  Lines        8042     8057      +15     
  Branches     2328     2325       -3     
==========================================
+ Hits         5578     5597      +19     
+ Misses       1353     1348       -5     
- Partials     1111     1112       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

docs/source/library_reference.rst Outdated Show resolved Hide resolved
tests/test_cases/test_cocotb/test_testfactory.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
@ktbarrett ktbarrett force-pushed the regression-manager-changes-again branch from 990d915 to f76c22f Compare February 18, 2024 17:54
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/decorators.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/utils.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
@ktbarrett ktbarrett force-pushed the regression-manager-changes-again branch from f76c22f to 2e6c973 Compare February 19, 2024 01:09
@marlonjames
Copy link
Contributor

Pinging @AndrewNolte.

src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
src/cocotb/regression.py Outdated Show resolved Hide resolved
Defaults to ``func.__doc__`` (the docstring of the test function).

timeout_time:
Simulation time duration before timeout occurs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Simulation time duration before timeout occurs.
Simulation time duration before the timeout exception :exc:`~cocotb.result. SimTimeoutError` occurs.

Copy link
Member Author

Choose a reason for hiding this comment

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

That implies it can be caught, but it can't, so I reworded it slightly.

@cmarqu
Copy link
Contributor

cmarqu commented Feb 19, 2024

It would be nice to have a section or page in the user docs showing the different use cases.

src/cocotb/regression.py Show resolved Hide resolved
src/cocotb/regression.py Show resolved Hide resolved
@AndrewNolte
Copy link
Contributor

Do you mind writing down which issue's were specifically fixed? I believe I had two main ones in that dicussion, one being that an exact match TESTCASE would now add all tests that have that as a prefix, and the other being that imported tests were automatically added

@ktbarrett
Copy link
Member Author

ktbarrett commented Feb 22, 2024

@AndrewNolte

  1. Importing from a test module registers all the tests in that module.

Fixed. And you can even import test implementations from other modules and use them to implement tests in the current module, without also registering them in the current module, which was not possible in 1.8.

  1. Importing a test from another module to add that test to the current module.

Not changed. Won't fix. Use MODULE to create multiple regressions that run different sets of tests.

  1. TESTCASE now includes all tests that use the given value as a prefix

Not changed. Won't fix. Use make TESTCASE=my_test\$ to match the test name exactly. Running all tests that match a TestFactory's test name is a desirable change. Seeing as TESTCASE is explicitly set by the user to override a regression, there should be no silent change in behavior.

@ktbarrett
Copy link
Member Author

I guess I should fix some newsfragments.

@AndrewNolte
Copy link
Contributor

Thanks! #1 was the main one I was concerned about, and #3 was more for concerns with regression use cases where the tests suites are split up and run separately. I suppose runner.py might need to be changed if that's still being maintained.

The previous method had the `cocotb.test` decorator and
`TestFactory.generate_tests` call `RegressionManager.register_test`.
This means that if a user imports a module containing cocotb tests,
those tests are added to the regression regardless if they were
specified in MODULE.

The new solution has cocotb tests register to the module by including
them in a `__cocotb_tests__` global list. The RegressionManager simply
loads the modules and extract the tests from this list. This avoids the
aforementioned problem, and also allows user to import test functions
from other module without them also being registered. While maintaining
the ability to access the originally-decorated object.

Also the `Test` object was made public again, and
`RegressionManager.register_test` made to take `Test` objects. This is
just a little neater than before.

Also a couple other small cleanups to `TestFactory` and
`RegressionManager`.
Also removed the _trim function which was 1. incorrect and 2. duplicated
by `inspect.cleandoc`.
This is no longer needed as tests are registered to the
`__cocotb_tests__` list in order of their definition in each module.
Registery should be done based on `@cocotb.test` decoration, which is in
lexical order, instead of the order of creation of `Test` objects, which
is not inherently in lexical order.
Yes! Again!

filter_tests is now add_filters which simply register filters with the
RegressionManager. Additionally, there is a set_mode method which allows
the user to set the mode of the RegressionManager. Currently this is
just used for informing the test initialization logic that we specified
TESTCASE and want to still run skipped tests. All of this is synthesized
in the start_regression call.

The other upshot of doing it this way is that excluded tests appear in
the results.xml in order of declaration rather than all pushed towards
the beginning.

More documentation and comments have been added throughout.

The awkward combination of _start_test, _init_test, and _next_test have
all been combined into _execute, so it's easier to see the full logic
being applied to each test.

The sim_failed logic in the callback side of the regression manager has
been piped out so it can work with the new _execute to save some logic.
@ktbarrett ktbarrett force-pushed the regression-manager-changes-again branch from 2e6c973 to bf05d11 Compare February 23, 2024 17:08
@marlonjames marlonjames added the category:codebase:tests (regression_manager) regarding the code for automating test runs label Feb 23, 2024
@ktbarrett ktbarrett merged commit 6238c51 into cocotb:master Feb 24, 2024
27 checks passed
@ktbarrett ktbarrett deleted the regression-manager-changes-again branch February 24, 2024 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:codebase:tests (regression_manager) regarding the code for automating test runs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve regression messages
4 participants