#!/usr/bin/perl use strict; use warnings; use File::Path; use Cwd; if ($ARGV[0]=~ 'all'){ mkdir 'logs'; chdir 'logs'; my $logwd = getcwd(); chdir '..'; my $basewd = getcwd(); chdir 'tests'; my @files = glob "*"; foreach my $file(@files){ my $outwd = $logwd.'/'.$file; if(-d $file){ mkdir "$logwd/$file"; chdir $file; if(`../run_tests.pl $outwd` =~ 0){ rmtree($outwd); } } } chdir $basewd; `make unchecked`; } elsif($ARGV[0]=~/clean/){ my @ofiles = glob "*.o"; foreach my $file(@ofiles){ print "cleaning $file\n"; unlink $file; } } #### #!/usr/bin/perl use strict; use warnings; `make tests`; my $logwd = $ARGV[0]; my $pid = open(my $kid_to_read,"-|"); if($pid == 0){ print `./tests`; } else{ open(my $failed_tests,'>',"$logwd/test_fail.log"); open(my $test_output,'>',"$logwd/test_out.log"); my $fail = 0; while(<$kid_to_read>){ my $line = $_; if($line =~ /\Anot ok/){ print $failed_tests $line; $fail++; } print $test_output $line; } close $test_output; close $failed_tests; `make clean`; print $fail; } #### all: ./build.pl all make clean .PHONY: clean clean: ./build.pl clean unchecked: