]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix concurrency.distributed tests
authorChris Double <chris.double@double.co.nz>
Thu, 10 Nov 2016 10:32:08 +0000 (23:32 +1300)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Nov 2016 01:38:59 +0000 (17:38 -0800)
basis/concurrency/distributed/distributed-tests.factor

index 83d596cca3f99ffe7b607daaa3dfbe86938b8cf3..e3a00432ed2b1a0f55f908f73ecb084776ec7b8d 100644 (file)
@@ -1,40 +1,26 @@
-USING: tools.test concurrency.distributed kernel io.files
-io.files.temp io.directories arrays io.sockets system calendar
-combinators threads math sequences concurrency.messaging
-continuations accessors prettyprint io.servers ;
+USING: arrays calendar concurrency.distributed
+concurrency.messaging io.sockets kernel math namespaces
+sequences threads tools.test ;
 FROM: concurrency.messaging => receive send ;
 IN: concurrency.distributed.tests
 
 CONSTANT: test-ip "127.0.0.1"
+CONSTANT: test-port 57234
 
-: test-node-server ( -- threaded-server )
-    {
-        { [ os unix? ] [ "distributed-concurrency-test" temp-file <local> ] }
-        { [ os windows? ] [ test-ip 0 <inet4> ] }
-    } cond <node-server> ;
-
-: test-node-client ( -- addrspec )
-    {
-        { [ os unix? ] [ "distributed-concurrency-test" temp-file <local> ] }
-        { [ os windows? ] [ insecure-addr ] }
-    } cond ;
-
-os unix? [
-    "distributed-concurrency-test" temp-file ?delete-file
-] when
-
-test-node-server [
-    [ ] [
+[ 8 ] [
+    local-node get
+    test-ip test-port <inet4> start-node
+    local-node get swap local-node set-global
+    local-node [
         [
             receive first2 [ 3 + ] dip send
             "thread-a" unregister-remote-thread
         ] "Thread A" spawn
         "thread-a" register-remote-thread
-    ] unit-test
-
-    [ 8 ] [
         5 self 2array
-        test-node-client "thread-a" <remote-thread> send
+        test-ip test-port <inet4> "thread-a" <remote-thread> send
         100 seconds receive-timeout
-    ] unit-test
-] with-threaded-server
+        stop-node
+    ] with-variable
+] unit-test
+