# # regrtest2.pl - regression test for Quantity Library # This script drives compilation of regrtest2.cpp # # usage: perl -w regrtest2.pl # # Before using this script, edit the definition of $compile to # be the proper command to compile a C++ program on your system. # # Note that in the reported output, the sense of "pass" and "fail" # is reversed from what you would intuitively expect; if the # compile fails, the test is reported as a pass, since the whole # point of these tests is to make sure things that are supposed # to fail at compile-time really do so. # use strict; my $compile = "g++ -I."; # gcc/g++ # my $compile = "cl -GX"; #msvc my $pass = 0; my $fail = 0; my $maxtest = 52; my $summary = ""; print "Quantity Library regression test\n\n"; print "Testing detection of compile-time errors.\n\n"; my $i; for( $i = 0; $i <= $maxtest; $i++ ) { runtest( $i ); } print "\n$summary"; print "\nTotal pass: $pass"; print "\nTotal fail: $fail"; print "\n\nTest complete\n"; sub runtest() { my ( $num ) = @_; my $cmd = "$compile -DFAIL_$num regrtest2.cpp"; print "Testing $cmd ...\n"; system( $cmd ); my $rv = $?; if( $num == 0 ) { $rv = ( $rv == 0 ); # compile 0 is supposed to succeed } if( $rv == 0 ) { $fail ++; $summary .= "* FAIL: compile $num\n"; } else { $pass ++; $summary .= " pass: compile $num\n"; } } 1;