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

plugin: Checking other plugins #2815

Open
LecrisUT opened this issue Apr 3, 2024 · 0 comments
Open

plugin: Checking other plugins #2815

LecrisUT opened this issue Apr 3, 2024 · 0 comments

Comments

@LecrisUT
Copy link
Contributor

LecrisUT commented Apr 3, 2024

I haven't checked that it works, but my understanding is that this is one way to check the plugin type of a particular step:

        # Check that there is a prepare CMake step
        if not any(
            phase
            for step in self.step.plan.steps()
            if isinstance(step, Prepare)
            for phase in step.phases(tmt_cmake.prepare.PrepareCMake)
        ):
            msg = "No CMake prepare step found"
            raise tmt.utils.SpecificationError(msg)

Two simplifications that can be done here:

  • tmt.plan.steps accepting classes similar to the step.phases
  • Have a tmt.plan.phases that wraps the generator above. Maybe these should be as mixin since the tmt.base.Plan is quite lengthy. Although that would make it less navigable?

Second question for this, where should such a check be. I believe the most appropriate place so far is in wake? It should be in a place that:

  • Guarantees all steps and phases are defined
  • Is run for lint/show steps as well.

Edit: Tried it out and wake does not affect those cases, so it might need to be spread out different entry points

I have then tried to add it to show, but it seems in the current version show does not error when bogus data is given, so I should not use raise for that case. Right now I am using using try...except and redirecting the output to warning. Thinking of doing the same for wake but redirecting to fail. Technically this should be handled by the schema validation, but it is not portable to external plugins yet.

I think the thing that confuses me here is how one should add messages and raise, so as to not affect the remainder of the execution. E.g. if I raise within show or wake, the execution of the remainder of the tmt show/run fails, i.e. other tmt plans are stopped and do not execute.


Update this does not work :(. The phases are not available at the wake/show stage and not all steps are computed at that point. The closest I could get is to check step.data type

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

No branches or pull requests

1 participant