MCPcopy Create free account
hub / github.com/catchorg/Catch2 / normalizeFilepath

Function normalizeFilepath

tools/scripts/approvalTests.py:96–116  ·  view source on GitHub ↗
(line)

Source from the content-addressed store, hash-verified

94
95
96def normalizeFilepath(line):
97 # Sometimes the path separators used by compiler and Python can differ,
98 # so we try to match the path with both forward and backward path
99 # separators, to make the paths relative to Catch2 repo root.
100 forwardSlashPath = catchPath.replace('\\', '/')
101 if forwardSlashPath in line:
102 line = line.replace(forwardSlashPath + '/', '')
103 backwardSlashPath = catchPath.replace('/', '\\')
104 if backwardSlashPath in line:
105 line = line.replace(backwardSlashPath + '\\', '')
106
107 m = langFilenameParser.match(line)
108 if m:
109 filepath = m.group(0)
110 # go from \ in windows paths to /
111 filepath = filepath.replace('\\', '/')
112 # remove start of relative path
113 filepath = filepath.replace('../', '')
114 line = line[:m.start()] + filepath + line[m.end():]
115
116 return line
117
118def filterLine(line, isCompact):
119 line = normalizeFilepath(line)

Callers 1

filterLineFunction · 0.85

Calls 3

matchMethod · 0.45
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected