« Return to Thread: Testing utility

Testing utility

by Olli Saarela :: Rate this Message:

Reply to Author | View in Thread

Hello,

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

Olli


## 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

_______________________________________________
Octave-sources mailing list
Octave-sources@...
https://www.cae.wisc.edu/mailman/listinfo/octave-sources

 « Return to Thread: Testing utility

LightInTheBox - Buy quality products at wholesale price!