Skip to content

Feature: detect and handle compiler issues in the test suite #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ test description.
1. finalizes a non-allocatable object on the LHS of an intrinsic assignment
2. finalizes an allocated allocatable LHS of an intrinsic assignment
3. finalizes a function reference on the RHS of an intrinsic assignment
4. finalizes a function reference on the RHS of an intrinsic assignment
5. finalizes a specification expression function result
4. finalizes a specification expression function result

### Failing checks in `usage_test.f90`
1. copy points to the same resource as the original
Expand Down
32 changes: 27 additions & 5 deletions test/compiler_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module compiler_test
!! standard mandates type finalization.
use for_use_in_spec_expr_m, only: finalizable_t, component, was_finalized
use veggies, only: result_t, test_item_t, describe, it, assert_equals, assert_that
use iso_fortran_env, only : compiler_version
implicit none

private
Expand Down Expand Up @@ -200,15 +201,36 @@ function check_specification_expression() result(result_)
!! Test conformance with Fortran 2018 standard clause 7.5.6.3, paragraph 6:
!! "specification expression function result"
type(result_t) result_
integer exit_status
logical error_termination_occurred

call execute_command_line( &
command = "fpm run --example specification_expression_finalization "// fpm_compiler_arguments() //" > /dev/null 2>&1", &
wait = .true., &
exitstat = exit_status &
)
error_termination_occurred = exit_status /=0
result_ = assert_that(error_termination_occurred)

call try_it
result_ = assert_that(was_finalized)
contains
subroutine try_it
real tmp(component(finalizable_t(component=0))) !! Finalizes the finalizable_t function result
end subroutine

pure function fpm_compiler_arguments() result(args)
character(len=:), allocatable :: args

associate(compiler_identity=>compiler_version())
if (scan(compiler_identity, "GCC ")==1) then
args = " "
else if (scan(compiler_identity, "NAG Fortran ")==1) then
args = "--compiler nagfor --flag -fpp"
else
error stop "----> Unrecognized compiler_version() in function fpm_compiler_arguments. <----"
end if
end associate
end function

end function


function check_intent_out_finalization() result(result_)
!! Test conformance with Fortran 2018 standard clause 7.5.6.3, paragraph 7:
!! "nonpointer, nonallocatable, INTENT (OUT) dummy argument"
Expand Down
15 changes: 11 additions & 4 deletions test/usage_test.f90 → test/usage_test.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module usage_test
use iso_fortran_env, only : compiler_version
use reference_counter_m, only: ref_reference_t
use veggies, only: &
result_t, &
Expand All @@ -8,6 +9,7 @@ module usage_test
assert_that, &
describe, &
fail, &
succeed, &
it
use shallow_m, only : shallow_t, resource_freed

Expand Down Expand Up @@ -82,12 +84,17 @@ function check_deletion() result(result_)

function check_copy() result(result_)
type(result_t) :: result_

type(object_t) :: object1, object2

object1 = object_t()
object2 = object1
result_ = assert_that(associated(object2%ref, object1%ref))
if (scan(compiler_version(),"GCC ")==1) then
result_ = fail("skipped due to known gfortran bug that causes a segmenation fault")
else
#ifndef __GFORTRAN__
object1 = object_t()
object2 = object1
result_ = assert_that(associated(object2%ref, object1%ref))
#endif
end if
end function

function check_shallow_copy() result(result_)
Expand Down