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

Add support for arranging tests in subdirectories #125

Merged
merged 5 commits into from
Jan 20, 2023
Merged

Conversation

jnikula
Copy link
Owner

@jnikula jnikula commented Jan 20, 2023

This should enable us to start arranging tests in subdirectories. I played with it a bit, and it seems to work, but I didn't actually include any rearrangement of the files. I threw in some additional asserts in case the files aren't found.

Examples work test-wise, but make html will fail if the examples are placed in a subdirectory, because of hawkmoth_root config. I think that's fine for now.

This is embarrassing. We copy the input .c file to the Sphinx srcdir for
every extension test case. However, the extension looks at hawkmoth_root
configuration for the input file root, defaulting to the Sphinx
confdir. Which, during test execution, is the test directory. We don't
use the copied files at all. So stop copying.
Set hawkmoth_root for extension tests to the directory holding the
testcase yaml. We'll want the filenames in the testcase yaml to be
relative to the yaml, with hopes it's the least confusing option. We
also don't want to adjust the directive during testing depending on the
paths either.

Because the hawkmoth_root depends on the testcase yaml location, we
can't set it in conf.py.

For now, these are all the same, of course, but this will change if we
arrange the tests in a directory hierarchy.
Add support for organizing the files in subdirectories.

Note that organizing examples in a subdirectory currently does not work,
because the documentation sets hawkmoth_root to the test directory.
Be defensive against test environment bugs that cause tests to pass with
empty results.
Fail if a mandatory file is None or does not exist. Be more robust
against errors in the test environment.
@@ -101,9 +101,10 @@ def get_testid(testcase):
return testcase.get_testid()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure that the comment about the examples is warranted. hawkmoth_root simply has to be redirected to an examples folder and / or the directives must include the path of the files relative to hawkmoth_root. I.e. it does work with respect to the changes we introduce here.

Anyway, nitpicking.

Copy link
Owner Author

Choose a reason for hiding this comment

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

It'll work if you move all the examples to the same directory, and point hawkmoth_root there. But if you wanted to have examples in multiple directories, it'll break...

Copy link
Collaborator

Choose a reason for hiding this comment

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

My point is that this code is perfect as it is with regards to that. If we have hawkmoth_root=test/examples, we just need to do .. c:autodoc:: dir1/dir2/src.c, either way it's not a limitation with regards to what you changed here. We'd need only change conf.py and possibly adjust update_examples.py unless I've missed something.

Anyway, good merge ;)

@BrunoMSantos
Copy link
Collaborator

Looks pretty good to me!

@jnikula jnikula merged commit 5d04ec0 into master Jan 20, 2023
@jnikula
Copy link
Owner Author

jnikula commented Jan 20, 2023

Thanks for the review, merged!

@jnikula jnikula deleted the test-recursive branch January 27, 2023 10:08
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.

None yet

2 participants