commit f99ba396105eb2790b3d4ff87df1721e0e086337
parent 5c0b99af303ae53fda1f15c31626c92f46f07231
Author: kyle <kyle@0x30.net>
Date: Sun, 27 Dec 2015 18:14:49 -0700
tests: don't export TEST_DIR anymore
- it was used by the fail() function to show some error context
- turns out in Perl you can get the callsite of a function your inside of
- you can get the exact line number and file name too, so just use those
Diffstat:
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/run_tests.sh b/run_tests.sh
@@ -25,7 +25,6 @@ count=0
for t in `ls tests/*/Makefile`; do
count=`expr $count + 1`
test_dir=`dirname ${t}`
- export TEST_DIR="$test_dir"
make -s -C $test_dir clean
perl -T sl -p $PORT -t > $test_dir/server.log &
diff --git a/tests/test.pm b/tests/test.pm
@@ -13,9 +13,8 @@ our (%msg_num, @msg_str);
our @EXPORT = qw(new_socket fail send_msg recv_msg %msg_num @msg_str SHUT_RDWR);
sub fail {
- my $test_dir = '.';
- $test_dir = $ENV{TEST_DIR} if ($ENV{TEST_DIR});
- print "$test_dir/$0: " . shift . "\n";
+ my (undef, $file, $line) = caller;
+ print "$file:$line: " . shift . "\n";
exit 1;
}