io.monitors: change tests to not use unique because it only ever used temp-file.

locals-and-roots
John Benediktsson 2016-03-18 10:36:16 -07:00
parent 7c2e8d0fad
commit f5b31a85c0
1 changed files with 75 additions and 83 deletions

View File

@ -1,85 +1,81 @@
USING: accessors calendar concurrency.count-downs USING: accessors calendar concurrency.count-downs
concurrency.promises continuations destructors io io.directories concurrency.promises continuations destructors io io.directories
io.directories.hierarchy io.files io.files.temp io.files.unique io.directories.hierarchy io.files io.files.temp io.monitors
io.monitors io.pathnames io.timeouts kernel namespaces sequences io.pathnames io.timeouts kernel namespaces sequences system
system threads tools.test ; threads tools.test ;
IN: io.monitors.tests IN: io.monitors.tests
os { windows linux macosx } member? [ os { windows linux macosx } member? [
[ [
[ [ "monitor-test" temp-file delete-tree ] ignore-errors
[ "monitor-test" temp-file delete-tree ] ignore-errors
[ ] [ "monitor-test" temp-file make-directory ] unit-test [ ] [ "monitor-test" temp-file make-directory ] unit-test
[ ] [ "monitor-test" temp-file t <monitor> "m" set ] unit-test [ ] [ "monitor-test" temp-file t <monitor> "m" set ] unit-test
[ ] [ "monitor-test/a1" temp-file make-directory ] unit-test [ ] [ "monitor-test/a1" temp-file make-directory ] unit-test
[ ] [ "monitor-test/a2" temp-file make-directory ] unit-test [ ] [ "monitor-test/a2" temp-file make-directory ] unit-test
[ ] [ "monitor-test/a1" temp-file "monitor-test/a2" temp-file move-file-into ] unit-test [ ] [ "monitor-test/a1" temp-file "monitor-test/a2" temp-file move-file-into ] unit-test
[ t ] [ "monitor-test/a2/a1" temp-file exists? ] unit-test [ t ] [ "monitor-test/a2/a1" temp-file exists? ] unit-test
[ ] [ "monitor-test/a2/a1/a3.txt" temp-file touch-file ] unit-test [ ] [ "monitor-test/a2/a1/a3.txt" temp-file touch-file ] unit-test
[ t ] [ "monitor-test/a2/a1/a3.txt" temp-file exists? ] unit-test [ t ] [ "monitor-test/a2/a1/a3.txt" temp-file exists? ] unit-test
[ ] [ "monitor-test/a2/a1/a4.txt" temp-file touch-file ] unit-test [ ] [ "monitor-test/a2/a1/a4.txt" temp-file touch-file ] unit-test
[ ] [ "monitor-test/a2/a1/a5.txt" temp-file touch-file ] unit-test [ ] [ "monitor-test/a2/a1/a5.txt" temp-file touch-file ] unit-test
[ ] [ "monitor-test/a2/a1/a4.txt" temp-file delete-file ] unit-test [ ] [ "monitor-test/a2/a1/a4.txt" temp-file delete-file ] unit-test
[ ] [ "monitor-test/a2/a1/a5.txt" temp-file "monitor-test/a2/a1/a4.txt" temp-file move-file ] unit-test [ ] [ "monitor-test/a2/a1/a5.txt" temp-file "monitor-test/a2/a1/a4.txt" temp-file move-file ] unit-test
[ t ] [ "monitor-test/a2/a1/a4.txt" temp-file exists? ] unit-test [ t ] [ "monitor-test/a2/a1/a4.txt" temp-file exists? ] unit-test
[ ] [ "m" get dispose ] unit-test [ ] [ "m" get dispose ] unit-test
] with-unique-directory delete-tree
] with-monitors ] with-monitors
[ [
[ [ "monitor-test" temp-file delete-tree ] ignore-errors
[ "monitor-test" temp-file delete-tree ] ignore-errors [ ] [ "monitor-test/xyz" temp-file make-directories ] unit-test
[ ] [ "monitor-test/xyz" temp-file make-directories ] unit-test [ ] [ "monitor-test" temp-file t <monitor> "m" set ] unit-test
[ ] [ "monitor-test" temp-file t <monitor> "m" set ] unit-test
[ ] [ 1 <count-down> "b" set ] unit-test
[ ] [ 1 <count-down> "c1" set ] unit-test
[ ] [ 1 <count-down> "c2" set ] unit-test
[ ] [
[
"b" get count-down
[ ] [ 1 <count-down> "b" set ] unit-test
[ ] [ 1 <count-down> "c1" set ] unit-test
[ ] [ 1 <count-down> "c2" set ] unit-test
[ ] [
[ [
"b" get count-down "m" get next-change path>>
dup print flush
dup parent-directory
[ trim-tail-separators "xyz" tail? ] either? not
] loop
[ "c1" get count-down
"m" get next-change path>> [
dup print flush "m" get next-change path>>
dup parent-directory dup print flush
[ trim-tail-separators "xyz" tail? ] either? not dup parent-directory
] loop [ trim-tail-separators "yxy" tail? ] either? not
] loop
"c1" get count-down "c2" get count-down
[ ] "Monitor test thread" spawn drop
"m" get next-change path>> ] unit-test
dup print flush
dup parent-directory
[ trim-tail-separators "yxy" tail? ] either? not
] loop
"c2" get count-down [ ] [ "b" get await ] unit-test
] "Monitor test thread" spawn drop [ ] [ "monitor-test/xyz/test.txt" temp-file touch-file ] unit-test
] unit-test [ ] [ "c1" get 1 minutes await-timeout ] unit-test
[ ] [ "monitor-test/subdir/blah/yxy" temp-file make-directories ] unit-test
[ ] [ "monitor-test/subdir/blah/yxy/test.txt" temp-file touch-file ] unit-test
[ ] [ "c2" get 1 minutes await-timeout ] unit-test
[ ] [ "b" get await ] unit-test ! Dispose twice
[ ] [ "monitor-test/xyz/test.txt" temp-file touch-file ] unit-test [ ] [ "m" get dispose ] unit-test
[ ] [ "c1" get 1 minutes await-timeout ] unit-test [ ] [ "m" get dispose ] unit-test
[ ] [ "monitor-test/subdir/blah/yxy" temp-file make-directories ] unit-test
[ ] [ "monitor-test/subdir/blah/yxy/test.txt" temp-file touch-file ] unit-test
[ ] [ "c2" get 1 minutes await-timeout ] unit-test
! Dispose twice
[ ] [ "m" get dispose ] unit-test
[ ] [ "m" get dispose ] unit-test
] with-unique-directory delete-tree
] with-monitors ] with-monitors
! Out-of-scope disposal should not fail ! Out-of-scope disposal should not fail
@ -88,41 +84,37 @@ os { windows linux macosx } member? [
! Timeouts ! Timeouts
[ [
[ [ ] [ "monitor-timeout-test" temp-file make-directories ] unit-test
[ ] [ "monitor-timeout-test" temp-file make-directories ] unit-test
! Non-recursive ! Non-recursive
[ ] [ "monitor-timeout-test" temp-file f <monitor> "m" set ] unit-test [ ] [ "monitor-timeout-test" temp-file f <monitor> "m" set ] unit-test
[ ] [ 100 milliseconds "m" get set-timeout ] unit-test [ ] [ 100 milliseconds "m" get set-timeout ] unit-test
[ [ t ] [ "m" get next-change drop ] while ] must-fail [ [ t ] [ "m" get next-change drop ] while ] must-fail
[ ] [ "m" get dispose ] unit-test [ ] [ "m" get dispose ] unit-test
! Recursive ! Recursive
[ ] [ "monitor-timeout-test" temp-file t <monitor> "m" set ] unit-test [ ] [ "monitor-timeout-test" temp-file t <monitor> "m" set ] unit-test
[ ] [ 100 milliseconds "m" get set-timeout ] unit-test [ ] [ 100 milliseconds "m" get set-timeout ] unit-test
[ [ t ] [ "m" get next-change drop ] while ] must-fail [ [ t ] [ "m" get next-change drop ] while ] must-fail
[ ] [ "m" get dispose ] unit-test [ ] [ "m" get dispose ] unit-test
] with-unique-directory delete-tree
] with-monitors ] with-monitors
! Disposing a monitor should throw an error in any threads ! Disposing a monitor should throw an error in any threads
! waiting on notifications ! waiting on notifications
[ [
[ ] [
<promise> "p" set
"monitor-test" temp-file t <monitor> "m" set
10 seconds "m" get set-timeout
] unit-test
[ [
[ ] [ [ "m" get next-change ] [ ] recover
<promise> "p" set "p" get fulfill
"monitor-test" temp-file t <monitor> "m" set ] in-thread
10 seconds "m" get set-timeout
] unit-test
[ [ ] [ 100 milliseconds sleep ] unit-test
[ "m" get next-change ] [ ] recover [ ] [ "m" get dispose ] unit-test
"p" get fulfill [ t ] [ "p" get 10 seconds ?promise-timeout already-disposed? ] unit-test
] in-thread
[ ] [ 100 milliseconds sleep ] unit-test
[ ] [ "m" get dispose ] unit-test
[ t ] [ "p" get 10 seconds ?promise-timeout already-disposed? ] unit-test
] with-unique-directory delete-tree
] with-monitors ] with-monitors
] when ] when