Add unit tests for alien.remote-control

db4
Slava Pestov 2009-01-14 21:03:07 -06:00
parent 07ec51b24a
commit 36e73b8c91
1 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,44 @@
USING: interpolate multiline
io io.directories io.encodings.ascii io.files
io.files.temp io.launcher io.streams.string kernel locals system
tools.test sequences ;
IN: alien.remote-control.tests
: compile-file ( contents -- )
"test.c" ascii set-file-contents
{ "gcc" "-I../" "-L.." "-lfactor" "test.c" }
os macosx? cpu x86.64? and [ "-m64" suffix ] when
try-process ;
: run-test ( -- line )
os windows? "temp/a.exe" "temp/a.out" ?
ascii [ readln ] with-process-reader ;
:: test-embedding ( code -- line )
image :> image
[
I[
#include <vm/master.h>
#include <stdio.h>
#include <stdbool.h>
int main(int argc, char **argv)
{
F_PARAMETERS p;
default_parameters(&p);
p.image_path = STRING_LITERAL("${image}");
init_factor(&p);
start_embedded_factor(&p);
${code}
printf("Done.\n");
return 0;
}
]I
] with-string-writer
"resource:temp" [ compile-file ] with-directory
"resource:" [ run-test ] with-directory ;
[ "Done." ] [ "" test-embedding ] unit-test
[ "Done." ] [ "factor_yield();" test-embedding ] unit-test