From: Marius Gavrilescu Date: Mon, 16 Mar 2015 16:11:50 +0000 (+0200) Subject: Make gruntmaster-problem check also set/clear time limit overrides X-Git-Tag: 5999.000_014~54 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=a1da4db78107158bbaed8a10a695d4e59ffe6c0b;p=gruntmaster-data.git Make gruntmaster-problem check also set/clear time limit overrides --- diff --git a/gruntmaster-problem b/gruntmaster-problem index 20f6a4f..e74449b 100755 --- a/gruntmaster-problem +++ b/gruntmaster-problem @@ -145,7 +145,9 @@ END } sub cmd_check { - my ($id) = @_; + my ($set, $clear); + GetOptions ( 'set|s' => \$set, 'clear|c' => \$clear ); + my ($id) = @ARGV; my @jobs = $db->jobs->search({problem => $id, reference => { '!=', undef }})->all; say 'Rerunning ' . @jobs . ' reference jobs...'; $_->rerun for @jobs; @@ -169,11 +171,27 @@ sub cmd_check { printf "Min timeout for %s: %.2fs\n", $_, $pass{$_} for keys %pass; printf "Max timeout for %s: %.2fs\n", $_, $fail{$_} for keys %fail; say $fail ? 'Test failed' : 'Test successful'; + + if ($clear) { + $db->limits->search({problem => $id})->delete; + say 'Cleared time limits'; + } + + if ($set) { + for (keys %pass) { + my $time = $pass{$_}; + $time = sprintf '%.1f', $time * 3/2 + 0.1; + $db->limits->create({problem => $id, format => $_, timeout => $time}); + say "Set time limit for $_ to $time"; + } + } + exit $fail if $fail; } ################################################## +Getopt::Long::Configure 'bundling'; my $cmd = 'cmd_' . shift; cmd_help unless exists $main::{$cmd}; no strict 'refs'; @@ -197,7 +215,7 @@ gruntmaster-problem - shell interface to Gruntmaster 6000 problems gruntmaster-problem set [--file] problem_id key value gruntmaster-problem get problem_id key gruntmaster-problem edit problem_id key - gruntmaster-problem check problem_id + gruntmaster-problem check [-cs] [--clear] [--set] problem_id =head1 DESCRIPTION @@ -237,10 +255,14 @@ Opens an editor with the value of the I configuration option. After the edi Sets the I configuration option of problem I to the contents of the file I. -=item B I +=item B [args] I Rerun all reference jobs for problem I and check their results. +With the I<--clear> or I<-c> argument, removes all time limit overrides for this problem. + +With the I<--set> or I<-s> argument, automatically adds time limit overrides based on the times used by the reference solutions. + =back =head1 AUTHOR