gh-102781: fix cwd dependence in cases generator (#102782)

This commit is contained in:
Carl Meyer 2023-03-17 11:01:10 -06:00 committed by GitHub
parent 65fb7c4055
commit 174c4bfd0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -122,8 +122,9 @@ class Formatter:
self.prefix = " " * indent self.prefix = " " * indent
self.emit_line_directives = emit_line_directives self.emit_line_directives = emit_line_directives
self.lineno = 1 self.lineno = 1
filename = os.path.relpath(self.stream.name, ROOT)
# Make filename more user-friendly and less platform-specific # Make filename more user-friendly and less platform-specific
filename = self.stream.name.replace("\\", "/") filename = filename.replace("\\", "/")
if filename.startswith("./"): if filename.startswith("./"):
filename = filename[2:] filename = filename[2:]
if filename.endswith(".new"): if filename.endswith(".new"):
@ -567,6 +568,7 @@ class Analyzer:
with open(filename) as file: with open(filename) as file:
src = file.read() src = file.read()
filename = os.path.relpath(filename, ROOT)
# Make filename more user-friendly and less platform-specific # Make filename more user-friendly and less platform-specific
filename = filename.replace("\\", "/") filename = filename.replace("\\", "/")
if filename.startswith("./"): if filename.startswith("./"):