Skip to content

Commit 4ebe231

Browse files
committed
add static library test
1 parent e57c5da commit 4ebe231

File tree

5 files changed

+70
-1
lines changed

5 files changed

+70
-1
lines changed

ci/run_tests.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,5 +326,11 @@ pushd shared_app_only
326326
test $EXIT_CODE -eq 0
327327
popd
328328

329+
# Static library dependencies
330+
pushd static_app_only
331+
"$fpm" test || EXIT_CODE=$?
332+
test $EXIT_CODE -eq 0
333+
popd
334+
329335
# Cleanup
330336
rm -rf ./*/build

example_packages/shared_app_only/fpm.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# App only, use shared lib from other folder
22
name = "shared_app_only"
3-
library.shared=true
3+
library.type="shared"
4+
install.library=true
45
[dependencies]
56
shared_lib_extra = { path = "../shared_lib_extra" }
67
[dev-dependencies]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
program main
2+
use testdrive
3+
print *, 'Hello, world!'
4+
end program main
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# App only, use shared lib from other folder
2+
name = "shared_app_only"
3+
library.type="static"
4+
install.library=true
5+
[dependencies]
6+
shared_lib_extra = { path = "../shared_lib_extra" }
7+
[dev-dependencies]
8+
test-drive = { git = "https://github.com/fortran-lang/test-drive", tag="v0.5.0" }
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module test_shared_lib
2+
use testdrive, only : new_unittest, unittest_type, error_type, check
3+
use shared_lib, only: test_something
4+
5+
implicit none
6+
7+
public :: collect
8+
9+
10+
contains
11+
12+
!> Collect all exported unit tests
13+
subroutine collect(testsuite)
14+
!> Collection of tests
15+
type(unittest_type), allocatable, intent(out) :: testsuite(:)
16+
17+
testsuite = [ new_unittest("shared_lib", test_shared) ]
18+
19+
end subroutine collect
20+
21+
subroutine test_shared(error)
22+
type(error_type), allocatable, intent(out) :: error
23+
24+
call check(error, test_something(), 123, "Should be test_something==123")
25+
26+
end subroutine test_shared
27+
28+
end module test_shared_lib
29+
30+
program tester
31+
use, intrinsic :: iso_fortran_env, only : error_unit
32+
use testdrive, only : run_testsuite, new_testsuite, testsuite_type
33+
use test_shared_lib, only : collect
34+
implicit none
35+
integer :: stat
36+
type(testsuite_type), allocatable :: testsuite
37+
character(len=*), parameter :: fmt = '("#", *(1x, a))'
38+
39+
stat = 0
40+
41+
testsuite = new_testsuite("shared_lib", collect)
42+
43+
write(error_unit, fmt) "Testing:", testsuite%name
44+
call run_testsuite(testsuite%collect, error_unit, stat)
45+
46+
if (stat > 0) then
47+
write(error_unit, '(i0, 1x, a)') stat, "test(s) failed!"
48+
error stop
49+
end if
50+
end program tester

0 commit comments

Comments
 (0)