From 1783de553b1b8df1380be4199ca83afb1a41462b Mon Sep 17 00:00:00 2001 From: emirplus Date: Sat, 17 Oct 2026 14:17:42 +0300 Subject: [PATCH] fix(tools): handle trailing separators in select_tests root paths --- tools/select_tests.py | 6 ++++-- tools/tests/test_select_tests.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/select_tests.py b/tools/select_tests.py index 9c77894a0a..5def841494 100644 --- a/tools/select_tests.py +++ b/tools/select_tests.py @@ -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): diff --git a/tools/tests/test_select_tests.py b/tools/tests/test_select_tests.py index 434a3da749..8a2099e69b 100644 --- a/tools/tests/test_select_tests.py +++ b/tools/tests/test_select_tests.py @@ -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()