-USING: accessors io io.encodings.ascii io.launcher kernel make
-sequences system tools.test ;
+USING: accessors io io.encodings.ascii io.files io.files.temp
+io.launcher kernel make sequences system tools.test ;
 IN: compiler.tests.callback-error
 
-: run-vm-with-script ( string -- lines )
-    [ <process> ] dip
-        [ vm , , ] { } make >>command
+: callback-error-script ( -- path )
+    "callback-error-script" temp-file ;
+
+: run-vm-with-script ( -- lines )
+    <process>
+        [ vm , callback-error-script , ] { } make >>command
         +closed+ >>stdin
         +stdout+ >>stderr
     ascii <process-reader> stream-lines ;
 
-! Callback error from initial thread
-[ t ] [
-    """-e=USING: alien alien.c-types alien.syntax kernel ;
+[ ] [
+    """USING: alien alien.c-types alien.syntax kernel ;
     IN: scratchpad
     
     : callback-death ( -- callback )

        void { } cdecl alien-indirect ;
    
    callback-death callback-invoke"""
    run-vm-with-script
    "\"Error!\"" swap member?
] unit-test

! Callback error from another thread
[ t ] [
    """-e=USING: alien alien.c-types alien.syntax kernel threads ;
    IN: scratchpad
    
    : callback-death ( -- callback )

    
    [ callback-death callback-invoke ] in-thread
    stop"""
    callback-error-script ascii set-file-contents
] unit-test

! Callback error from another thread
[ t ] [ run-vm-with-script "\"Error!\"" swap member? ] unit-test
