diff options
| author | ruki <[email protected]> | 2022-07-23 00:53:35 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-07-23 00:53:35 +0800 |
| commit | 73f9ee4974fcf8899baf2cf34dbbdf739eaf4975 (patch) | |
| tree | 342dc75f0a01a2247c7ee93d0d2ea65dfc7c730f /tests/modules | |
| parent | bf3a38003ae5b93010dd0d8b70155bf1b1ee305a (diff) | |
improve tests
Diffstat (limited to 'tests/modules')
| -rw-r--r-- | tests/modules/fwatcher/sched_watchdir.lua | 25 | ||||
| -rw-r--r-- | tests/modules/fwatcher/watchdir.lua | 1 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/modules/fwatcher/sched_watchdir.lua b/tests/modules/fwatcher/sched_watchdir.lua new file mode 100644 index 000000000..e990236ab --- /dev/null +++ b/tests/modules/fwatcher/sched_watchdir.lua @@ -0,0 +1,25 @@ +import("core.base.fwatcher") +import("core.base.scheduler") + +function _watch(watchdir) + print("watch %s ..", watchdir) + fwatcher.add(watchdir) + while true do + local ok, event = fwatcher.wait(-1) + if ok > 0 then + print(event) + end + end +end + +function _sleep() + while true do + print("sleep ..") + os.sleep(1000) + end +end + +function main(watchdir) + scheduler.co_start(_watch, watchdir) + scheduler.co_start(_sleep) +end diff --git a/tests/modules/fwatcher/watchdir.lua b/tests/modules/fwatcher/watchdir.lua index d73d7ff9f..3bd8e8897 100644 --- a/tests/modules/fwatcher/watchdir.lua +++ b/tests/modules/fwatcher/watchdir.lua @@ -1,6 +1,7 @@ import("core.base.fwatcher") function main(watchdir) + print("watch %s ..", watchdir) fwatcher.add(watchdir) while true do local ok, event = fwatcher.wait(-1) |
