Skip to content

Commit 70f0039

Browse files
committed
Add: error handling to module dependency resolution
to allow testing.
1 parent 8c55874 commit 70f0039

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

fpm/src/fpm.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ subroutine build_model(model, settings, package, error)
8787

8888
end if
8989

90-
call resolve_module_dependencies(model%sources)
90+
call resolve_module_dependencies(model%sources,error)
9191

9292
end subroutine build_model
9393

fpm/src/fpm_sources.f90

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module fpm_sources
2-
use fpm_error, only: error_t, file_parse_error
2+
use fpm_error, only: error_t, file_parse_error, fatal_error
33
use fpm_model, only: srcfile_ptr, srcfile_t, fpm_model_t, &
44
FPM_UNIT_UNKNOWN, FPM_UNIT_PROGRAM, FPM_UNIT_MODULE, &
55
FPM_UNIT_SUBMODULE, FPM_UNIT_SUBPROGRAM, &
@@ -549,11 +549,12 @@ function split_n(string,delims,n,stat) result(substring)
549549
end function split_n
550550

551551

552-
subroutine resolve_module_dependencies(sources)
552+
subroutine resolve_module_dependencies(sources,error)
553553
! After enumerating all source files: resolve file dependencies
554554
! by searching on module names
555555
!
556556
type(srcfile_t), intent(inout), target :: sources(:)
557+
type(error_t), allocatable, intent(out) :: error
557558

558559
type(srcfile_ptr) :: dep
559560

@@ -583,10 +584,11 @@ subroutine resolve_module_dependencies(sources)
583584
end if
584585

585586
if (.not.associated(dep%ptr)) then
586-
write(*,*) '(!) Unable to find source for module dependency: ', &
587-
sources(i)%modules_used(j)%s
588-
write(*,*) ' for file ',sources(i)%file_name
589-
error stop
587+
call fatal_error(error, &
588+
'Unable to find source for module dependency: "' // &
589+
sources(i)%modules_used(j)%s // &
590+
'" used by "'//sources(i)%file_name//'"')
591+
return
590592
end if
591593

592594
n_depend = n_depend + 1

0 commit comments

Comments
 (0)