|
4 | 4 | # The comparison is independent of the value of IDs (which are unstable) and instead uses their
|
5 | 5 | # relative ordering to check them against eachother by looking them up in their respective blob's
|
6 | 6 | # `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 `/`. |
8 | 9 |
|
9 | 10 | import copy
|
10 | 11 | import sys
|
@@ -36,7 +37,7 @@ def _check_subset(expected, actual, trace):
|
36 | 37 | actual_type = type(actual)
|
37 | 38 |
|
38 | 39 | if actual_type is str:
|
39 |
| - actual = actual.replace(base_dir, "$TEST_BASE_DIR") |
| 40 | + actual = normalize(actual).replace(base_dir, "$TEST_BASE_DIR") |
40 | 41 |
|
41 | 42 | if expected_type is not actual_type:
|
42 | 43 | raise SubsetException(
|
@@ -118,9 +119,11 @@ def main(expected_fpath, actual_fpath, base_dir):
|
118 | 119 | check_subset(expected_main, actual_main, base_dir)
|
119 | 120 | print("all checks passed")
|
120 | 121 |
|
| 122 | +def normalize(s): |
| 123 | + return s.replace('\\', '/') |
121 | 124 |
|
122 | 125 | if __name__ == "__main__":
|
123 | 126 | if len(sys.argv) < 4:
|
124 | 127 | print("Usage: `compare.py expected.json actual.json test-dir`")
|
125 | 128 | 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