From 340f47b9cb982eb84f9dca7cf210a8b4ed5986c3 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 1 Jun 2015 15:49:13 +0200 Subject: [PATCH] add unit test for a simple fortran project --- test/fortran/cmake/autocmake.cfg | 7 +++++++ test/fortran/src/CMakeLists.txt | 1 + test/fortran/src/example.f90 | 4 ++++ test/test.py | 14 ++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 test/fortran/cmake/autocmake.cfg create mode 100644 test/fortran/src/CMakeLists.txt create mode 100644 test/fortran/src/example.f90 diff --git a/test/fortran/cmake/autocmake.cfg b/test/fortran/cmake/autocmake.cfg new file mode 100644 index 0000000..d4a5909 --- /dev/null +++ b/test/fortran/cmake/autocmake.cfg @@ -0,0 +1,7 @@ +[project] +name: example + +[fortran] +source: https://github.com/scisoft/autocmake/raw/master/modules/UseFortran.cmake +docopt: --fc= Fortran compiler [default: gfortran]. +export: 'FC=%s' % arguments['--fc'] diff --git a/test/fortran/src/CMakeLists.txt b/test/fortran/src/CMakeLists.txt new file mode 100644 index 0000000..f6a0177 --- /dev/null +++ b/test/fortran/src/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(example example.f90) diff --git a/test/fortran/src/example.f90 b/test/fortran/src/example.f90 new file mode 100644 index 0000000..064acbc --- /dev/null +++ b/test/fortran/src/example.f90 @@ -0,0 +1,4 @@ +program example + implicit none + print *, 'Hello World!' +end program diff --git a/test/test.py b/test/test.py index 3107519..f9648d2 100644 --- a/test/test.py +++ b/test/test.py @@ -24,3 +24,17 @@ def test_cxx(): stdout, stderr = exe('make') stdout, stderr = exe('./bin/example') assert 'Hello World!' in stdout + +#------------------------------------------------------------------------------- + +def test_fortran(): + os.chdir(os.path.join(HERE, 'fortran', 'cmake')) + stdout, stderr = exe('wget https://github.com/scisoft/autocmake/raw/master/bootstrap.py') + stdout, stderr = exe('python bootstrap.py --update') + stdout, stderr = exe('python bootstrap.py ..') + os.chdir(os.path.join(HERE, 'fortran')) + stdout, stderr = exe('python setup.py --fc=gfortran') + os.chdir(os.path.join(HERE, 'fortran', 'build')) + stdout, stderr = exe('make') + stdout, stderr = exe('./bin/example') + assert 'Hello World!' in stdout