execute a programman REPL with perl

107 views Asked by At

I have a C program, and I must be write tests with Perl and Test::More.
But, my C program is a REPL.
This is a brief example the this running:
COMPILE

clang main.c -o database.db
./database.db

INITIAL APPARENCE

db>

EXECUTE COMMAND IN THIS

db> insert 1 guilherme

... well ... this is a program running.

Now, I have a tests in Perl and it is this:
TEST IF COMPILE OK

ok(&compile(), "Compile is sucess");
sub compile {
    my $compile = "clang $SRC_PATH/main.c -o test.db";
    system $compile;
    return -e "test.db";
}

Now, I needed send commands after executing the program in C.

system "./test.db"
... parse commands

But every time executing program with the perl system ... the test lock:

3 warnings generated.

ok 1 - Compile is sucess

the first test runed, but the second tests not running.

Somebody help me a execute program REPL in the Perl script or other language??

project_link

0

There are 0 answers