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

Override test attribute from plan #2865

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

lukaszachy
Copy link
Collaborator

@lukaszachy lukaszachy commented Apr 16, 2024

New option for discover -h fmf to adjust discovered tests

I went with 'adjust-tests' keyword proposed in #2430 (reply in thread)

Still to decide:

  • schema/type checking for rules
  • way to specify via CLI

Extend test coverage

  • 'adjust-tests' with value taken from envar, e.g. require: [$FORCE_REQUIRE]

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • update the specification
  • adjust plugin docstring
  • modify the json schema
  • mention the version
  • include a release note

New option for discover -h fmf to adjust discovered tests

Fix: #2430
@lukaszachy lukaszachy linked an issue Apr 16, 2024 that may be closed by this pull request
@lukaszachy lukaszachy added the blocked The merging of PR is blocked on some other issue label Apr 16, 2024
@lukaszachy
Copy link
Collaborator Author

Note that you need teemtee/fmf#230 to try this PR

@@ -155,6 +155,12 @@ class DiscoverFmfStepData(tmt.steps.discover.DiscoverStepData):
show_default=True,
help="Copy only immediate directories of executed tests and their required files.")

# Edit discovered tests
adjust_tests: list[Any] = field(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it make sense for this field to be pretty much the same as adjust, https://github.com/teemtee/tmt/blob/main/tmt/base.py#L681 ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose it could, it would be re-using the adjust concept, i.e. the same set of keys? We would use _RawAdjustRule type instead of Any (it's almost the same, but still better than Any, it's easier to follow in code).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks, was blind to see that we already have adjust rules

@@ -562,7 +568,8 @@ def do_the_discovery(self, path: Optional[Path] = None) -> None:
tree = tmt.Tree(
logger=self._logger,
path=tree_path,
fmf_context=self.step.plan._fmf_context)
fmf_context=self.step.plan._fmf_context,
additional_rules=self.get('adjust-tests'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

self.data.adjust should be preferred over self.get() as self.get() can't handle the type annotations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so like this?

Suggested change
additional_rules=self.get('adjust-tests'))
additional_rules=self.data.adjust_tests)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, that should work, type checkers should grab the right type (because self.data is a dataclass), and match it against the additional_rules signature.

@lukaszachy lukaszachy added this to the 1.34 milestone Apr 30, 2024
@lukaszachy lukaszachy modified the milestones: 1.34, 1.35 Jun 5, 2024
@lukaszachy
Copy link
Collaborator Author

fmf released today, but it will take some time it reaches stable repos, thus aiming for next tmt version with this.

@lukaszachy lukaszachy removed the blocked The merging of PR is blocked on some other issue label Jun 5, 2024
@martinhoyer martinhoyer modified the milestones: 1.35, 1.36 Jul 30, 2024
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.

Override test duration from plan
3 participants