Revision 9990c068 htools/Ganeti/HTools/QC.hs

b/htools/Ganeti/HTools/QC.hs
56 56
import Test.QuickCheck
57 57
import Test.QuickCheck.Monadic (assert, monadicIO, run, stop)
58 58
import Text.Printf (printf)
59
import Data.List (intercalate, nub, isPrefixOf)
59
import Data.List (intercalate, nub, isPrefixOf, sort, (\\))
60 60
import Data.Maybe
61 61
import qualified Data.Set as Set
62 62
import Control.Monad
......
1617 1617
    J.Error e -> failTest $ "Cannot deserialise: " ++ e
1618 1618
    J.Ok op' -> op ==? op'
1619 1619

  
1620
-- | Check that Python and Haskell defined the same opcode list.
1621
case_OpCodes_AllDefined :: HUnit.Assertion
1622
case_OpCodes_AllDefined = do
1623
  py_stdout <- runPython "from ganeti import opcodes\n\
1624
                         \print '\\n'.join(opcodes.OP_MAPPING.keys())" "" >>=
1625
               checkPythonResult
1626
  let py_ops = sort $ lines py_stdout
1627
      hs_ops = OpCodes.allOpIDs
1628
      -- extra_py = py_ops \\ hs_ops
1629
      extra_hs = hs_ops \\ py_ops
1630
  -- FIXME: uncomment when we have parity
1631
  -- HUnit.assertBool ("OpCodes missing from Haskell code:\n" ++
1632
  --                  unlines extra_py) (null extra_py)
1633
  HUnit.assertBool ("Extra OpCodes in the Haskell code code:\n" ++
1634
                    unlines extra_hs) (null extra_hs)
1635

  
1620 1636
testSuite "OpCodes"
1621
            [ 'prop_OpCodes_serialization ]
1637
            [ 'prop_OpCodes_serialization
1638
            , 'case_OpCodes_AllDefined
1639
            ]
1622 1640

  
1623 1641
-- ** Jobs tests
1624 1642

  

Also available in: Unified diff