changeset 11747:8b77c3a5d87a release-3-0-x

Fix various tests under Win32.
author Michael Goffioul <michael.goffioul@gmail.com>
date Wed, 09 Apr 2008 13:26:25 -0400
parents ab14529b67de
children 63e048203ed3
files src/ChangeLog src/DLD-FUNCTIONS/dispatch.cc test/ChangeLog test/test_string.m test/test_system.m
diffstat 5 files changed, 48 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Apr 09 13:13:18 2008 -0400
+++ b/src/ChangeLog	Wed Apr 09 13:26:25 2008 -0400
@@ -1,3 +1,8 @@
+2008-04-09  Michael Goffioul  <michael.goffioul@gmail.com>
+
+	* DLD-FUNCTIONS/dispatch.cc: Replace system("echo '...'>...") calls
+	with real file writing.
+
 2008-04-04  John W. Eaton  <jwe@octave.org>
 
 	* parse.y (make_constant): Handle escape sequences in dq-strings.
--- a/src/DLD-FUNCTIONS/dispatch.cc	Wed Apr 09 13:13:18 2008 -0400
+++ b/src/DLD-FUNCTIONS/dispatch.cc	Wed Apr 09 13:26:25 2008 -0400
@@ -532,13 +532,21 @@
 FIXME I would rather not create dispatch_x/dispatch_y
 in the current directory!  I don't want them installed accidentally.
 
+%!function echo_to_file (str, name)
+%!  fid = fopen (name, 'w');
+%!  if (fid != -1)
+%!    fprintf (fid, str);
+%!    fprintf (fid, '\n');
+%!    fclose (fid);
+%!  endif
+
 %!test # replace base m-file
-%! system("echo 'function a=dispatch_x(a)'>dispatch_x.m");
+%! echo_to_file ('function a=dispatch_x(a)', "dispatch_x.m");
 %! dispatch('dispatch_x','length','string')
 %! assert(dispatch_x(3),3)
 %! assert(dispatch_x("a"),1)
 %! sleep (2);
-%! system("echo 'function a=dispatch_x(a),++a;'>dispatch_x.m");
+%! echo_to_file ('function a=dispatch_x(a),++a;', "dispatch_x.m");
 %! rehash();
 %! assert(dispatch_x(3),4)
 %! assert(dispatch_x("a"),1)
@@ -546,11 +554,11 @@
 %! unlink("dispatch_x.m");
 
 %!test # replace dispatch m-file
-%! system("echo 'function a=dispatch_y(a)'>dispatch_y.m");
+%! echo_to_file ('function a=dispatch_y(a)', "dispatch_y.m");
 %! dispatch('hello','dispatch_y','complex scalar')
 %! assert(hello(3i),3i)
 %! sleep (2);
-%! system("echo 'function a=dispatch_y(a),++a;'>dispatch_y.m");
+%! echo_to_file ('function a=dispatch_y(a),++a;', "dispatch_y.m");
 %! rehash();
 %! assert(hello(3i),1+3i)
 %!test 
--- a/test/ChangeLog	Wed Apr 09 13:13:18 2008 -0400
+++ b/test/ChangeLog	Wed Apr 09 13:26:25 2008 -0400
@@ -1,3 +1,10 @@
+2008-04-09  Michael Goffioul  <michael.goffioul@gmail.com>
+
+	* test_string.m: Fix isprint test under Win32, where
+	isprint(setstr(9)) is true.
+	* test_system.m: Add condition for various syscall tests. Make cd test
+	able to deal with drive-letter-only pathnames (e.g. C:\) under Win32.
+
 2008-03-26  David Bateman  <dbateman@free.fr>
 
 	* test_index-wfi-f.m: Split large block of tests.  New tests.
--- a/test/test_string.m	Wed Apr 09 13:13:18 2008 -0400
+++ b/test/test_string.m	Wed Apr 09 13:26:25 2008 -0400
@@ -532,6 +532,9 @@
 %! result = zeros (1, 128);
 %! 
 %! result (33:127) = 1;
+%! if (ispc () && ! isunix ())
+%!   result(10) = 1;
+%! endif
 %! 
 %! assert(all (isprint (charset) == result));
 
--- a/test/test_system.m	Wed Apr 09 13:13:18 2008 -0400
+++ b/test/test_system.m	Wed Apr 09 13:26:25 2008 -0400
@@ -377,7 +377,7 @@
 %!error <Invalid call to file_in_path.*> file_in_path ("foo", "bar", "baz", "ooka");
 
 %% test/octave.test/system/tilde_expand-1.m
-%!test
+%!testif HAVE_GETPWUID
 %! x = getpwuid (getuid ());
 %! assert((strcmp (x.dir, tilde_expand ("~"))
 %! && strcmp (x.dir, tilde_expand (sprintf ("~%s", x.name)))
@@ -390,7 +390,8 @@
 %!error <Invalid call to tilde_expand.*> tilde_expand ("str", 2);
 
 %% test/octave.test/system/getpgrp-1.m
-%!assert(getpgrp () > 0);
+%!testif HAVE_GETPGRP
+%! assert(getpgrp () > 0);
 
 %% test/octave.test/system/getpgrp-2.m
 %!error <... getpgrp> getpgrp (1);
@@ -402,7 +403,8 @@
 %!error <... getpid> getpid (1);
 
 %% test/octave.test/system/getppid-1.m
-%!assert(getppid () > 0);
+%!testif HAVE_GETPPID
+%! assert(getppid () > 0);
 
 %% test/octave.test/system/getppid-2.m
 %!error <... getppid> getppid (1);
@@ -471,7 +473,14 @@
 %! cd /
 %! d1 = pwd ();
 %! cd (xdir);
-%! assert("/", d1);
+%! if (ispc () && ! isunix ())
+%!   # should be a drive letter
+%!   assert(length (d1), 3);
+%!   assert(d1(2), ":");
+%!   assert(d1(3), "\\");
+%! else
+%!   assert("/", d1);
+%! endif
 %! assert(pwd(), xdir);
 
 %% test/octave.test/system/cd-2.m
@@ -484,7 +493,7 @@
 %!error ls (1);
 
 %% test/octave.test/system/getpwent-1.m
-%!test
+%!testif HAVE_GETPWENT
 %! s = getpwent ();
 %! endpwent (); 
 %! assert((isstruct (s)
@@ -500,7 +509,7 @@
 %!error <Invalid call to getpwent.*> getpwent (1);
 
 %% test/octave.test/system/getpwuid-1.m
-%!test
+%!testif HAVE_GETPWUID
 %! x = getpwent ();
 %! y = getpwuid (x.uid);
 %! endpwent (); 
@@ -513,7 +522,7 @@
 %!error <Invalid call to getpwuid.*> getpwuid (1, 2);
 
 %% test/octave.test/system/getpwnam-1.m
-%!test
+%!testif HAVE_GETPWNAM
 %! x = getpwent ();
 %! y = getpwnam (x.name);
 %! endpwent (); 
@@ -526,7 +535,7 @@
 %!error <Invalid call to getpwnam.*> getpwnam ("foo", 1);
 
 %% test/octave.test/system/setpwent-1.m
-%!test
+%!testif HAVE_SETPWENT
 %! x = getpwent ();
 %! setpwent ();
 %! y = getpwent ();
@@ -540,7 +549,7 @@
 %!error <Invalid call to endpwent.*> endpwent (1);
 
 %% test/octave.test/system/getgrent-1.m
-%!test
+%!testif HAVE_GETGRENT
 %! x = getgrent ();
 %! endgrent ();
 %! assert((isstruct (x)
@@ -553,7 +562,7 @@
 %!error <Invalid call to getgrent.*> getgrent (1);
 
 %% test/octave.test/system/getgrgid-1.m
-%!test
+%!testif HAVE_GETGRGID
 %! x = getgrent ();
 %! y = getgrgid (x.gid);
 %! endgrent ();
@@ -566,7 +575,7 @@
 %!error <Invalid call to getgrgid.*> getgrgid (1, 2);
 
 %% test/octave.test/system/getgrnam-1.m
-%!test
+%!testif HAVE_GETGRNAM
 %! x = getgrent ();
 %! y = getgrnam (x.name);
 %! endgrent ();
@@ -579,7 +588,7 @@
 %!error <Invalid call to getgrnam.*> getgrnam ("foo", 1);
 
 %% test/octave.test/system/setgrent-1.m
-%!test
+%!testif HAVE_SETGRENT
 %! x = getgrent ();
 %! setgrent ();
 %! y = getgrent ();