Revision a292b4e0
b/htools/Ganeti/HTools/QC.hs | ||
---|---|---|
75 | 75 |
import qualified Ganeti.HTools.Version |
76 | 76 |
import qualified Ganeti.Constants as C |
77 | 77 |
|
78 |
import qualified Ganeti.HTools.Program as Program |
|
78 | 79 |
import qualified Ganeti.HTools.Program.Hail |
79 | 80 |
import qualified Ganeti.HTools.Program.Hbal |
80 | 81 |
import qualified Ganeti.HTools.Program.Hscan |
... | ... | |
1511 | 1512 |
] |
1512 | 1513 |
in conjoin $ map (checkStringArg argument) args |
1513 | 1514 |
|
1515 |
-- | Helper to test that a given option is accepted OK with quick exit. |
|
1516 |
checkEarlyExit name options param = |
|
1517 |
case CLI.parseOptsInner [param] name options of |
|
1518 |
Left (code, _) -> if code == 0 |
|
1519 |
then property True |
|
1520 |
else failTest $ "Program " ++ name ++ |
|
1521 |
" returns invalid code " ++ show code ++ |
|
1522 |
" for option " ++ param |
|
1523 |
_ -> failTest $ "Program " ++ name ++ " doesn't consider option " ++ |
|
1524 |
param ++ " as early exit one" |
|
1525 |
|
|
1526 |
-- | Test that all binaries support some common options. There is |
|
1527 |
-- nothing actually random about this test... |
|
1528 |
prop_CLI_stdopts = |
|
1529 |
let params = ["-h", "--help", "-V", "--version"] |
|
1530 |
opts = map (\(name, (_, o)) -> (name, o)) Program.personalities |
|
1531 |
-- apply checkEarlyExit across the cartesian product of params and opts |
|
1532 |
in conjoin [checkEarlyExit n o p | p <- params, (n, o) <- opts] |
|
1533 |
|
|
1514 | 1534 |
testSuite "CLI" |
1515 | 1535 |
[ 'prop_CLI_parseISpec |
1516 | 1536 |
, 'prop_CLI_parseISpecFail |
1517 | 1537 |
, 'prop_CLI_parseYesNo |
1518 | 1538 |
, 'prop_CLI_StringArg |
1539 |
, 'prop_CLI_stdopts |
|
1519 | 1540 |
] |
Also available in: Unified diff