2 USING: io.monitors tools.test io.files system sequences
3 continuations namespaces concurrency.count-downs kernel io
4 threads calendar prettyprint destructors io.timeouts ;
6 os { winnt linux macosx } member? [
8 [ "monitor-test" temp-file delete-tree ] ignore-errors
10 [ ] [ "monitor-test" temp-file make-directory ] unit-test
12 [ ] [ "monitor-test" temp-file t <monitor> "m" set ] unit-test
14 [ ] [ "monitor-test/a1" temp-file make-directory ] unit-test
16 [ ] [ "monitor-test/a2" temp-file make-directory ] unit-test
18 [ ] [ "monitor-test/a1" temp-file "monitor-test/a2" temp-file move-file-into ] unit-test
20 [ t ] [ "monitor-test/a2/a1" temp-file exists? ] unit-test
22 [ ] [ "monitor-test/a2/a1/a3.txt" temp-file touch-file ] unit-test
24 [ t ] [ "monitor-test/a2/a1/a3.txt" temp-file exists? ] unit-test
26 [ ] [ "monitor-test/a2/a1/a4.txt" temp-file touch-file ] unit-test
27 [ ] [ "monitor-test/a2/a1/a5.txt" temp-file touch-file ] unit-test
28 [ ] [ "monitor-test/a2/a1/a4.txt" temp-file delete-file ] unit-test
29 [ ] [ "monitor-test/a2/a1/a5.txt" temp-file "monitor-test/a2/a1/a4.txt" temp-file move-file ] unit-test
31 [ t ] [ "monitor-test/a2/a1/a4.txt" temp-file exists? ] unit-test
33 [ ] [ "m" get dispose ] unit-test
37 [ "monitor-test" temp-file delete-tree ] ignore-errors
39 [ ] [ "monitor-test/xyz" temp-file make-directories ] unit-test
41 [ ] [ "monitor-test" temp-file t <monitor> "m" set ] unit-test
43 [ ] [ 1 <count-down> "b" set ] unit-test
45 [ ] [ 1 <count-down> "c1" set ] unit-test
47 [ ] [ 1 <count-down> "c2" set ] unit-test
54 "m" get next-change drop
57 [ trim-right-separators "xyz" tail? ] either? not
63 "m" get next-change drop
66 [ trim-right-separators "yxy" tail? ] either? not
70 ] "Monitor test thread" spawn drop
73 [ ] [ "b" get await ] unit-test
75 [ ] [ "monitor-test/xyz/test.txt" temp-file touch-file ] unit-test
77 [ ] [ "c1" get 1 minutes await-timeout ] unit-test
79 [ ] [ "monitor-test/subdir/blah/yxy" temp-file make-directories ] unit-test
81 [ ] [ "monitor-test/subdir/blah/yxy/test.txt" temp-file touch-file ] unit-test
83 [ ] [ "c2" get 1 minutes await-timeout ] unit-test
86 [ ] [ "m" get dispose ] unit-test
88 [ ] [ "m" get dispose ] unit-test
91 ! Out-of-scope disposal should not fail
92 [ ] [ [ "" resource-path f <monitor> ] with-monitors dispose ] unit-test
93 [ ] [ [ "" resource-path t <monitor> ] with-monitors dispose ] unit-test
97 [ ] [ "monitor-timeout-test" temp-file make-directories ] unit-test
100 [ ] [ "monitor-timeout-test" temp-file f <monitor> "m" set ] unit-test
101 [ ] [ 3 seconds "m" get set-timeout ] unit-test
102 [ [ t ] [ "m" get next-change 2drop ] [ ] while ] must-fail
103 [ ] [ "m" get dispose ] unit-test
106 [ ] [ "monitor-timeout-test" temp-file t <monitor> "m" set ] unit-test
107 [ ] [ 3 seconds "m" get set-timeout ] unit-test
108 [ [ t ] [ "m" get next-change 2drop ] [ ] while ] must-fail
109 [ ] [ "m" get dispose ] unit-test