Open mingodad opened 3 years ago
Using the test script from the original distribution I'm getting:
FAILED 23 out of 35 tests.
PASSED 12 out of 35 tests.
test.pl
#
# Test script for FOG
#
# Prerequisite: TestFog is executable to test
# so on Unix do something like
# ln -s sun4o_g/fog TestFog
# and on NT create TestFog.bat containing
# Debug/Fog $*
#
# Invoke as:
#
# perl test.pl <test-directory>*
# requiring the TestFog prerequisite or as e.g.
# perl test.pl executable="\"Debug/fog.exe\"" <test-directory>*
# to use a specific executable for the tests
#
# where each test directory comprises
# 'test-directory'/'test-directory'.fog
# optional include files
# 'test-directory'/references/'reference result files'
#
# running test creates
# 'test-directory'/results/'actual result files'
#
# Thus to run the full set (wildcard only works on Unix)
# perl test.pl tests/*
# Thus to run some tests (NT or Unix)
# perl test.pl tests/ansi_c tests/lexical
#
# Warning: The stream synchronisation on NT is abysmal so diagnostics resulting
# from invocation of FOG may appear extraordinarily early wrt other activities.
#
#print "executable = $executable\n";
eval "\$$1=\$2" while $ARGV[0] =~ /^(\w+)=(.*)/ && shift; # Nutshell perl p256
#print "executable = $executable\n";
$executable = "\"./TestFog\"" unless $executable ne "";
#print "executable = $executable\n";
$ENV{'TESTNAME'} = "willink"; # Used by getenv.fog
$failures = 0;
$passes = 0;
$tests = 0;
for (@ARGV)
{
# print "$_\n";
next if $_ eq '.';
next if $_ eq '..';
next unless -d 'tests/'.$_;
$error_count = 0;
$tests++;
local($tst) = $_;
local($dir) = 'tests/'.$tst;
mkdir($dir .'/references', ~umask) unless -e $dir .'/references';
if (-e $dir .'/results')
{
opendir(DIR,$dir .'/results') || die "Can't open $dir/results";
local($unlinks) = "$dir/results/" . join(" $dir/results/", grep(!/^\.\.?$/, readdir(DIR)));
local(@unlinks) = split(/ /,$unlinks);
# print "unlink @unlinks\n";
unlink @unlinks;
closedir(DIR);
}
else
{
mkdir($dir .'/results', ~umask) unless -e $dir .'/results';
}
opendir(DIR, $dir) || die "Can't open $dir";
local(@commandline) = "$executable -q -zd -t4 -cd $dir/results -hd $dir/results $dir/" .
join(' $dir/',grep(/\.fog$/, readdir(DIR))) .
" -nc -nobanner -i$dir -global global -DMACRO=aMacro -log $dir/results/log.log";
closedir(DIR);
print "@commandline\n";
system "@commandline\n";
if (-e $dir . '/results/log.log')
{
opendir(DIR,$dir .'/results') || die "Can't open $dir/results";
local(@resultnames) = grep(!/^\.\.?$/, readdir(DIR));
closedir(DIR);
for (@resultnames)
{
# print "result $_\n";
if (!-e $dir .'/references/' . $_)
{
print "ERROR missing result need to cp $dir/results/$_ $dir/references/$_.\n";
$error_count++;
}
else
{
local(@commandline) = "diff -b $dir/references/$_ $dir/results/$_ > $dir/results/$_.diff";
# print "@commandline\n";
$diff_status = (system "@commandline\n") / 256;
# print "$diff_status\n";
if ($diff_status)
{
print "ERROR need to verify and then cp $dir/results/$_ $dir/references/$_.\n";
open(DIFFS, $dir . '/results/' . $_ . '.diff') || warn "Can't open $dir/results/$_.diff\n";
while (<DIFFS>)
{
print;
}
$error_count++;
}
# print "diff $dir/results/$_ $dir/references/$_.\n";
# open(RESULT, $dir . '/results/' . $_) || warn "Can't open $dir/results/$_.\n";
# open(REFERENCE, $dir . '/references/' . $_) || warn "Can't open $dir/references/$_.\n";
# $break = 0;
# while (!eof(RESULT) && !eof(REFERENCE) && !$break)
# {
# @reswords = split(/\W*\s+\W*/, <RESULT>);
# @refwords = split(/\W*\s+\W*/, <REFERENCE>);
# if (join(" ", @refwords) ne join(" ", @reswords))
# {
# print "Files differ.\n";
# print " Reference: " , join(" ", @refwords), "\n";
# print " Result: " , join(" ", @reswords), "\n";
# $break++;
# }
# }
# if (!eof(RESULT) || !eof(REFERENCE) || $break)
# {
# print "ERROR need to verify and then cp $dir/results/$_ $dir/references/$_.\n";
# $error_count++;
# }
# close RESULT;
# close REFERENCE;
}
}
}
else
{
print "ERROR fog failed to execute.\n";
$error_count++;
}
if (-e $dir . '/references/log.log')
{
opendir(DIR,$dir .'/references') || die "Can't open $dir/references";
local(@referencenames) = readdir(DIR);
closedir(DIR);
for (@referencenames)
{
next if $_ eq '.';
next if $_ eq '..';
next if $_ eq "Debug"; # Ignore bogus Debug directory
next if $_ eq "Release"; # Ignore bogus Release directory
next if $_ eq "vssver.scc"; # Ignore Visual SourceSafe control files
if (!-e $dir .'/results/' . $_)
{
print "ERROR $dir/results/$_ not generated to correspond to $dir/references/$_.\n";
$error_count++;
}
}
}
if ($error_count > 0)
{
print "FAILED $dir with $error_count errors ---------------------------------------------------.\n";
$failures++;
}
else
{
print "PASSED $dir ---------------------------------------------------.\n";
$passes++;
}
}
if ($failures > 0)
{
print "FAILED $failures out of $tests tests.\n";
}
if ($passes > 0)
{
print "PASSED $passes out of $tests tests.\n";
}
Executing tests from the root folder:
perl test.pl executable="$PWD/fog-nb/dist/Debug/GNU-Linux/fog-nb" \
13_5 \
auto_statements \
cxx \
FactoryMethod \
iterator \
monitor \
SynchronisedEnum \
ambig \
bugs \
defined \
getenv \
lexical \
multi_dollar \
templates \
anons \
burg \
derived \
if \
marshal \
multiples \
template_type \
ansi_c \
conversions \
dollars \
if_math \
meta_position \
Observer \
utility \
arithmetic \
cpp \
error \
includes \
misparse \
strings \
Visitor
...
FAILED 23 out of 35 tests.
PASSED 12 out of 35 tests.
"-Wall -Wextra" certainly gives a lot of warnings, because the original code is written for the c++98 standard, if even for it. These changes are welcome.
The changes that appear in the diffs look good. However, I was not able to patch them automatically with any command. Could you submit your changes with a pull request or submit a new patch that works with the patch
or git apply
command?
That test script needs to be re-enabled in this project. Those failed tests are a serious problem. I will look at this once these changes have been added.
Here is the output of git diff
.
dad-changes.diff.zip
Adding "-Wall -Wextra" compiler flags I fixed several warnings and some possible bugs showed up too see bellow:
Possible bugs:
Full list of fixes: