From b8f7001a80665c35f33aed657ead2a426d4efac8 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sun, 25 Jan 2015 17:43:40 +0200 Subject: [PATCH] Add hello world tests for all languages (enabled when RELEASE_TESTING is true) --- MANIFEST | 24 +++++++++++++++ Makefile.PL | 1 + t/01-jobs.t | 38 ++++++++++++++++++------ t/problems/hello/1.in | 0 t/problems/hello/1.ok | 1 + t/problems/hello/meta.yml | 15 ++++++++++ t/problems/hello/tests/c/meta.yml | 7 +++++ t/problems/hello/tests/c/prog.c | 6 ++++ t/problems/hello/tests/cpp/meta.yml | 7 +++++ t/problems/hello/tests/cpp/prog.cpp | 6 ++++ t/problems/hello/tests/gccgo/meta.yml | 7 +++++ t/problems/hello/tests/gccgo/prog.go | 5 ++++ t/problems/hello/tests/golang/meta.yml | 7 +++++ t/problems/hello/tests/golang/prog.go | 5 ++++ t/problems/hello/tests/haskell/meta.yml | 7 +++++ t/problems/hello/tests/haskell/prog.hs | 4 +++ t/problems/hello/tests/java/meta.yml | 7 +++++ t/problems/hello/tests/java/prog.java | 5 ++++ t/problems/hello/tests/mono/meta.yml | 8 +++++ t/problems/hello/tests/mono/prog.cs | 6 ++++ t/problems/hello/tests/mono/prog.exe | Bin 0 -> 3072 bytes t/problems/hello/tests/pascal/meta.yml | 7 +++++ t/problems/hello/tests/pascal/prog.pas | 4 +++ t/problems/hello/tests/perl/meta.yml | 7 +++++ t/problems/hello/tests/perl/prog.pl | 5 ++++ t/problems/hello/tests/python/meta.yml | 7 +++++ t/problems/hello/tests/python/prog.py | 2 ++ 27 files changed, 189 insertions(+), 9 deletions(-) create mode 100644 t/problems/hello/1.in create mode 100644 t/problems/hello/1.ok create mode 100644 t/problems/hello/meta.yml create mode 100644 t/problems/hello/tests/c/meta.yml create mode 100644 t/problems/hello/tests/c/prog.c create mode 100644 t/problems/hello/tests/cpp/meta.yml create mode 100644 t/problems/hello/tests/cpp/prog.cpp create mode 100644 t/problems/hello/tests/gccgo/meta.yml create mode 100644 t/problems/hello/tests/gccgo/prog.go create mode 100644 t/problems/hello/tests/golang/meta.yml create mode 100644 t/problems/hello/tests/golang/prog.go create mode 100644 t/problems/hello/tests/haskell/meta.yml create mode 100644 t/problems/hello/tests/haskell/prog.hs create mode 100644 t/problems/hello/tests/java/meta.yml create mode 100644 t/problems/hello/tests/java/prog.java create mode 100644 t/problems/hello/tests/mono/meta.yml create mode 100644 t/problems/hello/tests/mono/prog.cs create mode 100755 t/problems/hello/tests/mono/prog.exe create mode 100644 t/problems/hello/tests/pascal/meta.yml create mode 100644 t/problems/hello/tests/pascal/prog.pas create mode 100644 t/problems/hello/tests/perl/meta.yml create mode 100644 t/problems/hello/tests/perl/prog.pl create mode 100644 t/problems/hello/tests/python/meta.yml create mode 100644 t/problems/hello/tests/python/prog.py diff --git a/MANIFEST b/MANIFEST index 5c441b2..3bf7574 100644 --- 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/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 diff --git a/Makefile.PL b/Makefile.PL index f7d5e99..5baa62a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -14,6 +14,7 @@ WriteMakefile( File::Basename 0 File::Slurp 0 File::Temp 0 + File::Which 0 Hash::Merge 0 List::Util 0 Log::Log4perl 0 diff --git a/t/01-jobs.t b/t/01-jobs.t index a4e0c02..4b76310 100644 --- a/t/01-jobs.t +++ b/t/01-jobs.t @@ -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::Which qw/which/; 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 = <; +@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; @@ -64,15 +79,20 @@ for my $problem (@problems) { 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 index 0000000..e69de29 diff --git a/t/problems/hello/1.ok b/t/problems/hello/1.ok new file mode 100644 index 0000000..980a0d5 --- /dev/null +++ b/t/problems/hello/1.ok @@ -0,0 +1 @@ +Hello World! diff --git a/t/problems/hello/meta.yml b/t/problems/hello/meta.yml new file mode 100644 index 0000000..194437b --- /dev/null +++ b/t/problems/hello/meta.yml @@ -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 index 0000000..b254a56 --- /dev/null +++ b/t/problems/hello/tests/c/meta.yml @@ -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 index 0000000..298c213 --- /dev/null +++ b/t/problems/hello/tests/c/prog.c @@ -0,0 +1,6 @@ +#include + +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 index 0000000..5bd35bd --- /dev/null +++ b/t/problems/hello/tests/cpp/meta.yml @@ -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 index 0000000..2649ecc --- /dev/null +++ b/t/problems/hello/tests/cpp/prog.cpp @@ -0,0 +1,6 @@ +#include + +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 index 0000000..15cde0b --- /dev/null +++ b/t/problems/hello/tests/gccgo/meta.yml @@ -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 index 0000000..77c24d5 --- /dev/null +++ b/t/problems/hello/tests/gccgo/prog.go @@ -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 index 0000000..12ec0e1 --- /dev/null +++ b/t/problems/hello/tests/golang/meta.yml @@ -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 index 0000000..77c24d5 --- /dev/null +++ b/t/problems/hello/tests/golang/prog.go @@ -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 index 0000000..0d82691 --- /dev/null +++ b/t/problems/hello/tests/haskell/meta.yml @@ -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 index 0000000..0fca251 --- /dev/null +++ b/t/problems/hello/tests/haskell/prog.hs @@ -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 index 0000000..cb66e43 --- /dev/null +++ b/t/problems/hello/tests/java/meta.yml @@ -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 index 0000000..c4d820c --- /dev/null +++ b/t/problems/hello/tests/java/prog.java @@ -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 index 0000000..f2c2921 --- /dev/null +++ b/t/problems/hello/tests/mono/meta.yml @@ -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 index 0000000..d1aed41 --- /dev/null +++ b/t/problems/hello/tests/mono/prog.cs @@ -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 index 0000000000000000000000000000000000000000..754c465e8724bbf90acaae8d9b259ea074f8a354 GIT binary patch literal 3072 zcmeHI&2Jk;6#uQ0REeP>NT^K&3KKU-QPpk@3F1Q$n0&MeBu!MiNraG^wLLgX*Sps4 zx;Pvl9H>CzQ2r7SLQo+P95`?(;)Hsta_Ai)apFMvz1iKwiK;4Rl$Xq#_wk!I@4cNF zFTZ^YJpg(+9y|bUa~3KY{%E#C_u#YN58|7FJ7c%4r8{GlEjLoFFldBMQ`H>b4`Nl- zDs218_0`-;Sv7;YwojhSkEfwm=Yb`w2Md4wQptAPMb3K6>Q9n7ky!5)I4h14hcLw{ zmp~|){AI=t2kk;VD18D9ng9JcRTBtq6@a%yE&+Gbb*U?vHi5?v7>=kYfEDafKlOz@ z4X|U~iK*Y0J?S$A9NM4eO*@Rj8r>$hQi@A^Ld{T#+1sJ^0s>90n>0(TJVzImfSE4U zh(8w+i{zF=AL`eL18OuaW^1Cr*7wyU7 z@FEcw_a7yH65<;%+{V)wMDGp`k$fn*ff=1gCljZagL>Q3uR*RA zW&=M8JdN^p6ze9|LpRn-uCK9DeNWe7*tIwavFx}$uC)EwZR**e*>YmH>UwUx{YK2L zR@-qFz)nH7pj=OfWgXsdYdS(Rss*9vR?W7y?r6zpWC5CA%R>N#b@GsM9bo*s^{PvGezy9gMd6r{YgFOno+ptEZah2Su_0VZu4*dB}O}An<@GDzk@P1_VfA_&V zYa>&;pYi=EWQ7C2iLCbZZYevrz_r;RobPB;v&mX(yY9)E;*0hiRLMxk>?j?u%-tGJ zUeT@v$+<5+#4aFtJ2pym=0rWkzTDGUAB`{%#e?J|ax zy`Ii;E4soOtK55wQ5~MYi*R`cHDmgCmnTwaoQDsn(Cg3|(eEH8E}$m#5x(l(4rzqW5bl!X_pg61$Ih=|*g@KKJ&zGH7vqz-omi zOdd