From a920f878b1ed8bf83520e0acaf2810514d00d89f Mon Sep 17 00:00:00 2001 From: Gereon Kremer Date: Tue, 31 Aug 2021 12:27:55 -0700 Subject: [PATCH] Make sure modes are sorted in ModeInfo (#7097) This PR ensures that the possible modes returned in getOptionInfo() are always sorted. Their order would depend on the python dictionary ordering, which changed with a somewhat recent python version and thereby breaks our tests. --- src/options/mkoptions.py | 2 +- test/unit/api/solver_black.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/options/mkoptions.py b/src/options/mkoptions.py index 41f2ef543..30c2fc1c3 100644 --- a/src/options/mkoptions.py +++ b/src/options/mkoptions.py @@ -806,7 +806,7 @@ def codegen_all_modules(modules, build_dir, dst_dir, tpls): elif option.type == 'double' or is_numeric_cpp_type(option.type): constr = 'OptionInfo::NumberInfo<{type}>{{{default}, {value}, {minimum}, {maximum}}}'.format(**fmt) elif option.mode: - values = ', '.join(map(lambda s: '"{}"'.format(s), option.mode.keys())) + values = ', '.join(map(lambda s: '"{}"'.format(s), sorted(option.mode.keys()))) assert(option.default) constr = 'OptionInfo::ModeInfo{{"{default}", {value}, {{ {modes} }}}}'.format(**fmt, modes=values) else: diff --git a/test/unit/api/solver_black.cpp b/test/unit/api/solver_black.cpp index df4b42ca6..1daa3fba4 100644 --- a/test/unit/api/solver_black.cpp +++ b/test/unit/api/solver_black.cpp @@ -1371,7 +1371,7 @@ TEST_F(TestApiBlackSolver, getOptionInfo) auto modeInfo = std::get(info.valueInfo); EXPECT_EQ("NONE", modeInfo.defaultValue); EXPECT_EQ("OutputTag::NONE", modeInfo.currentValue); - std::vector modes{"NONE", "INST", "SYGUS", "TRIGGER"}; + std::vector modes{"INST", "NONE", "SYGUS", "TRIGGER"}; EXPECT_EQ(modes, modeInfo.modes); } } -- 2.30.2