X-Git-Url: http://git.ieval.ro/?p=gruntmaster-daemon.git;a=blobdiff_plain;f=lib%2FGruntmaster%2FDaemon%2FRunner%2FFile.pm;h=6d7b8f81fa8195d8c98469468373df6ee079f50d;hp=6fc66c2b00631dc6b6207bbd22b9042f90f4d50a;hb=69ea9358b59a6d8bd566c3af22247e8c2e35320f;hpb=593a8e6f0682094a1622622971f1143ace9d3980 diff --git a/lib/Gruntmaster/Daemon/Runner/File.pm b/lib/Gruntmaster/Daemon/Runner/File.pm index 6fc66c2..6d7b8f8 100644 --- a/lib/Gruntmaster/Daemon/Runner/File.pm +++ b/lib/Gruntmaster/Daemon/Runner/File.pm @@ -8,26 +8,31 @@ use Gruntmaster::Daemon::Constants qw/WA/; use File::Slurp qw/slurp/; use Log::Log4perl qw/get_logger/; -our $VERSION = "5999.000_001"; +our $VERSION = "5999.000_003"; ################################################## sub run{ - my ($test, $meta) = @_; - get_logger->trace("Running on test $test..."); - $meta->{files}{prog}{run}->($meta->{files}{prog}{name}, fds => [qw/0 input 1 >output/], map {defined $meta->{$_} ? ($_ => $meta->{$_}) : () } qw/timeout olimit mlimit/); - my $out = slurp 'output'; - my $ok = $meta->{okfile}[$test - 1]; - - $out =~ s/^\s+//; - $ok =~ s/^\s+//; - $out =~ s/\s+/ /; - $ok =~ s/\s+/ /; - $out =~ s/\s+$//; - $ok =~ s/\s+$//; - - die [WA, "Wrong answer"] if $out ne $ok; - $meta->{tests}[$test - 1] // 0 + my ($test, $meta) = @_; + get_logger->trace("Running on test $test..."); + $meta->{files}{prog}{run}->($meta->{files}{prog}{name}, fds => [qw/0 input 1 >output/], map {defined $meta->{$_} ? ($_ => $meta->{$_}) : () } qw/timeout olimit mlimit/); + my $out = slurp 'output'; + my $ok; + if (exists $meta->{okfile}) { + $ok = $meta->{okfile}[$test - 1] + } else { + $ok = slurp "/var/lib/gruntmasterd/pb/$meta->{problem}/$test.ok" + } + + $out =~ s/^\s+//; + $ok =~ s/^\s+//; + $out =~ s/\s+/ /g; + $ok =~ s/\s+/ /g; + $out =~ s/\s+$//; + $ok =~ s/\s+$//; + + die [WA, "Wrong answer"] if $out ne $ok; + $meta->{tests}[$test - 1] // 0 } 1; @@ -42,11 +47,16 @@ Gruntmaster::Daemon::Runner::File - Compare output with static text files =head1 SYNOPSIS use Gruntmaster::Daemon::Runner::File; - Gruntmaster::Daemon::Runner::File->run(5, $meta); + Gruntmaster::Daemon::Runner::File::run(5, $meta); =head1 DESCRIPTION -Gruntmaster::Daemon::Runner::File is a runner which compares the program output for test C<$test> with C<< $meta->{tests}[$test - 1] >>. Before comparing, leading and trailing whitespace is removed, and sequences of whitespace are converted to a single space. +Gruntmaster::Daemon::Runner::File is a runner which compares the program output for test C<$test> with a static output. Before comparing, leading and trailing whitespace is removed, and sequences of whitespace are converted to a single space. + +If C<< $meta->{okfile} >> exists, the output is compared to C<< $meta->{okfile}[$test - 1] >>. +Otherwise, the output is compared to F<< /var/lib/gruntmasterd/pb/$meta->{problem}/$test.ok >>. + +If the two strings match, the verdict is C<< $meta->{tests}[$test - 1] >>. Otherwise, the verdict is C<[WA, "Wrong answer"]>. =head1 AUTHOR