Skip to content

Commit

Permalink
restore automatic code codeverage
Browse files Browse the repository at this point in the history
  • Loading branch information
szaghi committed Apr 7, 2017
1 parent 21d9741 commit 8fdac03
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 110 deletions.
4 changes: 2 additions & 2 deletions fobos
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ help = Perform coverage analysis
rule_1 = FoBiS.py clean -mode tests-gnu
rule_2 = FoBiS.py build -mode tests-gnu -coverage
rule_3 = ./scripts/run_tests.sh
rule_4 = rm -f exe/obj/penf* exe/obj/face* exe/obj/flap* exe/obj/flow* exe/obj/foodie* exe/obj/vecfor*
rule_4 = rm -f exe/obj/face* exe/obj/flap* exe/obj/flow* exe/obj/foodie* exe/obj/foreseer* exe/obj/penf* exe/obj/pyplot* exe/obj/vecfor*
rule_5 = gcov -o exe/obj/ src/lib/wenoof*
rule_6 = rm -f *.gcov

Expand All @@ -245,7 +245,7 @@ help = Perform coverage analysis and saving reports in markdown
rule_1 = FoBiS.py clean -mode tests-gnu
rule_2 = FoBiS.py build -mode tests-gnu -coverage
rule_3 = ./scripts/run_tests.sh
rule_4 = rm -f exe/obj/penf* exe/obj/face* exe/obj/flap* exe/obj/flow* exe/obj/foodie* exe/obj/vecfor*
rule_4 = rm -f exe/obj/face* exe/obj/flap* exe/obj/flow* exe/obj/foodie* exe/obj/foreseer* exe/obj/penf* exe/obj/pyplot* exe/obj/vecfor*
rule_5 = gcov -o exe/obj/ src/lib/wenoof*
rule_6 = FoBiS.py rule -gcov_analyzer wiki/ Coverage-Analysis
rule_7 = rm -f *.gcov
22 changes: 17 additions & 5 deletions src/tests/polynoms_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,25 @@ subroutine execute(self)
class(test), intent(inout) :: self !< Test.

call self%ui%get
if (trim(adjustl(self%ui%interpolator_type))/='all') then
call self%perform
if (self%ui%interpolate.and.self%ui%reconstruct) then
call subexecute
self%ui%interpolate = .false.
call subexecute
else
do while(self%ui%loop_interpolator(interpolator=self%ui%interpolator_type))
call self%perform
enddo
call subexecute
endif
contains
subroutine subexecute
!< Subexecute test(s).

if (trim(adjustl(self%ui%interpolator_type))/='all') then
call self%perform
else
do while(self%ui%loop_interpolator(interpolator=self%ui%interpolator_type))
call self%perform
enddo
endif
endsubroutine subexecute
endsubroutine execute

! private methods
Expand Down
22 changes: 17 additions & 5 deletions src/tests/sin_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,25 @@ subroutine execute(self)
class(test), intent(inout) :: self !< Test.

call self%ui%get
if (trim(adjustl(self%ui%interpolator_type))/='all') then
call self%perform
if (self%ui%interpolate.and.self%ui%reconstruct) then
call subexecute
self%ui%interpolate = .false.
call subexecute
else
do while(self%ui%loop_interpolator(interpolator=self%ui%interpolator_type))
call self%perform
enddo
call subexecute
endif
contains
subroutine subexecute
!< Subexecute test(s).

if (trim(adjustl(self%ui%interpolator_type))/='all') then
call self%perform
else
do while(self%ui%loop_interpolator(interpolator=self%ui%interpolator_type))
call self%perform
enddo
endif
endsubroutine subexecute
endsubroutine execute

! private methods
Expand Down
143 changes: 45 additions & 98 deletions src/tests/wenoof_test_ui.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ module wenoof_test_ui
integer(I_P), allocatable :: S(:) !< Stencils used.
real(RPP) :: eps !< Small epsilon to avoid zero-division.
real(RPP) :: x_target !< Interpolation target coordinate.
logical :: interpolate !< Flag for activating interpolation.
logical :: interpolate=.false. !< Flag for activating interpolation.
logical :: reconstruct=.false. !< Flag for activating reconstruction.
logical :: errors_analysis=.false. !< Flag for activating errors analysis.
logical :: plots=.false. !< Flag for activating plots saving.
logical :: results=.false. !< Flag for activating results saving.
Expand All @@ -55,111 +56,57 @@ subroutine set_cli()
!< Set Command Line Interface.

associate(cli => self%cli)
call cli%init(progname = 'WenOOF Test', &
authors = 'Fortran-FOSS-Programmers', &
license = 'GNU GPLv3', &
description = 'Test WenOOF library on function reconstruction', &
examples = ["$EXECUTABLE interpolate -i JS --results", &
"$EXECUTABLE interpolate -i JS-Z -r ", &
"$EXECUTABLE reconstruct -i JS-M ", &
"$EXECUTABLE reconstruct -i all -p -r "])
call cli%init(progname = 'WenOOF Test', &
authors = 'Fortran-FOSS-Programmers', &
license = 'GNU GPLv3', &
description = 'Test WenOOF library on function reconstruction', &
examples = ["$EXECUTABLE --interpolate -i JS --results", &
"$EXECUTABLE --interpolate -i JS-Z -r ", &
"$EXECUTABLE --reconstruct -i JS-M ", &
"$EXECUTABLE --reconstruct -i all -p -r "])

call cli%add_group(group='interpolate', description='perform WENO interpolation')
call cli%add (group='interpolate', switch='--x_target', switch_ab='-x', &
help='WENO interpolation target point coordinate', &
required=.true., def='0', act='store')
call cli%add (group='interpolate', switch='--interpolator', switch_ab='-i', &
help='WENO interpolator type', required=.false., &
def='JS', act='store', choices='all,JS,M-JS,M-Z,Z')
call cli%add (group='interpolate', switch='--points_number', switch_ab='-pn', nargs='+', &
help='Number of points used to discretize the domain', &
required=.false., act='store', def='50 100')
call cli%add (group='interpolate', switch='--stencils', switch_ab='-s', nargs='+', &
help='Stencils dimensions (and number)', required=.false., act='store', &
def='2 3 4 5 6 7 8 9', choices='2, 3, 4, 5, 6, 7, 8, 9')
call cli%add (group='interpolate', switch='--eps', help='Small epsilon to avoid zero-division', &
required=.false., act='store', def='1.e-6')
call cli%add (group='interpolate', switch='--output_dir', help='Output directory', required=.false., &
act='store', def='./')
call cli%add (group='interpolate', switch='--results', switch_ab='-r', help='Save results', required=.false., &
act='store_true', def='.false.')
call cli%add (group='interpolate', switch='--plots', switch_ab='-p', help='Save plots', required=.false., &
act='store_true', def='.false.')
call cli%add (group='interpolate', switch='--output', help='Output files basename', required=.false., &
act='store', def='output')
call cli%add (group='interpolate', switch='--errors_analysis', help='Peform errors analysis', required=.false., &
act='store_true', def='.false.')
call cli%add (group='interpolate', switch='--verbose', help='Verbose output', required=.false., &
act='store_true', def='.false.')

call cli%add_group(group='reconstruct', description='perform WENO reconstruction')
call cli%add (group='reconstruct', switch='--interpolator', switch_ab='-i', &
help='WENO interpolator type', required=.false., &
def='JS', act='store', choices='all,JS,M-JS,M-Z,Z')
call cli%add (group='reconstruct', switch='--points_number', switch_ab='-pn', nargs='+', &
help='Number of points used to discretize the domain', &
required=.false., act='store', def='50 100')
call cli%add (group='reconstruct', switch='--stencils', switch_ab='-s', nargs='+', &
help='Stencils dimensions (and number)', required=.false., act='store', &
def='2 3 4 5 6 7 8 9', choices='2, 3, 4, 5, 6, 7, 8, 9')
call cli%add (group='reconstruct', switch='--eps', help='Small epsilon to avoid zero-division', &
required=.false., act='store', def='1.e-6')
call cli%add (group='reconstruct', switch='--output_dir', help='Output directory', required=.false., &
act='store', def='./')
call cli%add (group='reconstruct', switch='--results', switch_ab='-r', help='Save results', required=.false., &
act='store_true', def='.false.')
call cli%add (group='reconstruct', switch='--plots', switch_ab='-p', help='Save plots', required=.false., &
act='store_true', def='.false.')
call cli%add (group='reconstruct', switch='--output', help='Output files basename', required=.false., &
act='store', def='output')
call cli%add (group='reconstruct', switch='--errors_analysis', help='Peform errors analysis', required=.false., &
act='store_true', def='.false.')
call cli%add (group='reconstruct', switch='--verbose', help='Verbose output', required=.false., &
act='store_true', def='.false.')
call cli%add(switch='--interpolate', help='Perform interpolation', required=.false., act='store_true', def='.false.')
call cli%add(switch='--reconstruct', help='Perform interpolation', required=.false., act='store_true', def='.false.')
call cli%add(switch='--x_target', switch_ab='-x', help='WENO interpolation target point coordinate', &
required=.false., def='0.0', act='store')
call cli%add(switch='--interpolator', switch_ab='-i', help='WENO interpolator type', required=.false., &
def='JS', act='store', choices='all,JS,M-JS,M-Z,Z')
call cli%add(switch='--points_number', switch_ab='-pn', nargs='+', help='Number of points used to discretize the domain', &
required=.false., act='store', def='50 100')
call cli%add(switch='--stencils', switch_ab='-s', nargs='+', help='Stencils dimensions (and number)', required=.false., &
act='store', def='2 3 4 5 6 7 8 9', choices='2, 3, 4, 5, 6, 7, 8, 9')
call cli%add(switch='--eps', help='Small epsilon to avoid zero-division', required=.false., act='store', def='1.e-6')
call cli%add(switch='--output_dir', help='Output directory', required=.false., act='store', def='./')
call cli%add(switch='--results', switch_ab='-r', help='Save results', required=.false., act='store_true', def='.false.')
call cli%add(switch='--plots', switch_ab='-p', help='Save plots', required=.false., act='store_true', def='.false.')
call cli%add(switch='--output', help='Output files basename', required=.false., act='store', def='output')
call cli%add(switch='--errors_analysis', help='Peform errors analysis', required=.false., act='store_true', def='.false.')
call cli%add(switch='--verbose', help='Verbose output', required=.false., act='store_true', def='.false.')
endassociate
endsubroutine set_cli

subroutine parse_cli()
!< Parse Command Line Interface and check its validity.

call self%cli%parse(error=self%error) ; if (self%error/=0) stop
if (self%cli%run_command(group='interpolate')) then
self%interpolate=.true.
call self%cli%get(group='interpolate', switch='-x', val=self%x_target, error=self%error) ; if (self%error/=0) stop
call self%cli%get(group='interpolate', switch='-i', val=self%interpolator_type, error=self%error) ; if (self%error/=0) stop
call self%cli%get_varying(group='interpolate', switch='-pn', val=self%points_number, error=self%error)
if (self%error/=0) stop
call self%cli%get_varying(group='interpolate', switch='-s', val=self%S, error=self%error) ; if (self%error/=0) stop
call self%cli%get(group='interpolate', switch='--eps', val=self%eps, error=self%error) ; if (self%error/=0) stop
call self%cli%get(group='interpolate', switch='--output_dir', val=self%output_dir, error=self%error)
if (self%error/=0) stop
call self%cli%get(group='interpolate', switch='-r', val=self%results, error=self%error) ; if (self%error/=0) stop
call self%cli%get(group='interpolate', switch='-p', val=self%plots, error=self%error) ; if (self%error/=0) stop
call self%cli%get(group='interpolate', switch='--output', val=self%output_bname, error=self%error) ; if (self%error/=0) stop
call self%cli%get(group='interpolate', switch='--errors_analysis', val=self%errors_analysis, error=self%error)
if (self%error/=0) stop
call self%cli%get(group='interpolate', switch='--verbose', val=self%verbose, error=self%error) ; if (self%error/=0) stop
elseif (self%cli%run_command(group='reconstruct')) then
self%interpolate=.false.
call self%cli%get(group='reconstruct', switch='-i', val=self%interpolator_type, error=self%error) ; if (self%error/=0) stop
call self%cli%get_varying(group='reconstruct', switch='-pn', val=self%points_number, error=self%error)
if (self%error/=0) stop
call self%cli%get_varying(group='reconstruct', switch='-s', val=self%S, error=self%error) ; if (self%error/=0) stop
call self%cli%get(group='reconstruct', switch='--eps', val=self%eps, error=self%error) ; if (self%error/=0) stop
call self%cli%get(group='reconstruct', switch='--output_dir', val=self%output_dir, error=self%error)
if (self%error/=0) stop
call self%cli%get(group='reconstruct', switch='-r', val=self%results, error=self%error) ; if (self%error/=0) stop
call self%cli%get(group='reconstruct', switch='-p', val=self%plots, error=self%error) ; if (self%error/=0) stop
call self%cli%get(group='reconstruct', switch='--output', val=self%output_bname, error=self%error) ; if (self%error/=0) stop
call self%cli%get(group='reconstruct', switch='--errors_analysis', val=self%errors_analysis, error=self%error)
if (self%error/=0) stop
call self%cli%get(group='reconstruct', switch='--verbose', val=self%verbose, error=self%error) ; if (self%error/=0) stop
else
#ifndef DEBUG
! error stop in pure procedure is a F2015 feature not yet supported in debug mode
call self%cli%print_usage
error stop 'error: action not present; choose the correct action between "interpolate" and "reconstruct"'
#endif
call self%cli%get(switch='--interpolate', val=self%interpolate, error=self%error) ; if (self%error/=0) stop
call self%cli%get(switch='--reconstruct', val=self%reconstruct, error=self%error) ; if (self%error/=0) stop
call self%cli%get(switch='-x', val=self%x_target, error=self%error) ; if (self%error/=0) stop
call self%cli%get(switch='-i', val=self%interpolator_type, error=self%error) ; if (self%error/=0) stop
call self%cli%get_varying(switch='-pn', val=self%points_number, error=self%error) ; if (self%error/=0) stop
call self%cli%get_varying(switch='-s', val=self%S, error=self%error) ; if (self%error/=0) stop
call self%cli%get(switch='--eps', val=self%eps, error=self%error) ; if (self%error/=0) stop
call self%cli%get(switch='--output_dir', val=self%output_dir, error=self%error) ; if (self%error/=0) stop
call self%cli%get(switch='-r', val=self%results, error=self%error) ; if (self%error/=0) stop
call self%cli%get(switch='-p', val=self%plots, error=self%error) ; if (self%error/=0) stop
call self%cli%get(switch='--output', val=self%output_bname, error=self%error) ; if (self%error/=0) stop
call self%cli%get(switch='--errors_analysis', val=self%errors_analysis, error=self%error) ; if (self%error/=0) stop
call self%cli%get(switch='--verbose', val=self%verbose, error=self%error) ; if (self%error/=0) stop

if ((.not.self%interpolate).and.(.not.self%reconstruct)) then
! activate both for coverage tests
self%interpolate = .true.
self%reconstruct = .true.
endif

self%pn_number = size(self%points_number, dim=1)
Expand Down

0 comments on commit 8fdac03

Please sign in to comment.