From 436a285f18e42b19e581d1e673bf55766934f10b Mon Sep 17 00:00:00 2001 From: bgottesman Date: Tue, 16 Aug 2011 10:51:43 +0000 Subject: stop using 'subtest' because it doesn't work for everyone, e.g. Hieu reports it doesn't work on a Mac even with an up-to-date Test::Simple module git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4144 1f5c12ca-751b-0410-a591-d2e778427230 --- regression-testing/run-test-detokenizer.perl | 42 +++++++++++++--------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'regression-testing/run-test-detokenizer.perl') diff --git a/regression-testing/run-test-detokenizer.perl b/regression-testing/run-test-detokenizer.perl index 22b796c6b..e297b90be 100755 --- a/regression-testing/run-test-detokenizer.perl +++ b/regression-testing/run-test-detokenizer.perl @@ -187,7 +187,7 @@ sub runDetokenizerTest { # $stdinFile, if defined, is a file to send to the command via STDIN # $buildCommandRoutineReference is a reference to a zero-argument subroutine that returns the # system command to run in the form of an array reference -# $validationRoutineReference is a reference to a zero-argument subroutine that makes some calls +# $validationRoutineReference is a reference to a zero-argument subroutine that makes exactly one call # to ok() or similar to validate the contents of the output directory # $separateStdoutFromStderr is an optional boolean argument; if omitted or false, the command's # STDOUT and STDERR are mixed together in out output file called @@ -200,31 +200,27 @@ sub runDetokenizerTest { sub runTest { my ($testName, $outputDir, $stdinFile, $buildCommandRoutineReference, $validationRoutineReference, $separateStdoutFromStderr, $failureExplanation) = @_; - # Note: You may need to upgrade your version of the Perl module Test::Simple in order to get this 'subtest' thing to work. (Perl modules are installed/upgraded using CPAN; google 'how do I upgrade a perl module') - subtest $testName => sub { - my ($stdoutFile, $stderrFile); - if ($separateStdoutFromStderr) { - $stdoutFile = catfile($outputDir, "stdout.txt"); - $stderrFile = catfile($outputDir, "stderr.txt"); - } else { - $stdoutFile = catfile($outputDir, "stdout-and-stderr.txt"); - $stderrFile = $stdoutFile; - } - - my $commandRef = $buildCommandRoutineReference->(); - my $exitStatus = &runVerbosely($commandRef, $stdinFile, $stdoutFile, $stderrFile); - return unless is($exitStatus, 0, $testName.": command exited with status 0"); + my ($stdoutFile, $stderrFile); + if ($separateStdoutFromStderr) { + $stdoutFile = catfile($outputDir, "stdout.txt"); + $stderrFile = catfile($outputDir, "stderr.txt"); + } else { + $stdoutFile = catfile($outputDir, "stdout-and-stderr.txt"); + $stderrFile = $stdoutFile; + } - if (defined $failureExplanation) { - TODO: { - local $TODO = $failureExplanation; - $validationRoutineReference->(); - } - } else { - $validationRoutineReference->(); + my $commandRef = $buildCommandRoutineReference->(); + my $exitStatus = &runVerbosely($commandRef, $stdinFile, $stdoutFile, $stderrFile); + return fail($testName.": command exited with status ".$exitStatus) unless $exitStatus == 0; + if (defined $failureExplanation) { + TODO: { + local $TODO = $failureExplanation; + $validationRoutineReference->(); } - }; + } else { + $validationRoutineReference->(); + } } # Announce that we're going to run the given command, then run it. -- cgit v1.2.3