From 311d3e701a2e46d0f66aea4082ff4fb939139759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 20 Sep 2026 16:34:29 -0300 Subject: [PATCH] Fix tests in Windows build. --- .../unit_tests/projectdirectorytree_tests.cpp | 6 +++++- src/tools/ecode/ignorematcher.cpp | 12 ++++++++++-- src/tools/ecode/projectdirectorytree.cpp | 18 ++++++++++++++---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/tests/unit_tests/projectdirectorytree_tests.cpp b/src/tests/unit_tests/projectdirectorytree_tests.cpp index 0c5953c51..658a26e23 100644 --- a/src/tests/unit_tests/projectdirectorytree_tests.cpp +++ b/src/tests/unit_tests/projectdirectorytree_tests.cpp @@ -54,7 +54,11 @@ class ProjectDirectoryTreeTestDirectory { } std::string path( const std::string& relativePath = {} ) const { - return relativePath.empty() ? mPath.string() : ( mPath / relativePath ).string(); + std::filesystem::path path( mPath ); + if ( !relativePath.empty() ) + path /= relativePath; + path.make_preferred(); + return path.string(); } private: diff --git a/src/tools/ecode/ignorematcher.cpp b/src/tools/ecode/ignorematcher.cpp index dc1a955ce..3f4e6bdd1 100644 --- a/src/tools/ecode/ignorematcher.cpp +++ b/src/tools/ecode/ignorematcher.cpp @@ -131,7 +131,11 @@ bool IgnoreMatcherManager::match( const FileInfo& file ) const { localPath.clear(); if ( String::startsWith( dirPath, matcher->getPath() ) ) localPath = dirPath.substr( matcher->getPath().size() ); - if ( matcher->match( localPath + file.getFileName() ) ) + localPath += file.getFileName(); +#if EE_PLATFORM == EE_PLATFORM_WIN + std::replace( localPath.begin(), localPath.end(), '\\', '/' ); +#endif + if ( matcher->match( localPath ) ) return true; } return false; @@ -144,7 +148,11 @@ bool IgnoreMatcherManager::match( const std::string& dir, const std::string& val localPath.clear(); if ( String::startsWith( dir, matcher->getPath() ) ) localPath = dir.substr( matcher->getPath().size() ); - if ( matcher->match( localPath + value ) ) + localPath += value; +#if EE_PLATFORM == EE_PLATFORM_WIN + std::replace( localPath.begin(), localPath.end(), '\\', '/' ); +#endif + if ( matcher->match( localPath ) ) return true; } return false; diff --git a/src/tools/ecode/projectdirectorytree.cpp b/src/tools/ecode/projectdirectorytree.cpp index 4640632c8..1b57c35e7 100644 --- a/src/tools/ecode/projectdirectorytree.cpp +++ b/src/tools/ecode/projectdirectorytree.cpp @@ -396,16 +396,26 @@ bool ProjectDirectoryTree::shouldIgnoreEntry( const std::string& directory, if ( !mAllowedMatcher || !mAllowedMatcher->hasPatterns() ) return true; std::string fullpath( directory + filename ); - std::string_view localPath( fullpath ); + size_t localPathOffset = 0; if ( String::startsWith( directory, mAllowedMatcher->getPath() ) ) - localPath.remove_prefix( mAllowedMatcher->getPath().size() ); + localPathOffset = mAllowedMatcher->getPath().size(); +#if EE_PLATFORM == EE_PLATFORM_WIN + std::replace( fullpath.begin(), fullpath.end(), '\\', '/' ); +#endif + std::string_view localPath( fullpath ); + localPath.remove_prefix( localPathOffset ); if ( !mAllowedMatcher->match( localPath ) ) return true; } else if ( mDisallowedMatcher && mDisallowedMatcher->hasPatterns() ) { std::string fullpath( directory + filename ); - std::string_view localPath( fullpath ); + size_t localPathOffset = 0; if ( String::startsWith( directory, mDisallowedMatcher->getPath() ) ) - localPath.remove_prefix( mDisallowedMatcher->getPath().size() ); + localPathOffset = mDisallowedMatcher->getPath().size(); +#if EE_PLATFORM == EE_PLATFORM_WIN + std::replace( fullpath.begin(), fullpath.end(), '\\', '/' ); +#endif + std::string_view localPath( fullpath ); + localPath.remove_prefix( localPathOffset ); if ( mDisallowedMatcher->match( localPath ) ) return true; }