Testing utility

View: New views
3 Messages — Rating Filter:   Alert me  

Testing utility

by Olli Saarela :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

Re: Testing utility

by David Bateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Olli Saarela wrote:
> Hello,
>
> 'make check' is not necessarily available in a run-time environment. I
> used the enclosed function when testing the MSCV distribution.
>
> Olli
Yes but this will only check the tests that are in the m-files. There
are many tests also embedded in the C++ source code that this will miss
as the source is not on the path. It will also miss the octave/tests
directory that includes many tests as well. Really the "make check" is
for the builder of octave that has a built version of octave in its
source tree...

Cheers
David

--
David Bateman                                David.Bateman@...
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)

The information contained in this communication has been classified as:

[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary

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

Re: Testing utility

by Paul Kienzle :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jun 8, 2007, at 4:20 AM, David Bateman wrote:

> Olli Saarela wrote:
>> Hello,
>>
>> 'make check' is not necessarily available in a run-time environment. I
>> used the enclosed function when testing the MSCV distribution.
>>
>> Olli
> Yes but this will only check the tests that are in the m-files. There
> are many tests also embedded in the C++ source code that this will miss
> as the source is not on the path. It will also miss the octave/tests
> directory that includes many tests as well. Really the "make check" is
> for the builder of octave that has a built version of octave in its
> source tree...

It is easy to grab the C++ tests:

        for f in `find octave -name "*.cc" -print | xargs grep -l "^[%][!]"`;
do
                out=${f##*/}
                grep "^[%][!]" $f > test_${out%.cc}.m
        done

If these were extracted and installed along with the tests in
octave/test, then you could write testall using something like:

    fns_and_files=completion_matches('test_');
    files=regexp(fns_and_files,'[.]m$','lineanchors');
    for f = files, test('f'); endfor

Sorry, this is untested --- I don't have 2.9.x on my Mac.

- Paul

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