Skip to content

Commit f1f0efe

Browse files
committed
hello world test
1 parent 5a70062 commit f1f0efe

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

src/fpm_command_line.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ module fpm_command_line
5252
fpm_update_settings, &
5353
fpm_clean_settings, &
5454
fpm_publish_settings, &
55-
get_command_line_settings
55+
get_command_line_settings, &
56+
get_fpm_env
5657

5758
type, abstract :: fpm_cmd_settings
5859
character(len=:), allocatable :: working_dir

test/fpm_test/main.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ program fpm_testing
2424
stat = 0
2525

2626
suite = [ &
27-
& new_testsuite("fpm_toml", collect_toml), &
28-
& new_testsuite("fpm_compiler", collect_compiler), &
27+
& new_testsuite("fpm_toml", collect_toml), &
2928
& new_testsuite("fpm_manifest", collect_manifest), &
3029
& new_testsuite("fpm_filesystem", collect_filesystem), &
3130
& new_testsuite("fpm_source_parsing", collect_source_parsing), &
@@ -35,7 +34,8 @@ program fpm_testing
3534
& new_testsuite("fpm_installer", collect_installer), &
3635
& new_testsuite("fpm_versioning", collect_versioning), &
3736
& new_testsuite("fpm_settings", collect_settings), &
38-
& new_testsuite("fpm_os", collect_os) &
37+
& new_testsuite("fpm_os", collect_os), &
38+
& new_testsuite("fpm_compiler", collect_compiler) &
3939
& ]
4040

4141
call get_argument(1, suite_name)

test/fpm_test/test_compiler.f90

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ module test_compiler
33
use testsuite, only : new_unittest, unittest_t, error_t, test_failed, &
44
& check_string
55
use fpm_environment, only : OS_WINDOWS, OS_LINUX
6-
use fpm_compiler , only : compiler_t
6+
use fpm_compiler , only : compiler_t, new_compiler
7+
use fpm_command_line, only: get_fpm_env
78
implicit none
89
private
910

@@ -25,7 +26,29 @@ end subroutine collect_compiler
2526
subroutine test_check_fortran_source_runs(error)
2627
!> Error handling
2728
type(error_t), allocatable, intent(out) :: error
28-
29+
30+
character(:), allocatable :: fc,cc,cxx
31+
32+
33+
type(compiler_t) :: compiler
34+
35+
!> Get default compiler
36+
fc = get_fpm_env("FC", default="gfortran")
37+
cc = get_fpm_env("CC", default=" ")
38+
cxx = get_fpm_env("CXX", default=" ")
39+
40+
call new_compiler(compiler, fc, cc, cxx, echo=.false., verbose=.false.)
41+
42+
if (compiler%is_unknown()) then
43+
call test_failed(error, "Cannot initialize Fortran compiler")
44+
return
45+
end if
46+
47+
!> Test fortran-source runs
48+
if (.not.compiler%check_fortran_source_runs("print *, 'Hello world!'; end")) then
49+
call test_failed(error, "Cannot run Fortran hello world")
50+
return
51+
end if
2952

3053
end subroutine test_check_fortran_source_runs
3154

0 commit comments

Comments
 (0)