Revision d31193c3

b/autotools/convert-constants
30 30
from ganeti import constants
31 31
from ganeti import errors
32 32
from ganeti import luxi
33
from ganeti import opcodes
34 33
from ganeti import qlang
35 34
from ganeti import jstore
36 35

  
......
300 299
  return "\n".join(lines)
301 300

  
302 301

  
303
def ConvertMisc():
304
  """Convert some extra computed-values to Haskell.
305

  
306
  """
307
  lines = [""]
308
  lines.extend(ConvertVariable("opcodes", "OP_IDS",
309
                               opcodes.OP_MAPPING.keys(), {}))
310
  return "\n".join(lines)
311

  
312

  
313 302
def main():
314 303
  print Convert(constants, "")
315 304
  print Convert(luxi, "luxi")
......
317 306
  print Convert(_autoconf, "autoconf")
318 307
  print Convert(errors, "errors")
319 308
  print Convert(jstore, "jstore")
320
  print ConvertMisc()
321 309

  
322 310

  
323 311
if __name__ == "__main__":
b/test/hs/Test/Ganeti/OpCodes.hs
441 441
-- | Check that Python and Haskell defined the same opcode list.
442 442
case_AllDefined :: HUnit.Assertion
443 443
case_AllDefined = do
444
  let py_ops = sort C.opcodesOpIds
445
      hs_ops = sort OpCodes.allOpIDs
444
  py_stdout <-
445
     runPython "from ganeti import opcodes\n\
446
               \from ganeti import serializer\n\
447
               \import sys\n\
448
               \print serializer.Dump([opid for opid in opcodes.OP_MAPPING])\n" ""
449
     >>= checkPythonResult
450
  py_ops <- case J.decode py_stdout::J.Result [String] of
451
               J.Ok ops -> return ops
452
               J.Error msg ->
453
                 HUnit.assertFailure ("Unable to decode opcode names: " ++ msg)
454
                 -- this already raised an expection, but we need it
455
                 -- for proper types
456
                 >> fail "Unable to decode opcode names"
457
  let hs_ops = sort OpCodes.allOpIDs
446 458
      extra_py = py_ops \\ hs_ops
447 459
      extra_hs = hs_ops \\ py_ops
448 460
  HUnit.assertBool ("Missing OpCodes from the Haskell code:\n" ++

Also available in: Unified diff