summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGereon Kremer <nafur42@gmail.com>2021-08-31 12:27:55 -0700
committerGitHub <noreply@github.com>2021-08-31 19:27:55 +0000
commita920f878b1ed8bf83520e0acaf2810514d00d89f (patch)
tree87168951726de29082901b9bce0fa9111b30d14e
parent70baef755ad939040c9a670da224512eb076f61b (diff)
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.
-rw-r--r--src/options/mkoptions.py2
-rw-r--r--test/unit/api/solver_black.cpp2
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<OptionInfo::ModeInfo>(info.valueInfo);
EXPECT_EQ("NONE", modeInfo.defaultValue);
EXPECT_EQ("OutputTag::NONE", modeInfo.currentValue);
- std::vector<std::string> modes{"NONE", "INST", "SYGUS", "TRIGGER"};
+ std::vector<std::string> modes{"INST", "NONE", "SYGUS", "TRIGGER"};
EXPECT_EQ(modes, modeInfo.modes);
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback