Skip to content

Commit

Permalink
Normalize windows path seperators.
Browse files Browse the repository at this point in the history
  • Loading branch information
aDotInTheVoid committed Dec 2, 2020
1 parent 6018200 commit d619271
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/test/rustdoc-json/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# The comparison is independent of the value of IDs (which are unstable) and instead uses their
# relative ordering to check them against eachother by looking them up in their respective blob's
# `index` or `paths` mappings. To add a new test run `rustdoc --output-format json -o . yourtest.rs`
# and then create `yourtest.expected` by stripping unnecessary details from `yourtest.json`.
# and then create `yourtest.expected` by stripping unnecessary details from `yourtest.json`. If
# you're on windows, replace `\` with `/`.

import copy
import sys
Expand Down Expand Up @@ -36,7 +37,7 @@ def _check_subset(expected, actual, trace):
actual_type = type(actual)

if actual_type is str:
actual = actual.replace(base_dir, "$TEST_BASE_DIR")
actual = normalize(actual).replace(base_dir, "$TEST_BASE_DIR")

if expected_type is not actual_type:
raise SubsetException(
Expand Down Expand Up @@ -118,9 +119,11 @@ def main(expected_fpath, actual_fpath, base_dir):
check_subset(expected_main, actual_main, base_dir)
print("all checks passed")

def normalize(s):
return s.replace('\\', '/')

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

0 comments on commit d619271

Please sign in to comment.