help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recursively test m files in a path?


From: forkandwait
Subject: Re: Recursively test m files in a path?
Date: Wed, 31 Mar 2010 04:32:09 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

forkandwait <forkandwait <at> gmail.com> writes:

> 
> Hi all,
> 
> Is there a built in way to recursively find all the m files in a tree and run 
> "test" on them?  I am sure that one can imagine the utility....

It isn't much (and hardly worth its own patch), but if anyone cares, here is my 
hand rolled attempt, which I am sure could be made better.

function [results] = testall (pth)
  ##                                                                            
                                                              
  ## testall(P) -- runs "test()" on all mfiles in a path P.   
  ##  Returns a cell array with names of the funcs and 
  ##  whether passed all tests
  ##

  if nargin ~= 1
    usage("results = testall(PATHROOT)");
  endif

  addpath(genpath(pth));  # awkward, but necessary

  results = {};
  for p = strsplit(genpath(pth), ';') # splits go across cols 
    gstr = [p{:} '/*.m'];
    for mf = glob(gstr)'        # globs go down rows - hence transpose
    [_ func _] = fileparts(mf{1});
      success = test(func, 'quiet');
      results(end+1,1:2) = {func success};
    endfor
  endfor

endfunction

%!test 
%!  testall('/usr/local/share/octave/3.3.50/m/set/')



reply via email to

[Prev in Thread] Current Thread [Next in Thread]