@@ -29,16 +29,19 @@ function results() result(test_results)
2929#ifndef __GFORTRAN__
3030 test_descriptions = [ &
3131 test_description_t(string_t(" returning the value passed after a command-line flag" ), check_flag_value), &
32- test_description_t(string_t(" returning an empty string when a flag value is missing" ), handle_missing_flag_value) &
32+ test_description_t(string_t(" returning an empty string when a flag value is missing" ), handle_missing_flag_value), &
33+ test_description_t(string_t(" detecting a present command-line argument" ), check_command_line_argument) &
3334 ]
3435#else
3536 ! Work around missing Fortran 2008 feature: associating a procedure actual argument with a procedure pointer dummy argument:
36- procedure (test_function_i), pointer :: check_flag_ptr, handle_missing_value_ptr
37+ procedure (test_function_i), pointer :: check_flag_ptr, handle_missing_value_ptr, check_command_ptr
3738 check_flag_ptr = > check_flag_value
3839 handle_missing_value_ptr = > handle_missing_flag_value
40+ check_command_ptr = > check_command_line_argument
3941 test_descriptions = [ &
4042 test_description_t(string_t(" returning the value passed after a command-line flag" ), check_flag_ptr), &
41- test_description_t(string_t(" returning an empty string when a flag value is missing" ), handle_missing_value_ptr) &
43+ test_description_t(string_t(" returning an empty string when a flag value is missing" ), handle_missing_value_ptr), &
44+ test_description_t(string_t(" detecting a present command-line argument" ), check_command_ptr) &
4245 ]
4346#endif
4447 test_descriptions = pack (test_descriptions, &
@@ -71,4 +74,16 @@ function handle_missing_flag_value() result(test_passes)
7174 test_passes = exit_status == 0
7275 end function
7376
77+ function check_command_line_argument () result(test_passes)
78+ logical test_passes
79+ integer exit_status, command_status
80+ character (len= 132 ) command_message
81+
82+ call execute_command_line( &
83+ command = " fpm run --example check-command-line-argument -- --some-argument" , &
84+ wait = .true. , exitstat = exit_status, cmdstat = command_status, cmdmsg = command_message &
85+ )
86+ test_passes = exit_status == 0
87+ end function
88+
7489end module command_line_test_m
0 commit comments