# HG changeset patch # User Michael Goffioul # Date 1207761985 14400 # Node ID 8b77c3a5d87a3eb807afd10130ac0b5fac93b255 # Parent ab14529b67de5f14c80c08e2562f434c1872a568 Fix various tests under Win32. diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-04-09 Michael Goffioul + + * DLD-FUNCTIONS/dispatch.cc: Replace system("echo '...'>...") calls + with real file writing. + 2008-04-04 John W. Eaton * parse.y (make_constant): Handle escape sequences in dq-strings. diff --git a/src/DLD-FUNCTIONS/dispatch.cc b/src/DLD-FUNCTIONS/dispatch.cc --- a/src/DLD-FUNCTIONS/dispatch.cc +++ b/src/DLD-FUNCTIONS/dispatch.cc @@ -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 diff --git a/test/ChangeLog b/test/ChangeLog --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,10 @@ +2008-04-09 Michael Goffioul + + * 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 * test_index-wfi-f.m: Split large block of tests. New tests. diff --git a/test/test_string.m b/test/test_string.m --- a/test/test_string.m +++ b/test/test_string.m @@ -532,6 +532,9 @@ %! result = zeros (1, 128); %! %! result (33:127) = 1; +%! if (ispc () && ! isunix ()) +%! result(10) = 1; +%! endif %! %! assert(all (isprint (charset) == result)); diff --git a/test/test_system.m b/test/test_system.m --- a/test/test_system.m +++ b/test/test_system.m @@ -377,7 +377,7 @@ %!error 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 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 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 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 getpwnam ("foo", 1); %% test/octave.test/system/setpwent-1.m -%!test +%!testif HAVE_SETPWENT %! x = getpwent (); %! setpwent (); %! y = getpwent (); @@ -540,7 +549,7 @@ %!error endpwent (1); %% test/octave.test/system/getgrent-1.m -%!test +%!testif HAVE_GETGRENT %! x = getgrent (); %! endgrent (); %! assert((isstruct (x) @@ -553,7 +562,7 @@ %!error 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 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 getgrnam ("foo", 1); %% test/octave.test/system/setgrent-1.m -%!test +%!testif HAVE_SETGRENT %! x = getgrent (); %! setgrent (); %! y = getgrent ();