From: Gereon Kremer Date: Tue, 31 Aug 2021 19:27:55 +0000 (-0700) Subject: Make sure modes are sorted in ModeInfo (#7097) X-Git-Tag: cvc5-1.0.0~1313 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a920f878b1ed8bf83520e0acaf2810514d00d89f;p=cvc5.git 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. --- 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); } }