diff options
-rw-r--r-- | src/fpm.f90 | 6 | ||||
-rw-r--r-- | src/fpm/cmd/install.f90 | 2 | ||||
-rw-r--r-- | src/fpm_command_line.f90 | 13 | ||||
-rw-r--r-- | src/fpm_model.f90 | 3 | ||||
-rw-r--r-- | src/fpm_targets.f90 | 4 |
5 files changed, 23 insertions, 5 deletions
diff --git a/src/fpm.f90 b/src/fpm.f90 index 7208abf..1449dc2 100644 --- a/src/fpm.f90 +++ b/src/fpm.f90 @@ -85,6 +85,8 @@ subroutine build_model(model, settings, package, error) model%fortran_compile_flags = flags // " " // & & model%compiler%get_module_flag(join_path(model%output_directory, model%package_name)) + model%include_tests = settings%build_tests + allocate(model%packages(model%deps%ndep)) ! Add sources from executable directories @@ -268,7 +270,7 @@ if (allocated(error)) then call fpm_stop(1,'*cmd_build*:model error:'//error%message) end if -call targets_from_sources(targets,model,error) +call targets_from_sources(targets, model, error) if (allocated(error)) then call fpm_stop(1,'*cmd_build*:target error:'//error%message) end if @@ -314,7 +316,7 @@ subroutine cmd_run(settings,test) call fpm_stop(1, '*cmd_run*:model error:'//error%message) end if - call targets_from_sources(targets,model,error) + call targets_from_sources(targets, model, error) if (allocated(error)) then call fpm_stop(1, '*cmd_run*:targets error:'//error%message) end if diff --git a/src/fpm/cmd/install.f90 b/src/fpm/cmd/install.f90 index 4c8596e..22e451f 100644 --- a/src/fpm/cmd/install.f90 +++ b/src/fpm/cmd/install.f90 @@ -36,7 +36,7 @@ contains call build_model(model, settings%fpm_build_settings, package, error) call handle_error(error) - call targets_from_sources(targets,model,error) + call targets_from_sources(targets, model, error) call handle_error(error) installable = (allocated(package%library) .and. package%install%library) & diff --git a/src/fpm_command_line.f90 b/src/fpm_command_line.f90 index 178e885..c646e4a 100644 --- a/src/fpm_command_line.f90 +++ b/src/fpm_command_line.f90 @@ -67,6 +67,7 @@ end type type, extends(fpm_cmd_settings) :: fpm_build_settings logical :: list=.false. logical :: show_model=.false. + logical :: build_tests=.false. character(len=:),allocatable :: compiler character(len=:),allocatable :: profile character(len=:),allocatable :: flag @@ -202,6 +203,7 @@ contains & flag=val_flag, & & example=lget('example'), & & list=lget('list'),& + & build_tests=.false.,& & name=names,& & runner=val_runner,& & verbose=lget('verbose') ) @@ -213,7 +215,8 @@ contains & --show-model F & & --compiler "'//get_env('FPM_COMPILER','gfortran')//'" & & --flag:: " "& - & --verbose F& + & --tests F & + & --verbose F & & --',help_build,version_text) call check_build_vals() @@ -225,6 +228,7 @@ contains & flag=val_flag, & & list=lget('list'),& & show_model=lget('show-model'),& + & build_tests=lget('tests'),& & verbose=lget('verbose') ) case('new') @@ -417,6 +421,7 @@ contains & flag=val_flag, & & example=.false., & & list=lget('list'), & + & build_tests=.true., & & name=names, & & runner=val_runner, & & verbose=lget('verbose') ) @@ -521,6 +526,7 @@ contains help_list_dash = [character(len=80) :: & ' ', & ' build [--compiler COMPILER_NAME] [--profile PROF] [--flag FFLAGS] [--list] ', & + ' [--tests] ', & ' help [NAME(s)] ', & ' new NAME [[--lib|--src] [--app] [--test] [--example]]| ', & ' [--full|--bare][--backfill] ', & @@ -638,6 +644,7 @@ contains ' Their syntax is ', & ' ', & ' build [--profile PROF] [--flag FFLAGS] [--list] [--compiler COMPILER_NAME] ', & + ' [--tests] ', & ' new NAME [[--lib|--src] [--app] [--test] [--example]]| ', & ' [--full|--bare][--backfill] ', & ' update [NAME(s)] [--fetch-only] [--clean] ', & @@ -828,7 +835,8 @@ contains ' build(1) - the fpm(1) subcommand to build a project ', & ' ', & 'SYNOPSIS ', & - ' fpm build [--profile PROF] [--flag FFLAGS] [--compiler COMPILER_NAME] [-list]', & + ' fpm build [--profile PROF] [--flag FFLAGS] [--compiler COMPILER_NAME] ', & + ' [--list] [--tests] ', & ' ', & ' fpm build --help|--version ', & ' ', & @@ -864,6 +872,7 @@ contains ' "gfortran" unless set by the environment ', & ' variable FPM_COMPILER. ', & ' --list list candidates instead of building or running them ', & + ' --tests build all tests (otherwise only if needed) ', & ' --show-model show the model and exit (do not build) ', & ' --help print this help and exit ', & ' --version print program version information and exit ', & diff --git a/src/fpm_model.f90 b/src/fpm_model.f90 index 2dd9514..dd79b94 100644 --- a/src/fpm_model.f90 +++ b/src/fpm_model.f90 @@ -139,6 +139,9 @@ type :: fpm_model_t !> Project dependencies type(dependency_tree_t) :: deps + !> Whether tests should be added to the build list + logical :: include_tests = .true. + end type fpm_model_t contains diff --git a/src/fpm_targets.f90 b/src/fpm_targets.f90 index d480866..f10b330 100644 --- a/src/fpm_targets.f90 +++ b/src/fpm_targets.f90 @@ -191,6 +191,10 @@ subroutine build_target_list(targets,model) do i=1,size(sources) + if (.not. model%include_tests) then + if (sources(i)%unit_scope == FPM_SCOPE_TEST) cycle + end if + select case (sources(i)%unit_type) case (FPM_UNIT_MODULE,FPM_UNIT_SUBMODULE,FPM_UNIT_SUBPROGRAM,FPM_UNIT_CSOURCE) |