Skip to content

Commit

Permalink
Merge pull request #66 from sourceryinstitute/pass-only-if-all-pass
Browse files Browse the repository at this point in the history
fix(test_result): pass only if all images pass test
  • Loading branch information
rouson authored Dec 26, 2023
2 parents 5ecdc18 + 0ca3195 commit 2ee49f3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/sourcery/sourcery_test_result_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ pure module function characterize(self) result(characterization)
character(len=:), allocatable :: characterization
end function

elemental module function passed(self) result(test_passed)
!! The result is a character description of the test and its outcome
impure elemental module function passed(self) result(test_passed)
!! The result is true if and only if the test passed on all images
implicit none
class(test_result_t), intent(in) :: self
logical test_passed
Expand Down
2 changes: 2 additions & 0 deletions src/sourcery/sourcery_test_result_s.f90
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
submodule(sourcery_test_result_m) sourcery_test_result_s
use sourcery_user_defined_collectives_m, only : co_all
implicit none

contains
Expand All @@ -14,6 +15,7 @@

module procedure passed
test_passed = self%passed_
call co_all(test_passed)
end procedure

end submodule sourcery_test_result_s
16 changes: 15 additions & 1 deletion test/test_result_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function results() result(test_results)
type(test_result_t), allocatable :: test_results(:)

test_results = [ &
test_result_t("constructs and array of test_result_t objects elementally", check_array_result_construction()) &
test_result_t("constructing an array of test_result_t objects elementally", check_array_result_construction()), &
test_result_t("reporting failure if the test fails on one image", check_single_image_failure()) &
]
end function

Expand All @@ -36,4 +37,17 @@ pure function check_array_result_construction() result(passed)
passed = size(test_results)==2
end function

function check_single_image_failure() result(passed)
type(test_result_t), allocatable :: test_result
logical passed

if (this_image()==1) then
test_result = test_result_t("image 1 fails", .false.)
else
test_result = test_result_t("all images other than 1 pass", .true.)
end if

passed = .not. test_result%passed()
end function

end module test_result_test_m

0 comments on commit 2ee49f3

Please sign in to comment.