|
| 1 | +module command_line_test |
| 2 | + !! Verify object pattern asbtract parent |
| 3 | + use test_m, only : test_t, test_result_t |
| 4 | + use command_line_m, only : command_line_t |
| 5 | + implicit none |
| 6 | + |
| 7 | + private |
| 8 | + public :: command_line_test_t |
| 9 | + |
| 10 | + type, extends(test_t) :: command_line_test_t |
| 11 | + contains |
| 12 | + procedure, nopass :: subject |
| 13 | + procedure, nopass :: results |
| 14 | + end type |
| 15 | + |
| 16 | +contains |
| 17 | + |
| 18 | + pure function subject() result(specimen) |
| 19 | + character(len=:), allocatable :: specimen |
| 20 | + specimen = "The command_line_t type" |
| 21 | + end function |
| 22 | + |
| 23 | + function results() result(test_results) |
| 24 | + type(test_result_t), allocatable :: test_results(:) |
| 25 | + |
| 26 | + test_results = [ & |
| 27 | + test_result_t("returning the value passed after a command-line flag", check_flag_value()) & |
| 28 | + ] |
| 29 | + end function |
| 30 | + |
| 31 | + function check_flag_value() result(test_passes) |
| 32 | + logical test_passes |
| 33 | + |
| 34 | + integer exit_status, command_status |
| 35 | + character(len=132) command_message |
| 36 | + |
| 37 | + call execute_command_line( & |
| 38 | + command = "fpm run --example get-flag-value -- --input-file foo > /dev/null 2>&1", & |
| 39 | + wait = .true., exitstat = exit_status, cmdstat = command_status, cmdmsg = command_message & |
| 40 | + ) |
| 41 | + test_passes = exit_status == 0 |
| 42 | + |
| 43 | + end function |
| 44 | + |
| 45 | +end module command_line_test |
0 commit comments