Skip to content

Conversation

@ld-kerley
Copy link
Contributor

As reported in #2663 the get all files in directory unit test is not robust enough to OS generated files.

This PR inverts the validation logic to make it more robust.

Looks like this idea fails the windows CI - but im not sure why and don't have a windows machine to investigate.

@ld-kerley ld-kerley requested a review from kwokcb November 11, 2025 22:28
@kwokcb
Copy link
Contributor

kwokcb commented Nov 13, 2025

There is an issue with the logic in FilePath::getFilesInDirectory() for Windows:

You need this change since on FindFirstFileA will try to match that specific file (not the contents of the folder).

    FilePath query = extension.empty() ? (*this / "*") : (*this / ("*." + extension));
    //FilePath query = extension.empty() ? *this : (*this / ("*." + extension)); // finds nothing
    HANDLE hFind = FindFirstFileA(query.asString().c_str(), &fd);

Also suggest to put in a REQUIRE(results.size() > 0) in the unit test to check for this.

I ran with these changes locally and it seems to work if you have extra files in the folders being checked.

Copy link
Contributor

@kwokcb kwokcb left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. Looks good.

@ld-kerley ld-kerley merged commit bf12e61 into AcademySoftwareFoundation:main Nov 14, 2025
32 checks passed
@ld-kerley ld-kerley deleted the fix-get-files-in-directory-unit-test branch November 21, 2025 16:56
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.

2 participants