Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tntlua: implement a basic testing framework.
- Loading branch information
Showing
5 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.reject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lua l = box.queue.put(0, 0, 'hello') | ||
lua box.queue.delete(0, box.unpack('l', l[0])) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |