From 73f9ee4974fcf8899baf2cf34dbbdf739eaf4975 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 23 Jul 2022 00:53:35 +0800 Subject: improve tests --- tests/modules/fwatcher/sched_watchdir.lua | 25 +++++++++++++++++++++++++ tests/modules/fwatcher/watchdir.lua | 1 + 2 files changed, 26 insertions(+) create mode 100644 tests/modules/fwatcher/sched_watchdir.lua (limited to 'tests/modules') 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) -- cgit v1.3.1