Make test definitions more function like
This commit is contained in:
parent
826885df8a
commit
512e1a988a
@ -12,6 +12,7 @@ int tt_fd[2];
|
|||||||
int tt_color = 1;
|
int tt_color = 1;
|
||||||
|
|
||||||
extern tt_test tt_tests[];
|
extern tt_test tt_tests[];
|
||||||
|
extern char *tt_test_names[];
|
||||||
|
|
||||||
#ifndef TT_BUFFER_SIZE
|
#ifndef TT_BUFFER_SIZE
|
||||||
#define TT_BUFFER_SIZE 512
|
#define TT_BUFFER_SIZE 512
|
||||||
@ -63,7 +64,7 @@ extern tt_test tt_tests[];
|
|||||||
free(tt_lhs_c); free(tt_rhs_c); \
|
free(tt_lhs_c); free(tt_rhs_c); \
|
||||||
}while(0);
|
}while(0);
|
||||||
|
|
||||||
#define TEST(name, ...) void ttt_##name() { tt_current_test = #name; if(tt_before) tt_before(); __VA_ARGS__ }
|
#define TEST(name void ttt_##name()
|
||||||
|
|
||||||
#define BEFORE(body) void tt_before() { body }
|
#define BEFORE(body) void tt_before() { body }
|
||||||
|
|
||||||
@ -91,6 +92,8 @@ int main(int argc, char **argv)
|
|||||||
if(!(pid = fork()))
|
if(!(pid = fork()))
|
||||||
{
|
{
|
||||||
close(tt_fd[0]);
|
close(tt_fd[0]);
|
||||||
|
tt_current_test = tt_test_names[i];
|
||||||
|
if(tt_before) tt_before();
|
||||||
tt_tests[i]();
|
tt_tests[i]();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
11
ttest
11
ttest
@ -10,8 +10,15 @@ main()
|
|||||||
for suite in $files; do
|
for suite in $files; do
|
||||||
|
|
||||||
cp $suite $suite.c
|
cp $suite $suite.c
|
||||||
local tests=`sed -n -e 's/^\s*TEST(\([^,]*,\).*$/ttt_\1/p' $suite`
|
local tests=`sed -n -e 's/^\s*TEST(\([^,]*\)).*$/ttt_\1/p' $suite`
|
||||||
echo "tt_test tt_tests[] = {${tests}0};" >> $suite.c
|
|
||||||
|
echo "tt_test tt_tests[] = {" >> $suite.c
|
||||||
|
for t in $tests; do echo "$t," >> $suite.c; done
|
||||||
|
echo "0};" >> $suite.c
|
||||||
|
|
||||||
|
echo "char *tt_test_names[] = {" >> $suite.c
|
||||||
|
for t in $tests; do echo "\"$t\"," >> $suite.c; done
|
||||||
|
echo "\"\"};" >> $suite.c
|
||||||
|
|
||||||
test_exec=`mktemp /tmp/tmp.XXXXXX`
|
test_exec=`mktemp /tmp/tmp.XXXXXX`
|
||||||
compiler_output=`cc $suite.c -o $test_exec -ggdb -I $dir/include -DTTEST 2>&1`
|
compiler_output=`cc $suite.c -o $test_exec -ggdb -I $dir/include -DTTEST 2>&1`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user