Merge pull request #7106 from emirplus/fix/select-tests-trailing-separator

fix(tools): handle trailing separators in select_tests root paths
This commit is contained in:
Dean authored and GitHub committed 2026-10-18 01:58:52 +13:00
commit 097600f2e2
2 files changed
+14 -2

No files matched your search

+4 -2
View File
@@ -101,11 +101,13 @@ class Build:
def inside(path, root):
return os.path.normcase(path).startswith(os.path.normcase(root) + os.sep)
prefix = os.path.normcase(root).rstrip(os.sep) + os.sep
return os.path.normcase(path).startswith(prefix)
def relative(path, root):
return path[len(root) + 1:].replace(os.sep, "/")
root_len = len(root.rstrip(os.sep))
return path[root_len + 1:].replace(os.sep, "/")
def chunks(names):
+10
View File
@@ -129,6 +129,16 @@ class CaseInsensitivePathTests(unittest.TestCase):
self.assertIsNone(build.repo(os.path.join(os.sep, "WORK", "SOURCE", "BUILD", "Generated.h")))
self.assertEqual(build.key(os.path.join("tests", "MemoryPoolTest.exe")), build.key(os.path.join(os.sep, "WORK", "SOURCE", "BUILD", "TESTS", "memorypooltest.exe")))
def test_trailing_separator_in_root_is_handled(self):
with mock.patch.object(select_tests.os.path, "normcase", str.lower):
build = self.build()
build.source = build.source + os.sep
build.path = build.path + os.sep
self.assertEqual(build.output(os.path.join(os.sep, "work", "source", "build", "tests", "MemoryPoolTest.exe")), "tests/MemoryPoolTest.exe")
self.assertEqual(build.output(os.path.join("tests", "MemoryPoolTest.exe")), "tests/MemoryPoolTest.exe")
self.assertEqual(build.repo(os.path.join(os.sep, "work", "source", "core", "libSceAgc", "Driver.cpp")), "core/libSceAgc/Driver.cpp")
self.assertIsNone(build.repo(os.path.join(os.sep, "WORK", "SOURCE", "BUILD", "Generated.h")))
if __name__ == "__main__":
unittest.main()