-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #275 from Goddard-Fortran-Ecosystem/hotfix/add-pfu…
…nit-ctest-fix Fixed problems with add_pfunit_ctest() macro
- Loading branch information
Showing
4 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
!--------------------------------------------------------------------------- | ||
! This file is external to the pfunit library and is used to represent | ||
! information that cannot be determined at run-time. In particular, | ||
! Fortran lacks reflection/introspection and therefore cannot automatically | ||
! collect user-defined test suites. | ||
! | ||
! | ||
! Typical usage is for the user to compile this file while leaving it in the | ||
! pFUnit installation directory. Use "-D<_TEST_SUITES>" to specify a file | ||
! that contains the list of test_suites to be builtlinked and executed. | ||
! | ||
! | ||
! For serial runs, the user links with the FUnit library, while for parallel | ||
! runs the user links with FUnit _and_ pFUnit. | ||
!--------------------------------------------------------------------------- | ||
|
||
#cmakedefine PFUNIT_EXTRA_USE @PFUNIT_EXTRA_USE@ | ||
module loader | ||
use FUnit, only: TestSuite | ||
implicit none | ||
|
||
contains | ||
|
||
function load_tests() result(suite) | ||
|
||
#define ADDULE_TEST_SUITE(m,s) use m, only: s | ||
#define ADD_TEST_SUITE(s) ! do nothing | ||
#include _TEST_SUITES | ||
#undef ADDULE_TEST_SUITE | ||
#undef ADD_TEST_SUITE | ||
|
||
type (TestSuite) :: suite | ||
|
||
#define ADDULE_TEST_SUITE(m,s) ! do nothing | ||
#define ADD_TEST_SUITE(s) type (TestSuite), external :: s | ||
# include _TEST_SUITES | ||
#undef ADD_TEST_SUITE | ||
#undef ADDULE_TEST_SUITE | ||
|
||
suite = TestSuite() | ||
|
||
#define ADD_TEST_SUITE(s) call suite%addTest(s()) | ||
#define ADDULE_TEST_SUITE(m,s) call suite%addTest(s()) | ||
# include _TEST_SUITES | ||
#undef ADD_TEST_SUITE | ||
#undef ADDULE_TEST_SUITE | ||
|
||
end function load_tests | ||
|
||
end module loader | ||
|
||
program main | ||
use FUnit, only : stub | ||
use loader | ||
#ifdef PFUNIT_EXTRA_USE | ||
! Use external code for whatever suite-wide fixture is in use. | ||
use @PFUNIT_EXTRA_USE@ | ||
#endif | ||
implicit none | ||
|
||
procedure(), pointer :: extra_initialize | ||
procedure(), pointer :: extra_finalize | ||
|
||
#ifdef PFUNIT_EXTRA_INITIALIZE | ||
# ifndef PFUNIT_EXTRA_USE | ||
external :: PFUNIT_EXTRA_INITIALIZE | ||
# endif | ||
extra_initialize => PFUNIT_EXTRA_INITIALIZE | ||
#else | ||
extra_initialize => stub | ||
#endif | ||
|
||
#ifdef PFUNIT_EXTRA_FINALIZE | ||
# ifndef PFUNIT_EXTRA_USE | ||
external :: PFUNIT_EXTRA_FINALIZE | ||
# endif | ||
extra_finalize => PFUNIT_EXTRA_FINALIZE | ||
#else | ||
extra_finalize => stub | ||
#endif | ||
|
||
call funit_main(load_tests, extra_initialize, extra_finalize) | ||
|
||
end program main |