aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xci/run_tests.bat4
-rwxr-xr-xci/run_tests.sh2
-rw-r--r--fpm/fpm.toml3
-rw-r--r--fpm/src/fpm/cmd/new.f9019
-rw-r--r--fpm/test/new_test/new_test.f9050
5 files changed, 47 insertions, 31 deletions
diff --git a/ci/run_tests.bat b/ci/run_tests.bat
index 76e5349..5f455b3 100755
--- a/ci/run_tests.bat
+++ b/ci/run_tests.bat
@@ -9,8 +9,10 @@ if errorlevel 1 exit 1
fpm run
if errorlevel 1 exit 1
+rmdir fpm_scratch_* /s /q
fpm test
if errorlevel 1 exit 1
+rmdir fpm_scratch_* /s /q
build\gfortran_debug\app\fpm
if errorlevel 1 exit 1
@@ -103,4 +105,4 @@ if errorlevel 1 exit 1
if errorlevel 1 exit 1
.\build\gfortran_debug\app\Program_with_module
-if errorlevel 1 exit 1 \ No newline at end of file
+if errorlevel 1 exit 1
diff --git a/ci/run_tests.sh b/ci/run_tests.sh
index adff2b3..7568b46 100755
--- a/ci/run_tests.sh
+++ b/ci/run_tests.sh
@@ -5,7 +5,9 @@ set -ex
cd fpm
fpm build
fpm run
+rm -rf fpm_scratch_*/
fpm test
+rm -rf fpm_scratch_*/
build/gfortran_debug/app/fpm
cd ../test/example_packages/hello_world
diff --git a/fpm/fpm.toml b/fpm/fpm.toml
index 8b4d8a3..f5fd443 100644
--- a/fpm/fpm.toml
+++ b/fpm/fpm.toml
@@ -16,6 +16,7 @@ rev = "649075aceb97f997665a1a4656514fd2e9b4becc"
[dependencies.fortran-intrinsic-manpages]
git = "https://github.com/urbanjost/M_intrinsics.git"
+rev = "a758ebdd0487e8cab5b4894fbf375f87147c44b5"
[[test]]
name = "cli-test"
@@ -31,3 +32,5 @@ main = "new_test.f90"
name = "fpm-test"
source-dir = "test/fpm_test"
main = "main.f90"
+
+
diff --git a/fpm/src/fpm/cmd/new.f90 b/fpm/src/fpm/cmd/new.f90
index f57b948..eb1a532 100644
--- a/fpm/src/fpm/cmd/new.f90
+++ b/fpm/src/fpm/cmd/new.f90
@@ -15,6 +15,9 @@ type(fpm_new_settings), intent(in) :: settings
character(len=:),allocatable :: bname ! baeename of NAME
character(len=:),allocatable :: message(:)
character(len=:),allocatable :: littlefile(:)
+character(len=8) :: date
+
+ call date_and_time(DATE=date)
if(exists(settings%name) .and. .not.settings%backfill )then
write(stderr,'(*(g0,1x))')&
@@ -53,14 +56,14 @@ character(len=:),allocatable :: littlefile(:)
call warnwrite(join_path(settings%name, 'README.md'), littlefile)
! start building NAME/fpm.toml
- message=[character(len=80) :: &
- &'name = "'//bname//'" ', &
- &'version = "0.1.0" ', &
- &'license = "license" ', &
- &'author = "Jane Doe" ', &
- &'maintainer = "jane.doe@example.com" ', &
- &'copyright = "2020 Jane Doe" ', &
- &' ', &
+ message=[character(len=80) :: &
+ &'name = "'//bname//'" ', &
+ &'version = "0.1.0" ', &
+ &'license = "license" ', &
+ &'author = "Jane Doe" ', &
+ &'maintainer = "jane.doe@example.com" ', &
+ &'copyright = "'//date(1:4)//' Jane Doe" ', &
+ &' ', &
&'']
if(settings%with_lib)then
diff --git a/fpm/test/new_test/new_test.f90 b/fpm/test/new_test/new_test.f90
index cafcaf2..17e269a 100644
--- a/fpm/test/new_test/new_test.f90
+++ b/fpm/test/new_test/new_test.f90
@@ -4,37 +4,42 @@ use fpm_filesystem, only : is_dir, list_files, exists, windows_path
use fpm_strings, only : string_t, operator(.in.)
use fpm_environment, only : run, get_os_type
use fpm_environment, only : OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD, OS_WINDOWS
+implicit none
type(string_t), allocatable :: file_names(:)
integer :: i, j, k
character(len=*),parameter :: cmdpath = 'build/gfortran_debug/app/fpm'
character(len=:),allocatable :: path
+character(len=*),parameter :: scr = 'fpm_scratch_'
character(len=*),parameter :: cmds(*) = [character(len=80) :: &
' new', &
' new no-no', &
-' new A', &
-' new B --lib', &
-' new C --app', &
-' new D --test', &
-' new E --lib --test ', &
-' new F --lib --app', &
-' new G --test --app', &
-' new BB --lib', &
-' new BB --test ', &
-' new BB --backfill --test', &
-' new CC --test --src --app', &
+' new '//scr//'A', &
+' new '//scr//'B --lib', &
+' new '//scr//'C --app', &
+' new '//scr//'D --test', &
+' new '//scr//'E --lib --test ', &
+' new '//scr//'F --lib --app', &
+' new '//scr//'G --test --app', &
+' new '//scr//'BB --lib', &
+' new '//scr//'BB --test ', &
+' new '//scr//'BB --backfill --test', &
+' new '//scr//'CC --test --src --app', &
' new --version', &
' new --help']
integer :: estat, cstat
character(len=256) :: message
character(len=:),allocatable :: directories(:)
+character(len=:),allocatable :: shortdirs(:)
character(len=:),allocatable :: expected(:)
logical,allocatable :: tally(:)
logical :: IS_OS_WINDOWS
write(*,'(g0:,1x)')'TEST new SUBCOMMAND (draft):'
allocate(tally(0))
- directories=[character(len=80) :: 'A','B','C','D','E','F','G','BB','CC']
+ shortdirs=[character(len=80) :: 'A','B','C','D','E','F','G','BB','CC']
+ allocate(character(len=80) :: directories(size(shortdirs)))
do i=1,size(directories)
+ directories(i)=scr//trim(shortdirs(i))
if( is_dir(trim(directories(i))) ) then
write(*,*)'ERROR:',trim( directories(i) ),' already exists'
write(*,*)' you must remove scratch directories before performing this test'
@@ -76,31 +81,31 @@ logical :: IS_OS_WINDOWS
! assuming hidden files in .git and .gitignore are ignored for now
TESTS: do i=1,size(directories)
! test if expected directory exists
- if( .not. is_dir(trim(directories(i))) ) then
+ if( .not. is_dir(trim( directories(i))) ) then
tally=[tally,.false.]
write(*,*)'ERROR:',trim( directories(i) ),' is not a directory'
else
- select case(directories(i))
+ select case(shortdirs(i))
case('A'); expected=[ character(len=80)::&
- &'A/app','A/fpm.toml','A/README.md','A/src','A/test','A/app/main.f90','A/src/A.f90','A/test/main.f90']
+ &'A/app','A/fpm.toml','A/README.md','A/src','A/test','A/app/main.f90','A/src/'//scr//'A.f90','A/test/main.f90']
case('B'); expected=[ character(len=80)::&
- &'B/fpm.toml','B/README.md','B/src','B/src/B.f90']
+ &'B/fpm.toml','B/README.md','B/src','B/src/'//scr//'B.f90']
case('C'); expected=[ character(len=80)::&
&'C/app','C/fpm.toml','C/README.md','C/app/main.f90']
case('D'); expected=[ character(len=80)::&
&'D/fpm.toml','D/README.md','D/test','D/test/main.f90']
case('E'); expected=[ character(len=80)::&
- &'E/fpm.toml','E/README.md','E/src','E/test','E/src/E.f90','E/test/main.f90']
+ &'E/fpm.toml','E/README.md','E/src','E/test','E/src/'//scr//'E.f90','E/test/main.f90']
case('F'); expected=[ character(len=80)::&
- &'F/app','F/fpm.toml','F/README.md','F/src','F/app/main.f90','F/src/F.f90']
+ &'F/app','F/fpm.toml','F/README.md','F/src','F/app/main.f90','F/src/'//scr//'F.f90']
case('G'); expected=[ character(len=80)::&
&'G/app','G/fpm.toml','G/README.md','G/test','G/app/main.f90','G/test/main.f90']
case('BB'); expected=[ character(len=80)::&
- &'BB/fpm.toml','BB/README.md','BB/src','BB/test','BB/src/BB.f90','BB/test/main.f90']
+ &'BB/fpm.toml','BB/README.md','BB/src','BB/test','BB/src/'//scr//'BB.f90','BB/test/main.f90']
case('CC'); expected=[ character(len=80)::&
- &'CC/app','CC/fpm.toml','CC/README.md','CC/src','CC/test','CC/app/main.f90','CC/src/CC.f90','CC/test/main.f90']
+ &'CC/app','CC/fpm.toml','CC/README.md','CC/src','CC/test','CC/app/main.f90','CC/src/'//scr//'CC.f90','CC/test/main.f90']
case default
- write(*,*)'ERROR: internal error. unknown directory name ',trim(directories(i))
+ write(*,*)'ERROR: internal error. unknown directory name ',trim(shortdirs(i))
stop 4
end select
!! MSwindows has hidden files in it
@@ -109,12 +114,13 @@ logical :: IS_OS_WINDOWS
if(size(expected).ne.size(file_names))then
write(*,*)'WARNING: unexpected number of files in file list=',size(file_names),' expected ',size(expected)
- write(*,'("EXPECTED: ",*(g0:,","))')(trim(expected(j)),j=1,size(expected))
+ write(*,'("EXPECTED: ",*(g0:,","))')(scr//trim(expected(j)),j=1,size(expected))
write(*,'("FOUND: ",*(g0:,","))')(trim(file_names(j)%s),j=1,size(file_names))
endif
do j=1,size(expected)
+ expected(j)=scr//expected(j)
if(is_os_windows) expected(j)=windows_path(expected(j))
if( .not.(trim(expected(j)).in.file_names) )then
tally=[tally,.false.]