From f87dd03eb5c725da8cdcebf2e81b9eeaf409d9ed Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Fri, 31 Jan 2025 22:31:43 +0100 Subject: [PATCH] Tests: Raise error if global and output directories match When a given render test defined in CMakeLists.txt with a `--outdir` parameter ends with a trailing slash, the resulting global report overwrites the specific test's report. This is because `os.path.dirname` for a path that ends in a slash returns the same directory, for example, `os.path.dirname('foo/bar/') => 'foo/bar' To avoid tests being able to put the report into a weird state, this commit normalizes the `--outdir` path to strip trailing slashes. Pull Request: https://projects.blender.org/blender/blender/pulls/133791 --- tests/python/modules/render_report.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/python/modules/render_report.py b/tests/python/modules/render_report.py index 1117a7dcfa2..56b7d88d8bd 100755 --- a/tests/python/modules/render_report.py +++ b/tests/python/modules/render_report.py @@ -96,8 +96,12 @@ class Report: def __init__(self, title, output_dir, oiiotool, variation=None, blocklist=[]): self.title = title - self.output_dir = output_dir - self.global_dir = os.path.dirname(output_dir) + + # Normalize the path to avoid output_dir and global_dir being the same when a directory + # ends with a trailing slash. + self.output_dir = os.path.normpath(output_dir) + self.global_dir = os.path.dirname(self.output_dir) + self.reference_dir = 'reference_renders' self.reference_override_dir = None self.oiiotool = oiiotool