| 1 |
program test_watch_polling |
| 2 |
use fgof_watch, only : init_watch, poll_watch, reset_watch |
| 3 |
use fgof_watch_types, only : & |
| 4 |
FGOF_WATCH_EVT_CREATED, & |
| 5 |
FGOF_WATCH_EVT_MODIFIED, & |
| 6 |
FGOF_WATCH_EVT_MOVED, & |
| 7 |
FGOF_WATCH_EVT_REMOVED, & |
| 8 |
watch_event, & |
| 9 |
watch_session |
| 10 |
use watch_test_support, only : & |
| 11 |
append_text, & |
| 12 |
ensure_clean_dir, & |
| 13 |
expect_no_events, & |
| 14 |
expect_single_event, & |
| 15 |
move_path, & |
| 16 |
remove_path, & |
| 17 |
remove_tree, & |
| 18 |
write_text |
| 19 |
implicit none |
| 20 |
|
| 21 |
character(len=*), parameter :: root = "build/watch-tests-polling" |
| 22 |
character(len=*), parameter :: alpha_path = "build/watch-tests-polling/alpha.txt" |
| 23 |
character(len=*), parameter :: beta_path = "build/watch-tests-polling/beta.txt" |
| 24 |
type(watch_event), allocatable :: events(:) |
| 25 |
type(watch_session) :: session |
| 26 |
|
| 27 |
call ensure_clean_dir(root) |
| 28 |
call init_watch(session, root) |
| 29 |
|
| 30 |
events = poll_watch(session) |
| 31 |
call expect_no_events(events, "initial poll should be empty") |
| 32 |
|
| 33 |
call write_text(alpha_path, "alpha") |
| 34 |
events = poll_watch(session) |
| 35 |
call expect_single_event(events, FGOF_WATCH_EVT_CREATED, alpha_path, "", .false., "file creation should be detected") |
| 36 |
|
| 37 |
call append_text(alpha_path, "beta") |
| 38 |
events = poll_watch(session) |
| 39 |
call expect_single_event(events, FGOF_WATCH_EVT_MODIFIED, alpha_path, "", .false., "file modification should be detected") |
| 40 |
|
| 41 |
call move_path(alpha_path, beta_path) |
| 42 |
events = poll_watch(session) |
| 43 |
call expect_single_event(events, FGOF_WATCH_EVT_MOVED, beta_path, alpha_path, .false., "file move should be detected") |
| 44 |
|
| 45 |
call remove_path(beta_path) |
| 46 |
events = poll_watch(session) |
| 47 |
call expect_single_event(events, FGOF_WATCH_EVT_REMOVED, beta_path, "", .false., "file removal should be detected") |
| 48 |
|
| 49 |
call reset_watch(session) |
| 50 |
call remove_tree(root) |
| 51 |
end program test_watch_polling |
| 52 |
|