diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-01-23 23:47:03 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2020-01-24 02:53:34 +0530 |
commit | e99e7424547f96d0e41416e13702a642a152f2fe (patch) | |
tree | 80a432923c46c2b587e7bfa87a256a50f6674622 | |
parent | a78f90c3f8c6eb17d70b02636ebd2cb878cb3198 (diff) | |
download | meson-e99e7424547f96d0e41416e13702a642a152f2fe.zip meson-e99e7424547f96d0e41416e13702a642a152f2fe.tar.gz meson-e99e7424547f96d0e41416e13702a642a152f2fe.tar.bz2 |
summary: Ensure that output is deterministic
Use OrderedDict instead of dict() to ensure that the order is the same
every time, and change the unit test to check for that.
-rwxr-xr-x | run_unittests.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/run_unittests.py b/run_unittests.py index d6d5208..9008f17 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -4219,13 +4219,20 @@ recommended as it is not supported on some platforms''') A number: 1 yes: YES no: NO + + Subprojects + sub: YES + sub2: NO ''') - # Dict ordering is not guaranteed and an exact string comparison randomly - # fails on the CI because lines are reordered. expected_lines = expected.split('\n')[1:] out_start = out.find(expected_lines[0]) out_lines = out[out_start:].split('\n')[:len(expected_lines)] - self.assertEqual(sorted(expected_lines), sorted(out_lines)) + if sys.version_info < (3, 7, 0): + # Dictionary order is not stable in Python <3.7, so sort the lines + # while comparing + self.assertEqual(sorted(expected_lines), sorted(out_lines)) + else: + self.assertEqual(expected_lines, out_lines) class FailureTests(BasePlatformTests): |