1# test that help request doesn't fail
2# also checks acceptance of debug and verbose options
3# and an option that shouldn't be implemented anywhere
4
5# help alone
6
7execute_process(COMMAND ${TEST_PROG} -h
8                OUTPUT_QUIET
9                ERROR_QUIET
10                RESULT_VARIABLE HAD_ERROR)
11if(HAD_ERROR)
12    message(FATAL_ERROR "Test failed with short help option")
13endif()
14
15execute_process(COMMAND ${TEST_PROG} --help
16                OUTPUT_QUIET
17                ERROR_QUIET
18                RESULT_VARIABLE HAD_ERROR)
19if(HAD_ERROR)
20    message(FATAL_ERROR "Test failed with long help option")
21endif()
22
23# help and debug
24
25execute_process(COMMAND ${TEST_PROG} -h -d
26                OUTPUT_QUIET
27                ERROR_QUIET
28                RESULT_VARIABLE HAD_ERROR)
29if(HAD_ERROR)
30    message(FATAL_ERROR "Test failed with short debug option")
31endif()
32
33execute_process(COMMAND ${TEST_PROG} -h -ddd
34                OUTPUT_QUIET
35                ERROR_QUIET
36                RESULT_VARIABLE HAD_ERROR)
37if(HAD_ERROR)
38    message(FATAL_ERROR "Test failed with multiple short debug options")
39endif()
40
41# help and long debug
42
43execute_process(COMMAND ${TEST_PROG} -h --debug
44                OUTPUT_QUIET
45                ERROR_QUIET
46                RESULT_VARIABLE HAD_ERROR)
47if(HAD_ERROR)
48    message(FATAL_ERROR "Test failed with long debug option")
49endif()
50
51execute_process(COMMAND ${TEST_PROG} -h --debug --debug --debug
52                OUTPUT_QUIET
53                ERROR_QUIET
54                RESULT_VARIABLE HAD_ERROR)
55if(HAD_ERROR)
56    message(FATAL_ERROR "Test failed with multiple long debug options")
57endif()
58
59# help and verbose
60
61execute_process(COMMAND ${TEST_PROG} -h -v
62                OUTPUT_QUIET
63                ERROR_QUIET
64                RESULT_VARIABLE HAD_ERROR)
65if(HAD_ERROR)
66    message(FATAL_ERROR "Test failed with short verbose option")
67endif()
68
69execute_process(COMMAND ${TEST_PROG} -h -vvv
70                OUTPUT_QUIET
71                ERROR_QUIET
72                RESULT_VARIABLE HAD_ERROR)
73if(HAD_ERROR)
74    message(FATAL_ERROR "Test failed with multiple short verbose options")
75endif()
76
77# help and long verbose
78
79execute_process(COMMAND ${TEST_PROG} -h --verbose
80                OUTPUT_QUIET
81                ERROR_QUIET
82                RESULT_VARIABLE HAD_ERROR)
83if(HAD_ERROR)
84    message(FATAL_ERROR "Test failed with long verbose option")
85endif()
86
87execute_process(COMMAND ${TEST_PROG} -h --verbose --verbose --verbose
88                OUTPUT_QUIET
89                ERROR_QUIET
90                RESULT_VARIABLE HAD_ERROR)
91if(HAD_ERROR)
92    message(FATAL_ERROR "Test failed with multiple long verbose options")
93endif()
94
95# unimplemented option
96
97#execute_process(COMMAND ${TEST_PROG} --whyUimplementDis
98#                OUTPUT_QUIET
99#                ERROR_QUIET
100#                RESULT_VARIABLE HAD_ERROR)
101#message(STATUS "${TEST_PROG} returned ${HAD_ERROR}")
102#if(HAD_ERROR EQUAL 0)
103#    message(FATAL_ERROR "Test failed with undefined option")
104#endif()
105