[m-rev.] diff: fix for io.call_system_code on java

Peter Wang novalazy at gmail.com
Thu Mar 4 11:40:53 AEDT 2010


Branches: main

library/io.m:
        In the Java implementation of `io.call_system_code', don't interrupt
        the threads copying the output and error streams of the child process
        immediately after the child process is finished.  Wait for them to
        finish as there may still be buffered data.

tests/hard_coded/Mmakefile:
        Don't treat the `dst_test' test case different in the java grade.
        The code was out of date and is not necessary.

tests/hard_coded/dir_test.exp4:
        Add an expected output for this test case, with Unix-style directory
        separators but no symlink support (java grade on Unix).

diff --git a/library/io.m b/library/io.m
index 443f3e6..9f4a6d7 100644
--- a/library/io.m
+++ b/library/io.m
@@ -9899,11 +9899,13 @@ command_line_argument(_, "") :-
         Status  = process.waitFor();
         Msg = null;
 
-        // The StreamPipes are killed off after the Process is finished,
-        // so as not to waste CPU cycles with pointless threads.
+        // The stdin StreamPipe is killed off after the Process is finished
+        // so as not to waste CPU cycles with a pointless thread.
         stdin.interrupt();
-        stdout.interrupt();
-        stderr.interrupt();
+
+        // Wait for all the outputs to be written.
+        stdout.join();
+        stderr.join();
 
         if (stdin.exception != null) {
             throw stdin.exception;
diff --git a/tests/hard_coded/Mmakefile b/tests/hard_coded/Mmakefile
index c058496..19b70bd 100644
--- a/tests/hard_coded/Mmakefile
+++ b/tests/hard_coded/Mmakefile
@@ -873,20 +873,10 @@ clean_dir_test:
 # Since all the test data is based on Melbourne's DST conventions, the
 # timezone environment variable TZ must be set accordingly.
 
-ifneq "$(findstring java,$(GRADE))" ""
-
-dst_test.out: dst_test.class
-	TZ="Australia/Melbourne" $(JAVA) dst_test > $@ 2>&1 || \
-		{ grep . $@ /dev/null; exit 1; }
-
-else
-
 dst_test.out: dst_test
 	TZ="Australia/Melbourne" ./$< > $@ 2>&1 || \
 		{ grep . $@ /dev/null; exit 1; }
 
-endif
-
 #-----------------------------------------------------------------------------#
 
 clean_local:
diff --git a/tests/hard_coded/dir_test.exp4 b/tests/hard_coded/dir_test.exp4
new file mode 100644
index 0000000..e393954
--- /dev/null
+++ b/tests/hard_coded/dir_test.exp4
@@ -0,0 +1,156 @@
+Directory separator is '/'.
+dir__split_name("\\server\share\foo", _, _) failed.
+dir__dirname("\\server\share\foo") = ".".
+dir__basename("\\server\share\foo") = "\\server\share\foo".
+dir__path_name_is_absolute("\\server\share\foo") failed
+dir__path_name_is_root_directory("\\server\share\foo") failed
+
+dir__split_name("\\server\share", _, _) failed.
+dir__dirname("\\server\share") = ".".
+dir__basename("\\server\share") = "\\server\share".
+dir__path_name_is_absolute("\\server\share") failed
+dir__path_name_is_root_directory("\\server\share") failed
+
+dir__split_name("\\server\share\\", _, _) failed.
+dir__dirname("\\server\share\\") = ".".
+dir__basename("\\server\share\\") = "\\server\share\\".
+dir__path_name_is_absolute("\\server\share\\") failed
+dir__path_name_is_root_directory("\\server\share\\") failed
+
+dir__split_name("C:\foo", _, _) failed.
+dir__dirname("C:\foo") = ".".
+dir__basename("C:\foo") = "C:\foo".
+dir__path_name_is_absolute("C:\foo") failed
+dir__path_name_is_root_directory("C:\foo") failed
+
+dir__split_name("C:\foo\", _, _) failed.
+dir__dirname("C:\foo\") = ".".
+dir__basename("C:\foo\") = "C:\foo\".
+dir__path_name_is_absolute("C:\foo\") failed
+dir__path_name_is_root_directory("C:\foo\") failed
+
+dir__split_name("C:\", _, _) failed.
+dir__dirname("C:\") = ".".
+dir__basename("C:\") = "C:\".
+dir__path_name_is_absolute("C:\") failed
+dir__path_name_is_root_directory("C:\") failed
+
+dir__split_name("C:", _, _) failed.
+dir__dirname("C:") = ".".
+dir__basename("C:") = "C:".
+dir__path_name_is_absolute("C:") failed
+dir__path_name_is_root_directory("C:") failed
+
+dir__split_name("\", _, _) failed.
+dir__dirname("\") = ".".
+dir__basename("\") = "\".
+dir__path_name_is_absolute("\") failed
+dir__path_name_is_root_directory("\") failed
+
+dir__split_name("", _, _) failed.
+dir__dirname("") = ".".
+dir__basename("") = "".
+dir__path_name_is_absolute("") failed
+dir__path_name_is_root_directory("") failed
+
+dir__split_name("foo\\bar\", _, _) failed.
+dir__dirname("foo\\bar\") = ".".
+dir__basename("foo\\bar\") = "foo\\bar\".
+dir__path_name_is_absolute("foo\\bar\") failed
+dir__path_name_is_root_directory("foo\\bar\") failed
+
+dir__split_name("foo\bar\", _, _) failed.
+dir__dirname("foo\bar\") = ".".
+dir__basename("foo\bar\") = "foo\bar\".
+dir__path_name_is_absolute("foo\bar\") failed
+dir__path_name_is_root_directory("foo\bar\") failed
+
+dir__split_name("foo", _, _) failed.
+dir__dirname("foo") = ".".
+dir__basename("foo") = "foo".
+dir__path_name_is_absolute("foo") failed
+dir__path_name_is_root_directory("foo") failed
+
+dir__split_name("/foo", "/", "foo").
+"/"/"foo" = "/foo".
+dir__dirname("/foo") = "/".
+dir__basename("/foo") = "foo".
+dir__path_name_is_absolute("/foo").
+dir__path_name_is_root_directory("/foo") failed
+
+dir__split_name("/foo//bar///", "/foo", "bar").
+"/foo"/"bar" = "/foo/bar".
+dir__dirname("/foo//bar///") = "/foo".
+dir__basename("/foo//bar///") = "bar".
+dir__path_name_is_absolute("/foo//bar///").
+dir__path_name_is_root_directory("/foo//bar///") failed
+
+dir__split_name("//foo//bar/", "/foo", "bar").
+"/foo"/"bar" = "/foo/bar".
+dir__dirname("//foo//bar/") = "/foo".
+dir__basename("//foo//bar/") = "bar".
+dir__path_name_is_absolute("//foo//bar/").
+dir__path_name_is_root_directory("//foo//bar/") failed
+
+dir__split_name("//foo//", "/", "foo").
+"/"/"foo" = "/foo".
+dir__dirname("//foo//") = "/".
+dir__basename("//foo//") = "foo".
+dir__path_name_is_absolute("//foo//").
+dir__path_name_is_root_directory("//foo//") failed
+
+dir__split_name("/", _, _) failed.
+dir__dirname("/") = "/".
+dir__basename("/") = _ failed.
+dir__path_name_is_absolute("/").
+dir__path_name_is_root_directory("/").
+
+dir__split_name("//", _, _) failed.
+dir__dirname("//") = "/".
+dir__basename("//") = _ failed.
+dir__path_name_is_absolute("//").
+dir__path_name_is_root_directory("//").
+
+dir__split_name("foo/bar", "foo", "bar").
+"foo"/"bar" = "foo/bar".
+dir__dirname("foo/bar") = "foo".
+dir__basename("foo/bar") = "bar".
+dir__path_name_is_absolute("foo/bar") failed
+dir__path_name_is_root_directory("foo/bar") failed
+
+"C:"/"foo" = "C:/foo".
+"C:\"/"foo" = "C:\/foo".
+"C:"/"C:" = "C:/C:".
+"C:"/"C:\foo" = "C:/C:\foo".
+"."/"/foo" threw exception: software_error("dir./: second argument is absolute")
+"."/"\foo" = "./\foo".
+"foo"/"bar/baz" = "foo/bar/baz".
+"foo/"/"bar/baz" = "foo/bar/baz".
+checking whether `unwritable' is readable...ok
+unwritable file found to be unwritable
+current_directory succeeded: hard_coded
+make_directory succeeded
+make_directory succeeded
+dir.make_single_directory with non-existent parent failed as expected.
+make_single_directory succeeded
+make_single_directory 2 succeeded
+file_type succeeded
+type of test_dir/d1 is directory
+file_type 2 succeeded
+type of dir_test.m is regular_file
+touching file succeeded
+touching file succeeded
+touching file succeeded
+touching file succeeded
+creating directory with same name as ordinary file failed (as expected).
+symlinks not available on this platform
+dir__foldl2 succeeded
+Files in test_dir:
+test_dir/d1, test_dir/d2, test_dir/quark, test_dir/queeg
+dir__recursive_foldl2 (no symlinks) succeeded
+Files in test_dir (recursive, not following symlinks):
+test_dir/d1, test_dir/d1/baz, test_dir/d1/foo, test_dir/d2, test_dir/d2/d2, test_dir/quark, test_dir/queeg
+dir__recursive_foldl2 (symlinks) succeeded
+Files in test_dir (recursive, following symlinks:
+test_dir/d1, test_dir/d1/baz, test_dir/d1/foo, test_dir/d2, test_dir/d2/d2, test_dir/quark, test_dir/queeg
+dir.recursive_foldl2(list_files, "dir_test.m", ...) failed as expected.

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list