@@ -530,8 +530,9 @@ endfunction()
530
530
# Setup an "execute" test. In the case of multi-file tests, MAIN will be the
531
531
# main file. For multi-file tests, OTHERS will be the remaining files needed by
532
532
# the test. FFLAGS are additional compiler flags needed by the test. LDFLAGS
533
- # are the other linker flags needed by the test.
534
- function (gfortran_add_execute_test main others fflags ldflags )
533
+ # are the other linker flags needed by the test. If EXPECT_ERROR evaluates to
534
+ # true, the test is expected to fail.
535
+ function (gfortran_add_execute_test expect_error main others fflags ldflags )
535
536
# PREFIX_EXECUTE will have been defined in the subdirectory from which this
536
537
# function is called.
537
538
gfortran_unique_target_name ("${PREFIX_EXECUTE} " "${main} " target )
@@ -540,6 +541,20 @@ function(gfortran_add_execute_test main others fflags ldflags)
540
541
541
542
llvm_test_executable_no_test (${target} ${main} ${others} )
542
543
llvm_test_run (WORKDIR "%S/${working_dir_name} " )
544
+ # FIXME: All we need is to negate the exit code. LLVM's not utility can do
545
+ # this, but if it is not already installed on the system, it will have to be
546
+ # obtained from LLVM's build directory. It is not clear that we can rely on
547
+ # this when running the test suite.
548
+ if (WIN32 )
549
+ # Probably need to check %errorlevel% here.
550
+ message (FATAL_ERROR "Verification not implemented on Windows." )
551
+ else ()
552
+ if (expect_error )
553
+ llvm_test_verify (${TESTCMD} $? -ne 0 )
554
+ else ()
555
+ llvm_test_verify (${TESTCMD} $? -eq 0 )
556
+ endif ()
557
+ endif ()
543
558
llvm_add_test_for_target (${target} )
544
559
545
560
target_include_directories (${target}
@@ -576,6 +591,9 @@ function(gfortran_add_execute_tests_from tests)
576
591
cmake_parse_arguments (GFORTRAN "" "" "FFLAGS;LDFLAGS" ${ARGN} )
577
592
578
593
foreach (file ${tests} )
594
+ # Whether this test is expected to pass or fail.
595
+ set (expect_error OFF )
596
+
579
597
# The file containing the "run" directive will be the main file.
580
598
set (main "" )
581
599
@@ -611,13 +629,15 @@ function(gfortran_add_execute_tests_from tests)
611
629
separate_arguments (file_fflags UNIX_COMMAND ${CMAKE_MATCH_2} )
612
630
list (REMOVE_ITEM file_fflags ${FLANG_ERRORING_FFLAGS} )
613
631
list (APPEND fflags ${file_fflags} )
632
+ elseif (line MATCHES "[{][ ]*dg-shouldfail[ ]+(.*)[}]" )
633
+ set (expect_error ON )
614
634
endif ()
615
635
endforeach ()
616
636
617
637
# Since any dependent files could also be processed by this function, there
618
638
# is no guarantee that main will have been set.
619
639
if (main )
620
- gfortran_add_execute_test (${main} "${others} " "${fflags} " "${ldflags} " )
640
+ gfortran_add_execute_test (${expect_error} ${ main} "${others} " "${fflags} " "${ldflags} " )
621
641
endif ()
622
642
endforeach ()
623
643
endfunction ()
@@ -632,7 +652,7 @@ function(gfortran_add_execute_tests tests)
632
652
list (APPEND ldflags ${GFORTRAN_LDFLAGS} )
633
653
634
654
foreach (file ${tests} )
635
- gfortran_add_execute_test (${file} "" "${fflags} " "${ldflags} " )
655
+ gfortran_add_execute_test (OFF ${file} "" "${fflags} " "${ldflags} " )
636
656
endforeach ()
637
657
endfunction ()
638
658
0 commit comments