-
Notifications
You must be signed in to change notification settings - Fork 52
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
Provide method which compares two ModuleStream objects #186
Comments
This should be a fairly easy (but not quick) addition to the 2.0 API. What we'll need:
As an implementation recommendation, the child objects should "chain up" to the parent class to compare the pieces common to all. |
Hey I am an Outreachy applicant, would like to work on this issue! |
@sgallagher Virtual functions are not native to C, which is the language used for the source files in the v2 directory. Do you mind further explaining what you mean by "virtual function" and possibly point to some resources on how to implement them? |
@indigoOmega021 The libmodulemd project is built atop the GObject toolkit. This offers us two advantages: the first is a rough approximation of object-orientation for the C language. The second is automatic introspection of these objects to create bindings for other languages such as python. A pretty good tutorial on GObjects (including how to create virtual and pure-virtual functions) can be found at https://developer.gnome.org/gobject/stable/howto-gobject.html In the case of libmodulemd, the parent class is located at https://github.com/fedora-modularity/libmodulemd/blob/master/modulemd/v2/modulemd-module-stream.c and the two existing child-classes are https://github.com/fedora-modularity/libmodulemd/blob/master/modulemd/v2/modulemd-module-stream-v1.c and https://github.com/fedora-modularity/libmodulemd/blob/master/modulemd/v2/modulemd-module-stream-v2.c |
@sgallagher I am trying to wrap my head around what "various objects and variables" to check in the equals function. Should I just use all of the getter methods for the Modulemd.ModuleStream, Modulemd.ModuleStreamV1, and Modulemd.ModuleStreamV2 classes and check that every word that is returned is equal for both objects? Any advice would be appreciated. |
For those getters that return strings, yes. For getters that return other objects (integers, other GObject types, etc.), they need to have an appropriate comparison. The comparison function needs to check every attribute that has a getter. |
@indigoOmega021 OK, I should have broken this task up a lot more when I initially created it. I've now created issues #214 #215 #216 #217 and #218 to track the individual objects underneath this one that need their own comparisons. I'd recommend picking one of those and working on that first and setting this one aside for now. Sorry for not realizing this sooner. |
@sgallagher can I please work on this now? |
Go ahead! |
In MBS unit-test, we want to be able to compare two modulemd objects to ensure they are the same. We currently have to do
yaml.load(mmd1.dumps()) == yaml.load(mmd2.dumps())
to achieve that. It would be nice if there is some libmodulemd method to do the same.The text was updated successfully, but these errors were encountered: