Fortran · 2140 bytes Raw Blame History
1 program watch_cycle_demo
2 use fgof_devloop, only : &
3 clear_devloop_options, &
4 devloop_build_command, &
5 devloop_smoke_command, &
6 devloop_summarize_watch_events, &
7 devloop_watch_trigger, &
8 run_devloop_cycle, &
9 start_devloop
10 use fgof_devloop_types, only : &
11 devloop_command_spec, &
12 devloop_options, &
13 devloop_state, &
14 devloop_supervision_result, &
15 devloop_trigger, &
16 devloop_watch_summary
17 use fgof_process, only : &
18 process_options, &
19 shell
20 use fgof_watch_types, only : &
21 FGOF_WATCH_EVT_MODIFIED, &
22 watch_event
23 implicit none
24
25 type(watch_event) :: events(2)
26 type(devloop_options) :: loop_options
27 type(process_options) :: command_options
28 type(devloop_watch_summary) :: summary
29 type(devloop_trigger) :: trigger
30 type(devloop_state) :: state
31 type(devloop_command_spec) :: build
32 type(devloop_command_spec) :: smoke
33 type(devloop_supervision_result) :: supervision
34
35 loop_options = clear_devloop_options()
36 command_options = process_options()
37 command_options%capture_stdout = .true.
38
39 events(1)%kind = FGOF_WATCH_EVT_MODIFIED
40 events(1)%path = "src/app.f90"
41 events(2)%kind = FGOF_WATCH_EVT_MODIFIED
42 events(2)%path = "test/app_test.f90"
43
44 summary = devloop_summarize_watch_events(events)
45 trigger = devloop_watch_trigger(summary, loop_options, "example watch batch")
46
47 call start_devloop(state, loop_options)
48 build = devloop_build_command(shell("printf build-ok"), command_options, "example build")
49 smoke = devloop_smoke_command(shell("printf smoke-ok"), command_options, "example smoke")
50 supervision = run_devloop_cycle(state, trigger, build_command=build, smoke_command=smoke)
51
52 if (.not. supervision%succeeded) error stop "example devloop cycle should succeed"
53 if (supervision%command_count /= 2) error stop "example should run build and smoke"
54
55 print '(a,i0)', "cycle id: ", supervision%cycle%id
56 print '(a,i0)', "changed files: ", supervision%cycle%change_count
57 print '(a)', "build stdout: " // supervision%build%process%stdout
58 print '(a)', "smoke stdout: " // supervision%smoke%process%stdout
59 end program watch_cycle_demo
60