changeset 9742:9f8ff01abc65

.cc files are now included in the list of files requiring tests only if they define a user function (DEFUN or DEFUN_DLD)
author Rik <rdrider0-list@yahoo.com>
date Mon, 19 Oct 2009 19:17:49 -0700
parents 36840b4ebda6
children 26abff55f6fe
files test/ChangeLog test/fntests.m
diffstat 2 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/ChangeLog	Mon Oct 19 19:13:57 2009 -0700
+++ b/test/ChangeLog	Mon Oct 19 19:17:49 2009 -0700
@@ -1,4 +1,9 @@
-2009-10-08  Rik  <octdev@nomad.inbox5.com>
+2009-10-19  Rik  <octdev@nomad.inbox5.com>
+
+	* fntests.m: .cc files are now included in the list of files requiring
+	tests only if they define a user function (DEFUN or DEFUN_DLD)
+
+2009-10-19  Rik  <octdev@nomad.inbox5.com>
 
 	* fntests.m: Remove deprecated functions from list of functions requiring
 	new tests to be written
--- a/test/fntests.m	Mon Oct 19 19:13:57 2009 -0700
+++ b/test/fntests.m	Mon Oct 19 19:17:49 2009 -0700
@@ -68,6 +68,17 @@
   puts ("\n");
 endfunction
 
+function y = hasfunctions (f)
+  fid = fopen (f);
+  if (fid < 0)
+    error ("fopen failed: %s", f);
+  else
+    str = fread (fid, "*char")';
+    fclose (fid);
+    y = regexp (str,'^(DEFUN|DEFUN_DLD)\b', "lineanchors");
+  endif
+endfunction
+
 ## FIXME -- should we only try match the keyword at the start of a line?
 function y = hastests (f)
   fid = fopen (f);
@@ -128,9 +139,9 @@
   endfor
   for i = 1:length (lst)
     nm = lst(i).name;
-    if ((length (nm) > 3 && strcmp (nm((end-2):end), ".cc"))
-	|| (length (nm) > 2 && strcmp (nm((end-1):end), ".m")))
-      f = fullfile (d, nm);
+    f = fullfile (d, nm);
+    if ((length (nm) > 2 && strcmp (nm((end-1):end), ".m")) || 
+        (length (nm) > 3 && strcmp (nm((end-2):end), ".cc") && hasfunctions(f)))
       p = n = xf = 0;
       ## Only run if it contains %!test, %!assert %!error or %!warning
       if (hastests (f))