Add hello world tests for all languages (enabled when RELEASE_TESTING is true)
authorMarius Gavrilescu <marius@ieval.ro>
Sun, 25 Jan 2015 15:43:40 +0000 (17:43 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sun, 25 Jan 2015 15:43:40 +0000 (17:43 +0200)
27 files changed:
MANIFEST
Makefile.PL
t/01-jobs.t
t/problems/hello/1.in [new file with mode: 0644]
t/problems/hello/1.ok [new file with mode: 0644]
t/problems/hello/meta.yml [new file with mode: 0644]
t/problems/hello/tests/c/meta.yml [new file with mode: 0644]
t/problems/hello/tests/c/prog.c [new file with mode: 0644]
t/problems/hello/tests/cpp/meta.yml [new file with mode: 0644]
t/problems/hello/tests/cpp/prog.cpp [new file with mode: 0644]
t/problems/hello/tests/gccgo/meta.yml [new file with mode: 0644]
t/problems/hello/tests/gccgo/prog.go [new file with mode: 0644]
t/problems/hello/tests/golang/meta.yml [new file with mode: 0644]
t/problems/hello/tests/golang/prog.go [new file with mode: 0644]
t/problems/hello/tests/haskell/meta.yml [new file with mode: 0644]
t/problems/hello/tests/haskell/prog.hs [new file with mode: 0644]
t/problems/hello/tests/java/meta.yml [new file with mode: 0644]
t/problems/hello/tests/java/prog.java [new file with mode: 0644]
t/problems/hello/tests/mono/meta.yml [new file with mode: 0644]
t/problems/hello/tests/mono/prog.cs [new file with mode: 0644]
t/problems/hello/tests/mono/prog.exe [new file with mode: 0755]
t/problems/hello/tests/pascal/meta.yml [new file with mode: 0644]
t/problems/hello/tests/pascal/prog.pas [new file with mode: 0644]
t/problems/hello/tests/perl/meta.yml [new file with mode: 0644]
t/problems/hello/tests/perl/prog.pl [new file with mode: 0644]
t/problems/hello/tests/python/meta.yml [new file with mode: 0644]
t/problems/hello/tests/python/prog.py [new file with mode: 0644]

index 5c441b2c445c876fdb5714c95447144019526672..3bf7574ac85536f93bb8a25ca324be4abfc5a46b 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -89,6 +89,30 @@ 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/double/meta.yml
 t/problems/double/tests/wa/meta.yml
 t/problems/double/tests/wa/prog.c
+t/problems/hello/1.in
+t/problems/hello/1.ok
+t/problems/hello/meta.yml
+t/problems/hello/tests/c/meta.yml
+t/problems/hello/tests/cpp/meta.yml
+t/problems/hello/tests/cpp/prog.cpp
+t/problems/hello/tests/c/prog.c
+t/problems/hello/tests/gccgo/meta.yml
+t/problems/hello/tests/gccgo/prog.go
+t/problems/hello/tests/golang/meta.yml
+t/problems/hello/tests/golang/prog.go
+t/problems/hello/tests/haskell/meta.yml
+t/problems/hello/tests/haskell/prog.hs
+t/problems/hello/tests/java/meta.yml
+t/problems/hello/tests/java/prog.java
+t/problems/hello/tests/mono/meta.yml
+t/problems/hello/tests/mono/prog.cs
+t/problems/hello/tests/mono/prog.exe
+t/problems/hello/tests/pascal/meta.yml
+t/problems/hello/tests/pascal/prog.pas
+t/problems/hello/tests/perl/meta.yml
+t/problems/hello/tests/perl/prog.pl
+t/problems/hello/tests/python/meta.yml
+t/problems/hello/tests/python/prog.py
 t/problems/increment/ver.c
 t/problems/increment/meta.yml
 t/problems/increment/tests/ac/meta.yml
 t/problems/increment/ver.c
 t/problems/increment/meta.yml
 t/problems/increment/tests/ac/meta.yml
index f7d5e99a1fc9b72fb73394bda6dfd9a68d295cc5..5baa62ab2d993952bbd3e546eb411d115cc2503d 100644 (file)
@@ -14,6 +14,7 @@ WriteMakefile(
                   File::Basename 0
                   File::Slurp 0
                   File::Temp 0
                   File::Basename 0
                   File::Slurp 0
                   File::Temp 0
+                  File::Which 0
                   Hash::Merge 0
                   List::Util 0
                   Log::Log4perl 0
                   Hash::Merge 0
                   List::Util 0
                   Log::Log4perl 0
index a4e0c027ad25ca6b59314a3a1c166d2f1aefd62a..4b763104d1dce74d4f0de8b0883db157b458e53f 100644 (file)
@@ -9,6 +9,7 @@ use Cwd qw/cwd/;
 use File::Basename qw/fileparse/;
 use File::Slurp qw/read_file/;
 use File::Temp qw/tempdir/;
 use File::Basename qw/fileparse/;
 use File::Slurp qw/read_file/;
 use File::Temp qw/tempdir/;
+use File::Which qw/which/;
 use Hash::Merge qw/merge/;
 use List::Util qw/sum/;
 use Log::Log4perl;
 use Hash::Merge qw/merge/;
 use List::Util qw/sum/;
 use Log::Log4perl;
@@ -17,6 +18,18 @@ use YAML::Any qw/LoadFile/;
 
 ##################################################
 
 
 ##################################################
 
+use constant COMPILER => {
+       qw/C gcc
+          CPP g++
+          MONO gmcs
+          JAVA javac
+          PASCAL fpc
+          GOLANG go
+          GCCGO gccgo
+          HASKELL ghc
+          PERL perl
+          PYTHON python/};
+
 my $loglevel = $ENV{TEST_LOG_LEVEL} // ($ENV{TEST_VERBOSE} ? 'TRACE' : 'OFF');
 my $log_conf = <<CONF;
 log4perl.category.Gruntmaster.Daemon = $loglevel, stderr
 my $loglevel = $ENV{TEST_LOG_LEVEL} // ($ENV{TEST_VERBOSE} ? 'TRACE' : 'OFF');
 my $log_conf = <<CONF;
 log4perl.category.Gruntmaster.Daemon = $loglevel, stderr
@@ -41,6 +54,8 @@ sub check_job{
 }
 
 my @problems = exists $ENV{TEST_PROBLEMS} ? map {"t/problems/$_"} split ' ', $ENV{TEST_PROBLEMS} : <t/problems/*>;
 }
 
 my @problems = exists $ENV{TEST_PROBLEMS} ? map {"t/problems/$_"} split ' ', $ENV{TEST_PROBLEMS} : <t/problems/*>;
+@problems = grep { $_ !~ /hello/ } @problems unless $ENV{RELEASE_TESTING} || $ENV{TEST_PROBLEMS};
+
 plan tests => 3 * sum map { my @temp = <$_/tests/*>; scalar @temp } @problems;
 note "Problems to be tested: " . join ', ', @problems;
 
 plan tests => 3 * sum map { my @temp = <$_/tests/*>; scalar @temp } @problems;
 note "Problems to be tested: " . join ', ', @problems;
 
@@ -64,15 +79,20 @@ for my $problem (@problems) {
                note "Now testing problem $pbmeta->{name} ($pbmeta->{description})";
 
                for my $source (<$problem/tests/*>) {
                note "Now testing problem $pbmeta->{name} ($pbmeta->{description})";
 
                for my $source (<$problem/tests/*>) {
-                       my $meta = LoadFile "$source/meta.yml";
-                       $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 = cwd;
-                       chdir $tempdir;
-                       Gruntmaster::Daemon::process $meta;
-                       chdir $savedcwd;
-                       check_job $meta;
+                 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}";
+                               $meta = merge $meta, $pbmeta;
+                               note "Running $meta->{test_name} ($meta->{test_description})...";
+                               my $savedcwd = cwd;
+                               chdir $tempdir;
+                               Gruntmaster::Daemon::process $meta;
+                               chdir $savedcwd;
+                               check_job $meta;
+                       }
                }
        }
 }
                }
        }
 }
diff --git a/t/problems/hello/1.in b/t/problems/hello/1.in
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/t/problems/hello/1.ok b/t/problems/hello/1.ok
new file mode 100644 (file)
index 0000000..980a0d5
--- /dev/null
@@ -0,0 +1 @@
+Hello World!
diff --git a/t/problems/hello/meta.yml b/t/problems/hello/meta.yml
new file mode 100644 (file)
index 0000000..194437b
--- /dev/null
@@ -0,0 +1,15 @@
+name: Hello World
+generator: File
+judge: Absolute
+runner: File
+testcnt: 1
+timeout: 1
+# mlimit: 20971520 # Python does not like memory limits
+olimit: 100
+description: Print "Hello World!"
+expected_result: 0
+expected_result_text: Accepted
+expected_results:
+- id: 1
+  result: 0
+  result_text: 0
diff --git a/t/problems/hello/tests/c/meta.yml b/t/problems/hello/tests/c/meta.yml
new file mode 100644 (file)
index 0000000..b254a56
--- /dev/null
@@ -0,0 +1,7 @@
+test_name: C
+test_description: Hello world in C
+problem: hello
+files:
+  prog:
+    format: C
+    name: prog.c
diff --git a/t/problems/hello/tests/c/prog.c b/t/problems/hello/tests/c/prog.c
new file mode 100644 (file)
index 0000000..298c213
--- /dev/null
@@ -0,0 +1,6 @@
+#include<stdio.h>
+
+int main(void){
+       puts("Hello World!");
+       return 0;
+}
diff --git a/t/problems/hello/tests/cpp/meta.yml b/t/problems/hello/tests/cpp/meta.yml
new file mode 100644 (file)
index 0000000..5bd35bd
--- /dev/null
@@ -0,0 +1,7 @@
+test_name: C++
+test_description: Hello world in C++
+problem: hello
+files:
+  prog:
+    format: CPP
+    name: prog.cpp
diff --git a/t/problems/hello/tests/cpp/prog.cpp b/t/problems/hello/tests/cpp/prog.cpp
new file mode 100644 (file)
index 0000000..2649ecc
--- /dev/null
@@ -0,0 +1,6 @@
+#include<cstdio>
+
+int main(void){
+       puts("Hello World!");
+       return 0;
+}
diff --git a/t/problems/hello/tests/gccgo/meta.yml b/t/problems/hello/tests/gccgo/meta.yml
new file mode 100644 (file)
index 0000000..15cde0b
--- /dev/null
@@ -0,0 +1,7 @@
+test_name: Go (gccgo)
+test_description: Hello world in Go (using gccgo)
+problem: hello
+files:
+  prog:
+    format: GCCGO
+    name: prog.go
diff --git a/t/problems/hello/tests/gccgo/prog.go b/t/problems/hello/tests/gccgo/prog.go
new file mode 100644 (file)
index 0000000..77c24d5
--- /dev/null
@@ -0,0 +1,5 @@
+package main
+import "fmt"
+func main() {
+       fmt.Println("Hello World!")
+}
\ No newline at end of file
diff --git a/t/problems/hello/tests/golang/meta.yml b/t/problems/hello/tests/golang/meta.yml
new file mode 100644 (file)
index 0000000..12ec0e1
--- /dev/null
@@ -0,0 +1,7 @@
+test_name: Go (golang)
+test_description: Hello world in Go (using golang)
+problem: hello
+files:
+  prog:
+    format: GOLANG
+    name: prog.go
diff --git a/t/problems/hello/tests/golang/prog.go b/t/problems/hello/tests/golang/prog.go
new file mode 100644 (file)
index 0000000..77c24d5
--- /dev/null
@@ -0,0 +1,5 @@
+package main
+import "fmt"
+func main() {
+       fmt.Println("Hello World!")
+}
\ No newline at end of file
diff --git a/t/problems/hello/tests/haskell/meta.yml b/t/problems/hello/tests/haskell/meta.yml
new file mode 100644 (file)
index 0000000..0d82691
--- /dev/null
@@ -0,0 +1,7 @@
+test_name: Haskell
+test_description: Hello world in Haskell
+problem: hello
+files:
+  prog:
+    format: HASKELL
+    name: prog.hs
diff --git a/t/problems/hello/tests/haskell/prog.hs b/t/problems/hello/tests/haskell/prog.hs
new file mode 100644 (file)
index 0000000..0fca251
--- /dev/null
@@ -0,0 +1,4 @@
+module Main where
+
+main :: IO ()
+main = putStrLn "Hello World!"
diff --git a/t/problems/hello/tests/java/meta.yml b/t/problems/hello/tests/java/meta.yml
new file mode 100644 (file)
index 0000000..cb66e43
--- /dev/null
@@ -0,0 +1,7 @@
+test_name: Java
+test_description: Hello world in Java
+problem: hello
+files:
+  prog:
+    format: JAVA
+    name: prog.java
diff --git a/t/problems/hello/tests/java/prog.java b/t/problems/hello/tests/java/prog.java
new file mode 100644 (file)
index 0000000..c4d820c
--- /dev/null
@@ -0,0 +1,5 @@
+public class prog {
+       public static void main(final String[] args){
+               System.out.println("Hello World!");
+       }
+}
diff --git a/t/problems/hello/tests/mono/meta.yml b/t/problems/hello/tests/mono/meta.yml
new file mode 100644 (file)
index 0000000..f2c2921
--- /dev/null
@@ -0,0 +1,8 @@
+test_name: C#
+test_description: Hello world in C#
+problem: hello
+todo: C# does not work with low output limits
+files:
+  prog:
+    format: MONO
+    name: prog.cs
diff --git a/t/problems/hello/tests/mono/prog.cs b/t/problems/hello/tests/mono/prog.cs
new file mode 100644 (file)
index 0000000..d1aed41
--- /dev/null
@@ -0,0 +1,6 @@
+using System;
+class prog {
+       static void Main() {
+               Console.WriteLine("Hello World!");
+       }
+}
\ No newline at end of file
diff --git a/t/problems/hello/tests/mono/prog.exe b/t/problems/hello/tests/mono/prog.exe
new file mode 100755 (executable)
index 0000000..754c465
Binary files /dev/null and b/t/problems/hello/tests/mono/prog.exe differ
diff --git a/t/problems/hello/tests/pascal/meta.yml b/t/problems/hello/tests/pascal/meta.yml
new file mode 100644 (file)
index 0000000..ae9faca
--- /dev/null
@@ -0,0 +1,7 @@
+test_name: Pascal
+test_description: Hello world in Pascal
+problem: hello
+files:
+  prog:
+    format: PASCAL
+    name: prog.pas
diff --git a/t/problems/hello/tests/pascal/prog.pas b/t/problems/hello/tests/pascal/prog.pas
new file mode 100644 (file)
index 0000000..d501d7e
--- /dev/null
@@ -0,0 +1,4 @@
+program HelloWorld;
+begin
+   writeln('Hello World!')
+end.
diff --git a/t/problems/hello/tests/perl/meta.yml b/t/problems/hello/tests/perl/meta.yml
new file mode 100644 (file)
index 0000000..02cd32c
--- /dev/null
@@ -0,0 +1,7 @@
+test_name: Perl
+test_description: Hello world in Perl
+problem: hello
+files:
+  prog:
+    format: PERL
+    name: prog.pl
diff --git a/t/problems/hello/tests/perl/prog.pl b/t/problems/hello/tests/perl/prog.pl
new file mode 100644 (file)
index 0000000..2d9fabf
--- /dev/null
@@ -0,0 +1,5 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+print 'Hello World!';
diff --git a/t/problems/hello/tests/python/meta.yml b/t/problems/hello/tests/python/meta.yml
new file mode 100644 (file)
index 0000000..702132f
--- /dev/null
@@ -0,0 +1,7 @@
+test_name: Python
+test_description: Hello world in Python
+problem: hello
+files:
+  prog:
+    format: PYTHON
+    name: prog.py
diff --git a/t/problems/hello/tests/python/prog.py b/t/problems/hello/tests/python/prog.py
new file mode 100644 (file)
index 0000000..b6681c7
--- /dev/null
@@ -0,0 +1,2 @@
+#!/usr/bin/python
+print 'Hello World!';
This page took 0.02512 seconds and 4 git commands to generate.