From: Marius Gavrilescu Date: Sun, 8 Feb 2015 13:27:29 +0000 (+0200) Subject: Add some tests with invalid jobs X-Git-Tag: 5999.000_005~46 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=fcfcfb939965f2536e812d3138a208008b1eb601;p=gruntmaster-daemon.git Add some tests with invalid jobs --- diff --git a/MANIFEST b/MANIFEST index 3bf7574..824d595 100644 --- a/MANIFEST +++ b/MANIFEST @@ -89,6 +89,10 @@ t/problems/double/9.ok t/problems/double/meta.yml t/problems/double/tests/wa/meta.yml t/problems/double/tests/wa/prog.c +t/problems/errors/tests/nonexistent-runner/meta.yml +t/problems/errors/tests/invalid-runner/meta.yml +t/problems/errors/tests/no-runner/meta.yml +t/problems/errors/meta.yml t/problems/hello/1.in t/problems/hello/1.ok t/problems/hello/meta.yml diff --git a/lib/Gruntmaster/Daemon.pm b/lib/Gruntmaster/Daemon.pm index 4f3360c..1c58550 100644 --- a/lib/Gruntmaster/Daemon.pm +++ b/lib/Gruntmaster/Daemon.pm @@ -38,7 +38,7 @@ my $db; sub safe_can { my ($type, $sub, $name) = @_; - return unless $name =~ /^\w+$/s; + get_logger->logdie("Invalid \l$type: '$name'") unless $name =~ /^\w+$/s; my $pkg = __PACKAGE__ . "::${type}::${name}"; eval "require $pkg" or get_logger->warn("Error while requiring $pkg: $@"); $pkg->can($sub) or get_logger->logdie("No such \l$type: '$name'"); diff --git a/t/01-jobs.t b/t/01-jobs.t index 4e0304a..4d4f8bc 100644 --- a/t/01-jobs.t +++ b/t/01-jobs.t @@ -81,10 +81,12 @@ for my $problem (@problems) { for my $source (<$problem/tests/*>) { SKIP: { my $meta = LoadFile "$source/meta.yml"; - my $compiler = COMPILER->{$meta->{files}{prog}{format}}; - skip "$compiler not found in path", 3 unless $ENV{GRUNTMASTER_VM} || which $compiler; - local $TODO = $meta->{todo} if exists $meta->{todo}; - $meta->{files}{prog}{content} = read_file "$source/$meta->{files}{prog}{name}"; + if ($meta->{files}{prog}) { + my $compiler = COMPILER->{$meta->{files}{prog}{format}}; + skip "$compiler not found in path", 3 unless $ENV{GRUNTMASTER_VM} || which $compiler; + local $TODO = $meta->{todo} if exists $meta->{todo}; + $meta->{files}{prog}{content} = read_file "$source/$meta->{files}{prog}{name}"; + } $meta = merge $meta, $pbmeta; note "Running $meta->{test_name} ($meta->{test_description})..."; my $savedcwd = getcwd; diff --git a/t/problems/errors/meta.yml b/t/problems/errors/meta.yml new file mode 100644 index 0000000..861d54c --- /dev/null +++ b/t/problems/errors/meta.yml @@ -0,0 +1,6 @@ +--- +name: Errors +description: A 'problem' that produces various errors +generator: Undef +judge: Absolute +testcnt: 1 diff --git a/t/problems/errors/tests/invalid-runner/meta.yml b/t/problems/errors/tests/invalid-runner/meta.yml new file mode 100644 index 0000000..053bc00 --- /dev/null +++ b/t/problems/errors/tests/invalid-runner/meta.yml @@ -0,0 +1,5 @@ +test_name: Invalid Runner +test_description: A job with an invalid Runner +runner: this_is_invalid! +expected_result: -1 +expected_result_text: "Invalid runner: 'this_is_invalid!'" \ No newline at end of file diff --git a/t/problems/errors/tests/no-runner/meta.yml b/t/problems/errors/tests/no-runner/meta.yml new file mode 100644 index 0000000..9dc2036 --- /dev/null +++ b/t/problems/errors/tests/no-runner/meta.yml @@ -0,0 +1,4 @@ +test_name: No Runner +test_description: A job with no Runner +expected_result: -1 +expected_result_text: "Required parameter missing: runner" \ No newline at end of file diff --git a/t/problems/errors/tests/nonexistent-runner/meta.yml b/t/problems/errors/tests/nonexistent-runner/meta.yml new file mode 100644 index 0000000..2abc8d1 --- /dev/null +++ b/t/problems/errors/tests/nonexistent-runner/meta.yml @@ -0,0 +1,5 @@ +test_name: Nonexistent Runner +test_description: A job with a non-existent Runner +runner: FakeRunner +expected_result: -1 +expected_result_text: "No such runner: 'FakeRunner'" \ No newline at end of file