Add (untested) support for reference jobs
authorMarius Gavrilescu <marius@ieval.ro>
Mon, 16 Mar 2015 14:36:34 +0000 (16:36 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Mon, 16 Mar 2015 14:36:34 +0000 (16:36 +0200)
gruntmaster-problem

index 7fe2f76a7a13a4e262a4d6170b47e90f02cf7e8f..f6d86dc8ac5db491059cd3c64dc57ecfa2ddb188 100755 (executable)
@@ -7,7 +7,8 @@ use File::Temp qw/tempfile/;
 
 use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ];
 use File::Slurp qw/read_file write_file/;
-use JSON qw/encode_json/;
+use JSON qw/decode_json encode_json/;
+use List::Util qw/max min/;
 use Term::ANSIColor qw/RED RESET/;
 use Getopt::Long qw/:config require_order/;
 
@@ -143,6 +144,34 @@ Private: $columns{private}
 END
 }
 
+sub cmd_check {
+       my ($id) = @_;
+       my @jobs = $db->jobs->search({problem => $id, reference => { '!=', undef }})->all;
+       say 'Rerunning ' . @jobs . ' reference jobs...';
+       $_->rerun for @jobs;
+       sleep 1 while $db->jobs->search({problem => $id, result_text => undef})->count;
+
+       my (@good_times, @fail_times, $fail);
+
+       for (@jobs) {
+               $_->discard_changes;
+               my @times = map { $_->{time} } @{decode_json $_->results};
+               push @good_times, @times if $_->reference == 0;
+               push @fail_times, @times if $_->reference == 3;
+               if ($_->result == $_->reference) {
+                       say 'Job ' . $_->id . ' OK'
+               } else {
+                       say 'Job ' . $_->id . ' got ' . $_->result . ' instead of ' . $_->reference;
+                       $fail = 1;
+               }
+       }
+
+       say 'Max time for AC: ' . max @good_times;
+       say 'Min time for TLE: ' . min @fail_times;
+       say $fail ? 'Test failed' : 'Test successful';
+       exit $fail;
+}
+
 ##################################################
 
 my $cmd = 'cmd_' . shift;
This page took 0.012059 seconds and 4 git commands to generate.