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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user