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

Make doc/templates part of the tests build #2016

Open
kontura opened this issue Jan 23, 2025 · 1 comment
Open

Make doc/templates part of the tests build #2016

kontura opened this issue Jan 23, 2025 · 1 comment

Comments

@kontura
Copy link
Contributor

kontura commented Jan 23, 2025

This will ensure the templates are always working and don't go out of sync with current API.

This is already setup for doc/tutorial so presumably a similar approach could be used.

@ferdnyc
Copy link
Contributor

ferdnyc commented Feb 3, 2025

@kontura

This is already setup for doc/tutorial so presumably a similar approach could be used.

I suppose that might work, if it was limited to the plugin templates.

With doc/tutorial/, the code listings inside the documentation are actually embedded from tests/tutorial/, which also contains a CMakeLists.txt to compile them as test executables, linked against the libdnf5 and libdnf5-cli targets. All of the tutorial source files are written as library API consumers, so they don't affect any of the normal build components.

The code for doc/templates/libdnf5-plugin/ and doc/templates/dnf5-plugin/ could probably also be converted to modules that get compiled and linked as part of the tests build, instead of being made part of the libdnf5 or dnf5 plugins build the way they're presented in the template docs.

doc/templates/command (which is the one that got wildly out of sync) couldn't be built that way, because it gets compiled into dnf5 itself — the tests would have to do their own separate dnf5 build to incorporate it. (Although... thinking about it more, maybe the command-template test could get away with having its own minimal main.cpp, with just enough of the dnf5 setup code to test the command-loading API for that one command in the same way the real dnf5/main.cpp does it for all the other commands.)

Or maybe it's OK that only the plugin builds are tested, because except for the two lines that get added to dnf5/main.cpp (an #include for the command's header, then a call to load the command class), all of the code in doc/templates/command/ is reused by doc/templates/dnf5-plugin/ to build the same command as a plugin instead of a builtin.

...Of course, the dnf5/template/command.rst documentation on how to load the command in dnf5/main.cpp was outdated, before I updated the document, so testing those lines would be a useful thing. But since that's harder to do, "test all of the templates except these two lines" would at least be a good start, compared to nothing.

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

2 participants