Skip to content

Commit

Permalink
tntlua: implement a basic testing framework.
Browse files Browse the repository at this point in the history
  • Loading branch information
kostja committed Oct 4, 2012
1 parent c02be5a commit 08efc51
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*.reject
8 changes: 8 additions & 0 deletions test/README
@@ -0,0 +1,8 @@
How to run tests:

./run.pl test.lua

What ./run.pl does:

cat queue.lua | tarantool > queue.reject
diff -u queue.reject queue.result
2 changes: 2 additions & 0 deletions test/queue.lua
@@ -0,0 +1,2 @@
lua l = box.queue.put(0, 0, 'hello')
lua box.queue.delete(0, box.unpack('l', l[0]))
Empty file added test/queue.result
Empty file.
27 changes: 27 additions & 0 deletions test/run.pl
@@ -0,0 +1,27 @@
#!/usr/bin/env perl
use strict;
#use autodie;
use File::Basename;
use File::Spec;
use Cwd qw(abs_path);

my $test = abs_path($ARGV[0]);

-e $test or die "No such test: $test\n";

my $module = basename($test);

my $module = File::Spec->catfile(dirname(dirname($test)), $module);

-e $module or die "The test doesn't have a module to load: $module";

(my $result = $test) =~ s/\.[^.]+$/.result/;
(my $reject = $test) =~ s/\.[^.]+$/.reject/;

system "echo 'lua dofile(\"$module\")' | tarantool > /dev/null";

system "cat $test | tarantool > $reject";

system "diff -u $result $reject";

print "Success!\n" if $_ == 0;

0 comments on commit 08efc51

Please sign in to comment.