Skip to content

Two tests for (include_subdirs qualified) and directories with invalid module names#7620

Closed
Niols wants to merge 6 commits intoocaml:mainfrom
Niols:two-tests-for-include-subdirs-qualified
Closed

Two tests for (include_subdirs qualified) and directories with invalid module names#7620
Niols wants to merge 6 commits intoocaml:mainfrom
Niols:two-tests-for-include-subdirs-qualified

Conversation

@Niols
Copy link
Copy Markdown
Contributor

@Niols Niols commented Apr 23, 2023

This PR adds two tests for the (include_subdirs qualified) stanza, specifically when this stanza is used while a directory whose name is an invalid module name is present (baz-baz). The two tests circumvent this problem in two different ways:

  1. The first one adds a (dirs :standard \ baz-baz) stanza to hide this module from Dune. This works fine as of now.
  2. The second one adds a (data_only_dirs baz-baz) stanza to specify that this directory should not be considered as a module but as a directory of data. This fails in the current state of Dune.

These two tests are meant as an illustration for #7601 (comment), which might soon lead to a feature request.

@anmonteiro
Copy link
Copy Markdown
Collaborator

related #7605

@Niols Niols force-pushed the two-tests-for-include-subdirs-qualified branch from 40d1304 to d7e55d8 Compare April 23, 2023 23:31
@Niols Niols force-pushed the two-tests-for-include-subdirs-qualified branch from d7e55d8 to ede03c9 Compare April 23, 2023 23:33
@Niols Niols force-pushed the two-tests-for-include-subdirs-qualified branch from 01babf7 to 6c8836c Compare April 25, 2023 09:41
@Niols
Copy link
Copy Markdown
Contributor Author

Niols commented Apr 25, 2023

Added a test where the directory with a malformed module name is nested in a directory with a valid name and that one is the one mentioned in (data_only_dirs).

@rgrinberg
Copy link
Copy Markdown
Member

@anmonteiro could you lead the review on this one?

@Niols Niols force-pushed the two-tests-for-include-subdirs-qualified branch from 8af0a31 to e1f2f4e Compare May 24, 2023 12:47
@@ -0,0 +1,3 @@
(include_subdirs qualified)
(executable (name foo))
(data_only_dirs baz-baz)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is this testing? I don't think this has any effect since there are no dune rules under baz-baz. (data_only_dirs ignores dune rules in the specified directories).

There are also no modules under that directory.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I do think that if the directories contain no Dune rules and no modules, it would make sense for Dune to simply ignore them, making the tests in this PR irrelevant. At the time of writing this PR, though, a project of mine could not compile because of a situation like this, where there were no modules and no Dune rules yet Dune failed because of a directory with invalid name. I haven't tested on newer Dune version but I have just updated my branch and we'll see what the CI thinks of this.

Copy link
Copy Markdown
Collaborator

@anmonteiro anmonteiro left a comment

Choose a reason for hiding this comment

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

I think the tests would be a bit more useful if they were testing the inclusion / exclusion of the directories in question.

Right now it's not clear whether the directories are being excluded because they're specified in data_only_dirs / dirs or because they have invalid folder names.

@Niols
Copy link
Copy Markdown
Contributor Author

Niols commented Sep 17, 2023

I think the tests would be a bit more useful if they were testing the inclusion / exclusion of the directories in question.

Sorry, I don't understand what you mean!

Right now it's not clear whether the directories are being excluded because they're specified in data_only_dirs / dirs or because they have invalid folder names.

When I wrote these tests, Dune was failing whenever a directory with an invalid name was present in the scope. I assumed it was a feature and therefore the test was supposed to exhibit the fact that Dune should not fail when the directories with invalid names were included in a data_only_dirs or dirs statement. Now if it has been decided that Dune was not supposed to fail on those directories to begin with but to ignore them, then yes, these tests become rather useless. I haven't played with the new versions of Dune so I don't know where we stand on this.

@Niols
Copy link
Copy Markdown
Contributor Author

Niols commented Sep 17, 2023

I haven't played with the new versions of Dune so I don't know where we stand on this.

The CI seems to show that this is still the case, but maybe I misunderstood something?

@anmonteiro
Copy link
Copy Markdown
Collaborator

To provide some closure here: data_only_dirs only means that dune will not read dune files in those directories, so these tests work as expected: (include_subdirs qualified) still indexes the modules in that directory.

@anmonteiro anmonteiro closed this Dec 31, 2025
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.

3 participants