testing - Cmake with fruit tests -


i have project uses fruit testing (fortran code). code.

calculator.f90

module calculator    implicit none    contains    subroutine add (a, b, output)        integer, intent(in) :: a, b        integer, intent(out):: output        output = a+b    end subroutine add end module calculator 

and test calculator_test.f90

module calculator_test    use fruit    contains    subroutine test_5_2_2       use calculator, only: add       integer :: result       call add(2,2,result)       call assertequals(4,result)    end subroutine test_5_2_2     subroutine test_5_2_3       use calculator, only: add       integer :: result       call add(2,3,result)       call assertequals(5,result)    end subroutine test_5_2_3 end module 

now i'd use cmake build , run tests (triggered jenkins), question is: need change tests or possible run test i've written through cmake, , if how? i've searched lot online testing cmake seems done c++ , using executeable testfiles files.

thanks! -minde

you can run tests have written is, need tell cmake how run them. command argument add_test for.

enable_testing() add_test(name "yourtest"      working_directory ${test_directory}     command ${test_directory}/test_dim) 

usually, see example 1 above, command executable (as have seen in c++ examples). doesn't have be. example, running python tests through cmake, , add test so:

add_test(name pythontests      working_directory ${test_directory}     command ${python_executable} setup.py test 

so, run fruit tests, call command creates fruit test runner (i believe rake command... assume true below, should substitute whatever call on command line run tests):

add_test(name fruittests      working_directory ${test_directory}     command rake test) # or whatever command is. 

when run make test on command line, should tell if "fruittests" failed or succeeded.

a word of caution cmake determines success or failure of test exit code of program. default fortran programs not have exit code (or if do, 0). when use fruit , cmake fortran tests, write test runner myself , use call exit(exit_code) builtin subroutine make sure exit code returned cmake. not sure if fruit's automatic test runner creator this; have verify yourself.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -