diff --git a/autotools/convert-constants b/autotools/convert-constants index e61a72336fa5db1d1c70f1e07c94a0b7ba762b8a..da04968d0c3e362051a2a051ccb05aa183f3f2b6 100755 --- a/autotools/convert-constants +++ b/autotools/convert-constants @@ -30,6 +30,7 @@ from ganeti import compat from ganeti import constants from ganeti import errors from ganeti import luxi +from ganeti import opcodes from ganeti import qlang @@ -296,12 +297,23 @@ def Convert(module, prefix): return "\n".join(lines) +def ConvertMisc(): + """Convert some extra computed-values to Haskell. + + """ + lines = [""] + lines.extend(ConvertVariable("opcodes", "OP_IDS", + opcodes.OP_MAPPING.keys(), {})) + return "\n".join(lines) + + def main(): print Convert(constants, "") print Convert(luxi, "luxi") print Convert(qlang, "qlang") print Convert(_autoconf, "autoconf") print Convert(errors, "errors") + print ConvertMisc() if __name__ == "__main__": diff --git a/htest/Test/Ganeti/OpCodes.hs b/htest/Test/Ganeti/OpCodes.hs index c18cfa82e4464a5649db96cedb057c15d5325edd..7c2c2a0259d3e5cd9c9707d9c84d417f7009dcb0 100644 --- a/htest/Test/Ganeti/OpCodes.hs +++ b/htest/Test/Ganeti/OpCodes.hs @@ -410,16 +410,12 @@ prop_serialization = testSerialisation -- | Check that Python and Haskell defined the same opcode list. case_AllDefined :: HUnit.Assertion case_AllDefined = do - py_stdout <- runPython "from ganeti import opcodes\n\ - \print '\\n'.join(opcodes.OP_MAPPING.keys())" "" >>= - checkPythonResult - let py_ops = sort $ lines py_stdout - hs_ops = OpCodes.allOpIDs - -- extra_py = py_ops \\ hs_ops + let py_ops = sort C.opcodesOpIds + hs_ops = sort OpCodes.allOpIDs + extra_py = py_ops \\ hs_ops extra_hs = hs_ops \\ py_ops - -- FIXME: uncomment when we have parity - -- HUnit.assertBool ("OpCodes missing from Haskell code:\n" ++ - -- unlines extra_py) (null extra_py) + HUnit.assertBool ("Missing OpCodes from the Haskell code:\n" ++ + unlines extra_py) (null extra_py) HUnit.assertBool ("Extra OpCodes in the Haskell code code:\n" ++ unlines extra_hs) (null extra_hs)