Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testing 水果测试_Testing_Cmake_Fortran - Fatal编程技术网

Testing 水果测试

Testing 水果测试,testing,cmake,fortran,Testing,Cmake,Fortran,我有一个使用fruit进行测试的项目(fortran代码)。 这是我的密码 计算器.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

我有一个使用fruit进行测试的项目(fortran代码)。 这是我的密码

计算器.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
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
和我的测试计算器测试.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
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
现在我想使用Cmake来构建和运行我的测试(由jenkins触发),所以我的问题是:我是否需要更改测试,或者是否可以只运行我通过Cmake编写的测试,如果需要,如何更改? 我在网上搜索了很多,但是所有的CGED测试似乎都是用C++完成的,然后是使用可执行的TestFrm文件。 谢谢!
-Minde

您可以按原样运行您编写的测试,您只需要告诉CMake如何运行它们。这就是
ADD\u TEST
命令
参数的作用

ENABLE_TESTING()
ADD_TEST(NAME "YourTest" 
    WORKING_DIRECTORY ${TEST_DIRECTORY}
    COMMAND ${TEST_DIRECTORY}/test_dim)

通常,你会看到一些类似上面的例子,其中命令是可执行的(正如你在C++示例中看到的)。但也不一定是这样。例如,我通过CMake运行python测试,并添加如下测试:

ADD_TEST(NAME PythonTests 
    WORKING_DIRECTORY ${TEST_DIRECTORY}
    COMMAND ${PYTHON_EXECUTABLE} setup.py test
因此,要运行您的水果测试,您需要调用为您创建水果测试运行程序的命令(我相信这是一个
rake
命令……我将在下面假设这是正确的,但您应该替换在命令行上实际调用的任何命令来运行测试):

当您在命令行上运行
maketest
时,它应该告诉您“foulttests”是否失败或成功


注意事项CMake通过程序的退出代码决定测试的成功或失败。默认情况下,Fortran程序没有退出代码(如果有,则始终为0)。当我使用Fruit和CMake进行Fortran测试时,我自己编写测试运行程序,并使用
调用exit(exit_code)
内置子例程确保将退出代码返回到CMake。我不确定Fruit的自动测试运行器创建者是否做到了这一点;您必须亲自验证这一点

我已经回答了下面的问题,假设你已经知道CMake。如果没有,让我知道,我可以添加一些细节,让你开始。如果回答不够清楚,请在您的问题中添加一些细节,以便更清楚地了解您在CMake中需要做什么。我的印象是,我必须在“add_test”命令中使用可执行的命令,因此这是正确的。非常感谢。