]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/remote-control/remote-control-tests.factor
factor: trim using lists
[factor.git] / basis / alien / remote-control / remote-control-tests.factor
1 USING: interpolate io io.encodings.ascii io.files io.files.temp
2 io.launcher io.streams.string kernel sequences system ;
3 IN: alien.remote-control.tests
4
5 : compile-file ( contents -- )
6     "test.c" ascii set-file-contents
7     { "gcc" "-I../" "-L.." "-lfactor" "test.c" }
8     os macosx? cpu x86.64? and [ "-m64" suffix ] when
9     try-process ;
10
11 : run-test ( -- line )
12     os windows? "a.exe" "a.out" ?
13     ascii [ readln ] with-process-reader ;
14
15 :: test-embedding ( code -- line )
16     image-path :> image
17
18     [
19         [I
20 #include <vm/master.h>
21 #include <stdio.h>
22 #include <stdbool.h>
23
24 int main(int argc, char **argv)
25 {
26     F_PARAMETERS p;
27     default_parameters(&p);
28     p.image_path = STRING_LITERAL("${image}");
29     init_factor(&p);
30     start_embedded_factor(&p);
31     ${code}
32     printf("Done.\n");
33     return 0;
34 }
35         I]
36     ] with-string-writer
37     [ compile-file ] with-temp-directory
38     [ run-test ] with-temp-directory ;
39
40 ! [ "Done." ] [ "" test-embedding ] unit-test
41
42 ! [ "Done." ] [ "factor_yield();" test-embedding ] unit-test