Testing utility

Olli Saarela <[email protected]> Wed, 06 Jun 2007 11:44:13 +0300
Newsgroups gmane.comp.gnu.octave.sources
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------060708060100020101080607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hello,

'make check' is not necessarily available in a run-time environment. I 
used the enclosed function when testing the MSCV distribution.

Olli


--------------060708060100020101080607
Content-Type: text/plain;
 name="test_all.m"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="test_all.m"

## Copyright (C) 2007 Olli Saarela
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301  USA

## -*- texinfo -*-
## @deftypefn {Function File} {} test_all ()
##
## Execute tests from all the m-files in the loadpath. Also check
## for duplicate file names.
## @seealso{test, assert}
## @end deftypefn

function test_all

  __fid = stdout;

  dirs = split (path, pathsep);
  seen = cell (10000, 2);      # function names & paths
  nbr_seen = 0;

  for j = 1:size (dirs, 1)
    dirname = deblank (dirs(j, :));  
    files = dir (dirname);

    for k = 1:length(files);
      funname = files(k).name;
    
      if (length (funname) > 1 && strcmp (funname(end-1:end), '.m'))
	if (nbr_seen > 0)
	  idx = strmatch (funname, seen(1:nbr_seen, 1), "exact");
	else
	  idx = [];
	endif
	if (isempty (idx))
	  nbr_seen = nbr_seen + 1;
	  seen(nbr_seen, 1) = funname;
	  seen(nbr_seen, 2) = dirname;
	  test_fun (__fid, dirname, funname);
	else
	  fprintf (__fid, ">>>>> %s\n", funname);
	  fprintf (__fid, "  ***** Duplicate file name in the loadpath:\n")
	  fprintf (__fid, "  %s%s%s\n", seen{idx,2}, filesep, seen{idx,1})
	  fprintf (__fid, "  %s%s%s\n", dirname, filesep, funname)
        endif
      endif

    endfor
  endfor
endfunction  


## Execute regression tests, if any
function test_fun (__fid, dirname, funname)
  infile = fopen ([dirname filesep funname], "r");
  code = fread (infile, inf);
  fclose (infile);
  if (findstr (code, "\n%!") || findstr (code, "\r%!"))
    fprintf (__fid, ">>>>> %s\n", funname);
    test (funname);
  endif
endfunction

--------------060708060100020101080607
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Octave-sources mailing list
[email protected]
https://www.cae.wisc.edu/mailman/listinfo/octave-sources

--------------060708060100020101080607--