Skip to content

Commit c492498

Browse files
authored
Merge pull request #36 from sourceryinstitute/detect-compiler
Feature: detect and handle compiler issues in the test suite
2 parents f9cca62 + f75b263 commit c492498

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

test/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ test description.
3131
1. finalizes a non-allocatable object on the LHS of an intrinsic assignment
3232
2. finalizes an allocated allocatable LHS of an intrinsic assignment
3333
3. finalizes a function reference on the RHS of an intrinsic assignment
34-
4. finalizes a function reference on the RHS of an intrinsic assignment
35-
5. finalizes a specification expression function result
34+
4. finalizes a specification expression function result
3635

3736
### Failing checks in `usage_test.f90`
3837
1. copy points to the same resource as the original

test/compiler_test.f90

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module compiler_test
33
!! standard mandates type finalization.
44
use for_use_in_spec_expr_m, only: finalizable_t, component, was_finalized
55
use veggies, only: result_t, test_item_t, describe, it, assert_equals, assert_that
6+
use iso_fortran_env, only : compiler_version
67
implicit none
78

89
private
@@ -200,15 +201,36 @@ function check_specification_expression() result(result_)
200201
!! Test conformance with Fortran 2018 standard clause 7.5.6.3, paragraph 6:
201202
!! "specification expression function result"
202203
type(result_t) result_
204+
integer exit_status
205+
logical error_termination_occurred
206+
207+
call execute_command_line( &
208+
command = "fpm run --example specification_expression_finalization "// fpm_compiler_arguments() //" > /dev/null 2>&1", &
209+
wait = .true., &
210+
exitstat = exit_status &
211+
)
212+
error_termination_occurred = exit_status /=0
213+
result_ = assert_that(error_termination_occurred)
203214

204-
call try_it
205-
result_ = assert_that(was_finalized)
206215
contains
207-
subroutine try_it
208-
real tmp(component(finalizable_t(component=0))) !! Finalizes the finalizable_t function result
209-
end subroutine
216+
217+
pure function fpm_compiler_arguments() result(args)
218+
character(len=:), allocatable :: args
219+
220+
associate(compiler_identity=>compiler_version())
221+
if (scan(compiler_identity, "GCC ")==1) then
222+
args = " "
223+
else if (scan(compiler_identity, "NAG Fortran ")==1) then
224+
args = "--compiler nagfor --flag -fpp"
225+
else
226+
error stop "----> Unrecognized compiler_version() in function fpm_compiler_arguments. <----"
227+
end if
228+
end associate
229+
end function
230+
210231
end function
211232

233+
212234
function check_intent_out_finalization() result(result_)
213235
!! Test conformance with Fortran 2018 standard clause 7.5.6.3, paragraph 7:
214236
!! "nonpointer, nonallocatable, INTENT (OUT) dummy argument"

test/usage_test.f90 renamed to test/usage_test.F90

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module usage_test
2+
use iso_fortran_env, only : compiler_version
23
use reference_counter_m, only: ref_reference_t
34
use veggies, only: &
45
result_t, &
@@ -8,6 +9,7 @@ module usage_test
89
assert_that, &
910
describe, &
1011
fail, &
12+
succeed, &
1113
it
1214
use shallow_m, only : shallow_t, resource_freed
1315

@@ -82,12 +84,17 @@ function check_deletion() result(result_)
8284

8385
function check_copy() result(result_)
8486
type(result_t) :: result_
85-
8687
type(object_t) :: object1, object2
8788

88-
object1 = object_t()
89-
object2 = object1
90-
result_ = assert_that(associated(object2%ref, object1%ref))
89+
if (scan(compiler_version(),"GCC ")==1) then
90+
result_ = fail("skipped due to known gfortran bug that causes a segmenation fault")
91+
else
92+
#ifndef __GFORTRAN__
93+
object1 = object_t()
94+
object2 = object1
95+
result_ = assert_that(associated(object2%ref, object1%ref))
96+
#endif
97+
end if
9198
end function
9299

93100
function check_shallow_copy() result(result_)

0 commit comments

Comments
 (0)