Add some tests with invalid jobs
authorMarius Gavrilescu <marius@ieval.ro>
Sun, 8 Feb 2015 13:27:29 +0000 (15:27 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sun, 8 Feb 2015 14:04:00 +0000 (16:04 +0200)
MANIFEST
lib/Gruntmaster/Daemon.pm
t/01-jobs.t
t/problems/errors/meta.yml [new file with mode: 0644]
t/problems/errors/tests/invalid-runner/meta.yml [new file with mode: 0644]
t/problems/errors/tests/no-runner/meta.yml [new file with mode: 0644]
t/problems/errors/tests/nonexistent-runner/meta.yml [new file with mode: 0644]

index 3bf7574..824d595 100644 (file)
--- 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
index 4f3360c..1c58550 100644 (file)
@@ -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'");
index 4e0304a..4d4f8bc 100644 (file)
@@ -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 (file)
index 0000000..861d54c
--- /dev/null
@@ -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 (file)
index 0000000..053bc00
--- /dev/null
@@ -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 (file)
index 0000000..9dc2036
--- /dev/null
@@ -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 (file)
index 0000000..2abc8d1
--- /dev/null
@@ -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
This page took 0.032434 seconds and 4 git commands to generate.