X-Git-Url: http://git.ieval.ro/?p=gruntmaster-daemon.git;a=blobdiff_plain;f=lib%2FGruntmaster%2FDaemon%2FRunner%2FFile.pm;h=7f67fb301a35a7b359c879a6c374bd5803e3bce6;hp=57555ac40e9e3f4c61edc0092e500a2f7db1eb31;hb=07d71f40d79d16bd14d446a67a3b50ce6b97cd7e;hpb=5c5cd38ad5b9e3c2b331564bc0b23e9167b7d07a diff --git a/lib/Gruntmaster/Daemon/Runner/File.pm b/lib/Gruntmaster/Daemon/Runner/File.pm index 57555ac..7f67fb3 100644 --- a/lib/Gruntmaster/Daemon/Runner/File.pm +++ b/lib/Gruntmaster/Daemon/Runner/File.pm @@ -8,6 +8,8 @@ use Gruntmaster::Daemon::Constants qw/WA/; use File::Slurp qw/slurp/; use Log::Log4perl qw/get_logger/; +our $VERSION = "5999.000_001"; + ################################################## sub run{ @@ -15,7 +17,13 @@ sub run{ 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 = slurp "$test.ok"; + my $ok; + if (exists $meta->{okfile}) { + $ok = $meta->{okfile}[$test - 1] + } else { + my $ct = defined $Gruntmaster::Data::contest ? "ct/$Gruntmaster::Data::contest" : ''; + $ok = slurp "/var/lib/gruntmasterd/$ct/pb/$meta->{problem}/$test.ok" + } $out =~ s/^\s+//; $ok =~ s/^\s+//; @@ -28,4 +36,36 @@ sub run{ $meta->{tests}[$test - 1] // 0 } -1 +1; +__END__ + +=encoding utf-8 + +=head1 NAME + +Gruntmaster::Daemon::Runner::File - Compare output with static text files + +=head1 SYNOPSIS + + use Gruntmaster::Daemon::Runner::File; + 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. + +=head1 AUTHOR + +Marius Gavrilescu Emarius@ieval.roE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2014 by Marius Gavrilescu + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + + +=cut