@@ -7,6 +7,7 @@ module test_backend
7
7
FPM_TARGET_OBJECT, FPM_TARGET_ARCHIVE, &
8
8
add_target, add_dependency
9
9
use fpm_backend, only: sort_target, schedule_targets
10
+ use fpm_compile_commands, only: compile_command_t, compile_command_table_t
10
11
implicit none
11
12
private
12
13
@@ -26,7 +27,8 @@ subroutine collect_backend(testsuite)
26
27
& new_unittest(" target-sort-skip-all" , test_target_sort_skip_all), &
27
28
& new_unittest(" target-sort-rebuild-all" , test_target_sort_rebuild_all), &
28
29
& new_unittest(" schedule-targets" , test_schedule_targets), &
29
- & new_unittest(" schedule-targets-empty" , test_schedule_empty) &
30
+ & new_unittest(" schedule-targets-empty" , test_schedule_empty), &
31
+ & new_unittest(" serialize-compile-commands" , compile_commands_roundtrip) &
30
32
]
31
33
32
34
end subroutine collect_backend
@@ -354,5 +356,38 @@ function new_test_package() result(targets)
354
356
355
357
end function new_test_package
356
358
359
+ subroutine compile_commands_roundtrip (error )
360
+
361
+ ! > Error handling
362
+ type (error_t), allocatable , intent (out ) :: error
363
+
364
+ type (compile_command_t) :: cmd
365
+ type (compile_command_table_t) :: cc
366
+ integer :: i
367
+
368
+ call cmd% test_serialization(' compile_command: empty' , error)
369
+ if (allocated (error)) return
370
+
371
+ cmd = compile_command_t(directory = string_t(" /test/dir" ), &
372
+ arguments = [string_t(" gfortran" ), &
373
+ string_t(" -c" ), string_t(" main.f90" ), &
374
+ string_t(" -o" ), string_t(" main.o" )], &
375
+ file = string_t(" main.f90" ))
376
+
377
+ call cmd% test_serialization(' compile_command: non-empty' , error)
378
+ if (allocated (error)) return
379
+
380
+ call cc% test_serialization(' compile_command_table: empty' , error)
381
+ if (allocated (error)) return
382
+
383
+ do i= 1 ,10
384
+ call cc% register(cmd,error)
385
+ if (allocated (error)) return
386
+ end do
387
+
388
+ call cc% test_serialization(' compile_command_table: non-empty' , error)
389
+ if (allocated (error)) return
390
+
391
+ end subroutine compile_commands_roundtrip
357
392
358
393
end module test_backend
0 commit comments