Skip to content

Commit d619271

Browse files
committed
Normalize windows path seperators.
1 parent 6018200 commit d619271

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/test/rustdoc-json/compare.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# The comparison is independent of the value of IDs (which are unstable) and instead uses their
55
# relative ordering to check them against eachother by looking them up in their respective blob's
66
# `index` or `paths` mappings. To add a new test run `rustdoc --output-format json -o . yourtest.rs`
7-
# and then create `yourtest.expected` by stripping unnecessary details from `yourtest.json`.
7+
# and then create `yourtest.expected` by stripping unnecessary details from `yourtest.json`. If
8+
# you're on windows, replace `\` with `/`.
89

910
import copy
1011
import sys
@@ -36,7 +37,7 @@ def _check_subset(expected, actual, trace):
3637
actual_type = type(actual)
3738

3839
if actual_type is str:
39-
actual = actual.replace(base_dir, "$TEST_BASE_DIR")
40+
actual = normalize(actual).replace(base_dir, "$TEST_BASE_DIR")
4041

4142
if expected_type is not actual_type:
4243
raise SubsetException(
@@ -118,9 +119,11 @@ def main(expected_fpath, actual_fpath, base_dir):
118119
check_subset(expected_main, actual_main, base_dir)
119120
print("all checks passed")
120121

122+
def normalize(s):
123+
return s.replace('\\', '/')
121124

122125
if __name__ == "__main__":
123126
if len(sys.argv) < 4:
124127
print("Usage: `compare.py expected.json actual.json test-dir`")
125128
else:
126-
main(sys.argv[1], sys.argv[2], sys.argv[3])
129+
main(sys.argv[1], sys.argv[2], normalize(sys.argv[3]))

0 commit comments

Comments
 (0)