]>
iEval git - gruntmaster-data.git/blob - t/tools.t
077185d99944ba06d910baef43ce437ea75cc97d
11 dbinit
'dbi:Pg:dbname=gmtest'; 1;
12 } or plan skip_all
=> 'Cannot connect to test database. Create it by running make_test_db.sh before running this test. '. "Error: $@";
13 no warnings
'redefine';
14 *Gruntmaster
::App
::dbinit
= sub {}; # Prevent reinit in Gruntmaster::App->run
19 open my $fakein, '<', \
$_[0];
24 my ($args, $out, $err) = @_;
25 my $ret = test_app
'Gruntmaster::App' => $args;
26 diag
'Error: ', $ret->error if defined $ret->error;
27 is
$ret->output, "$out\n", join ' ', gm
=> @
$args if defined $out;
40 subtest
'gm -c add ct' => sub {
42 my $ct = contest_entry
'ct';
43 is
$ct->{name
}, 'My cool contest', 'contest name';
44 is
$ct->{owner
}, 'MGV', 'contest owner';
45 is
$ct->{start
}, 1388534400, 'contest start';
46 is
$ct->{stop
}, 1388534400 + 5 * 60 * 60, 'contest stop';
50 my $out = ta
([qw
/-c show ct/])->output;
51 like
$out, qr/Name: My cool contest/, 'gm -c show ct contains Name'
54 ta
[qw
/-c get ct owner/], 'MGV';
55 ta
[qw
/-c set ct owner nobody/];
56 ta
[qw
/-c get ct owner/], 'nobody';
57 ta
[qw
/-c list/], join "\n", sort qw
/fc rc pc ct/;
59 ok
!defined contest_entry
('ct'), 'gm -c rm ct';
84 my $out = ta
([qw
/-p show pb/])->output;
85 like
$out, qr/Value \(points\): 250/, 'gm -p show pb contains Value'
88 subtest
'gruntmaster-problem add' => sub {
90 my $pb = problem_entry
'pb';
91 ok
$pb, 'problem exists';
92 is
$pb->{name
}, 'Test problem', 'name';
93 ok
$pb->{private
}, 'private';
94 is
$pb->{author
}, 'Marius Gavrilescu', 'author';
95 is
$pb->{writer
}, 'Smaranda Ciubotaru', 'statement writer';
96 is
$pb->{owner
}, 'MGV', 'owner';
97 is
$pb->{level
}, 'easy', 'level';
98 is
$pb->{timeout
}, 1, 'time limit';
99 is
$pb->{olimit
}, 100, 'output limit';
100 ok contest_has_problem
('ct', 'pb'), 'is in contest';
103 ta
[qw
/-p get pb author/], 'Marius Gavrilescu';
104 ta
[qw
/-p set pb owner nobody/];
105 ta
[qw
/-p get pb owner/], 'nobody';
106 ta
[qw
/-p set --file pb statement README/];
107 like problem_entry
('pb')->{statement
}, qr/Gruntmaster-Data/, 'gm -p set --file pb statement README';
108 ta
[qw
/-p list/], join "\n", sort qw
/arc pca rca fca prv pb/;
110 ok
!defined problem_entry
('pb'), 'gm -p rm pb';
112 my $id = create_job extension
=> '.cpp', format
=> 'CPP', problem
=> 'arc', source
=> '...', owner
=> 'MGV';
113 ok
abs (time - user_entry
('MGV')->{lastjob
}) < 2, 'create_job - lastjob looks sane';
115 is job_entry
($id)->{result
}, -2, "gm rerun $id";
119 my @fca_jobs = grep { $_->{problem
} eq 'fca' } @
{job_list
()};
120 ok
((!grep { $_->{result
} != -2 } @fca_jobs), "gm rerun fca");
123 my ($args, $err) = @_;
124 my $ret = test_app
'Gruntmaster::App' => $args;
125 like
$ret->error, qr/$err/, join ' ', 'invalid:', gm
=> @
$args;
129 terr
[qw
/add/], 'No table selected';
130 terr
[qw
/-j add/], 'Don\'t know how to add to this table';
131 terr
[qw
/-c add/], 'Wrong number of arguments';
132 terr
[qw
/get/], 'No table selected';
133 terr
[qw
/-c get/], 'Wrong number of arguments';
134 terr
[qw
/list/], 'No table selected';
135 terr
[qw
/-j rerun/], 'Not enough arguments';
136 terr
[qw
/rm/], 'No table selected';
137 terr
[qw
/-j rm/], 'Wrong number of arguments';
138 terr
[qw
/set/], 'No table selected';
139 terr
[qw
/-j set 1 owner/], 'Not enough arguments';
140 terr
[qw
/-j set 1 owner x name/], 'The number of arguments must be odd';
141 terr
[qw
/show/], 'No table selected';
142 terr
[qw
/-c show/], 'Wrong number of arguments';
This page took 0.055423 seconds and 4 git commands to generate.