Skip to content

Commit

Permalink
Fix various build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aradi committed Aug 16, 2024
1 parent fc47602 commit ab39c4f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 26 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ jobs:
if: ${{ contains(matrix.compiler, 'intel') }}
uses: rscohn2/setup-oneapi@v0
with:
components: ifx
# Note: intel 2024.1 and 2024.2 fail to build Fortuno properly due to a compiler bug,
# see https://community.intel.com/t5/Intel-Fortran-Compiler/Compiler-bug-Procedure-pointer-association-status-gets-lost/m-p/1612121#M172850
components: ifx@2024.0.0

- name: Setup Intel environment
if: ${{ contains(matrix.compiler, 'intel') }}
Expand Down
17 changes: 10 additions & 7 deletions include/fortuno_serial.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#:set _FORTUNO_SERIAL_FYPP_

#! Internal variable storing registered test items
#:set _fortuno_registered_tests = {}
#:set _fortuno_constructed_tests = set()
#:set _fortuno_serial_registered_tests = {}
#:set _fortuno_serial_constructed_tests = set()


#! Imports the prerequisites needed by the macro definitions in this file
Expand All @@ -27,7 +27,7 @@
#:def TEST(name, label="", args=None)
#:set proc = "test" + ("_" + label if label else "") + "_" + name
#:set argstr = ", ".join(args) if args is not None else ""
$:_fortuno_registered_tests.setdefault(label, []).append({"name": name, "proc": proc})
$:_fortuno_serial_registered_tests.setdefault(label, []).append({"name": name, "proc": proc})
subroutine ${proc}$(${argstr}$)
#:enddef

Expand All @@ -46,8 +46,11 @@
#! constructor: Name of the constructor to use (default: "test")
#!
#:def TEST_ITEMS(label="", suffix="", constructor="serial_case_item ")
#:set items = _fortuno_registered_tests[label]
$:_fortuno_constructed_tests.update(set([(label, item['name']) for item in items]))
#:set items = _fortuno_serial_registered_tests.get(label)
#:if items is None
#:stop "Undefined label ('{}') used in TEST_ITEMS()".format(label)
#:endif
$:_fortuno_serial_constructed_tests.update(set([(label, item['name']) for item in items]))
#:set calls = [f"{constructor}('{item['name']}', {item['proc']})" for item in items]
#:set lines = " " + ",&\n ".join(calls) + suffix + "&\n"
$:lines
Expand Down Expand Up @@ -86,12 +89,12 @@ if (serial_failed()) return
#!
#:def STOP_ON_MISSING_TEST_ITEMS()
#:set _all_items = set()
#:for label, items in _fortuno_registered_tests.items()
#:for label, items in _fortuno_serial_registered_tests.items()
#:for item in items
$:_all_items.add((label, item['name']))
#:endfor
#:endfor
#:set _uninst = set(_all_items) - _fortuno_constructed_tests
#:set _uninst = set(_all_items) - _fortuno_serial_constructed_tests
#:if _uninst
#:set _uninst_list = [(label + "/" + name if label else name) for label, name in _uninst]
#:set _uninst_str = ", ".join(_uninst_list)
Expand Down
36 changes: 27 additions & 9 deletions test/export/app/testapp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,40 @@
! Licensed under the BSD-2-Clause Plus Patent license.
! SPDX-License-Identifier: BSD-2-Clause-Patent

!> Test app driving Fortuno unit tests
program testapp
use fortuno_serial, only : execute_serial_cmd_app, is_equal, test => serial_case_item,&
check => serial_check
!> Unit tests
module testapp_tests
use fortuno_serial, only : is_equal, test => serial_case_item, check => serial_check, test_item
implicit none

call execute_serial_cmd_app(&
testitems=[&
test("success", test_success)&
]&
)
private
public :: test_items

contains


subroutine test_success()
call check(is_equal(1, 1))
end subroutine test_success


function test_items() result(testitems)
type(test_item), allocatable :: testitems(:)

testitems = [&
test("success", test_success)&
]

end function test_items

end module testapp_tests


!> Test app driving Fortuno unit tests
program testapp
use testapp_tests, only : test_items
use fortuno_serial, only : execute_serial_cmd_app
implicit none

call execute_serial_cmd_app(testitems=test_items())

end program testapp
25 changes: 16 additions & 9 deletions test/export/app/testapp_fypp.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@

#:include "fortuno_serial.fypp"

!> Test app driving Fortuno unit tests
program testapp_fypp
use fortuno_serial, only : execute_serial_cmd_app, is_equal, test_item
!> Unit tests
module testapp_fypp_tests
use fortuno_serial, only : is_equal, test_item
$:FORTUNO_SERIAL_IMPORTS()
implicit none

call execute_serial_cmd_app(&
testitems=[&
test_items()&
]&
)
private
public :: test_items

contains


$:TEST("success")
@:CHECK(is_equal(1, 1))
$:END_TEST()
Expand All @@ -33,4 +29,15 @@ contains

end function test_items

end module testapp_fypp_tests


!> Test app driving Fortuno unit tests
program testapp_fypp
use testapp_fypp_tests, only : test_items
use fortuno_serial, only : execute_serial_cmd_app
implicit none

call execute_serial_cmd_app(testitems=test_items())

end program testapp_fypp

0 comments on commit ab39c4f

Please sign in to comment.