From: Ben Pfaff Date: Tue, 21 Jun 2005 05:38:43 +0000 (+0000) Subject: Use temporary file instead of reference to string X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b99687391c079680373eb244a221b3ebfdb37e7;p=pintos-anon Use temporary file instead of reference to string on open() because old Perl doesn't support the latter. --- diff --git a/src/tests/tests.pm b/src/tests/tests.pm index 2e3642c..4cec83d 100644 --- a/src/tests/tests.pm +++ b/src/tests/tests.pm @@ -1,6 +1,7 @@ use strict; use warnings; use tests::Algorithm::Diff; +use File::Temp 'tempfile'; sub fail; sub pass; @@ -9,9 +10,8 @@ die if @ARGV != 2; our ($test, $src_dir) = @ARGV; our ($src_stem) = "$src_dir/$test"; -our ($messages) = ""; -open (MESSAGES, '>', \$messages); -select (MESSAGES); +my ($msg_file) = tempfile (); +select ($msg_file); sub check_expected { my ($expected) = pop @_; @@ -169,6 +169,14 @@ sub pass { sub finish { my ($verdict, @rest) = @_; + my ($messages) = ""; + seek ($msg_file, 0, 0); + while (<$msg_file>) { + $messages .= $_; + print "'$_'"; + } + close ($msg_file); + my ($result_fn) = "$test.result"; open (RESULT, '>', $result_fn) or die "$result_fn: create: $!\n"; print RESULT "$verdict\n", $messages, @rest;