Skip to content

gh-105540: Improve relative paths in generate_cases.py #106942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions Tools/cases_generator/generate_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,15 +1154,10 @@ def write_function(
self.out.emit("")

def from_source_files(self) -> str:
filenames = []
for filename in self.input_filenames:
try:
filename = os.path.relpath(filename, ROOT)
except ValueError:
# May happen on Windows if root and temp on different volumes
pass
filenames.append(filename)
paths = f"\n{self.out.comment} ".join(filenames)
paths = f"\n{self.out.comment} ".join(
prettify_filename(filename)
for filename in self.input_filenames
)
return f"{self.out.comment} from:\n{self.out.comment} {paths}\n"

def write_provenance_header(self):
Expand Down Expand Up @@ -1614,7 +1609,14 @@ def wrap_macro(self, mac: MacroInstruction):

def prettify_filename(filename: str) -> str:
# Make filename more user-friendly and less platform-specific,
# it is only used for error reporting at this point.
# it is only used:
# 1. in a generated file header as a source reference
# 2. for error reporting
try:
filename = os.path.relpath(filename, ROOT)
except ValueError:
# May happen on Windows if root and temp on different volumes
pass
filename = filename.replace("\\", "/")
if filename.startswith("./"):
filename = filename[2:]
Expand Down