Bug #10416 fixed - xmltoformat did not return at the root directory in case of error. 74/5874/2
Allan CORNET [Wed, 11 Jan 2012 11:05:44 +0000 (12:05 +0100)]
Change-Id: I2a9f9eacfa4c8cd97d2c02ea3d7812e1b6cbd645

scilab/CHANGES_5.4.X
scilab/modules/helptools/macros/xmltoformat.sci
scilab/modules/helptools/tests/nonreg_tests/bug_10416.tst [new file with mode: 0644]

index a56f3a9..c99c188 100644 (file)
@@ -131,6 +131,8 @@ Bug fixes
 * Bug #10408 fixed - In the history browser, the contents was scrolled even if the
                      knob was not at the bottom.
 
+* Bug #10416 fixed - xmltoformat did not return at the root directory in case of error.
+
 * Bug #10418 fixed - Playsound was failing under Mac OS X. Thanks to
                      Pierre-Henri Jondot for the patch.
 
index 28afca8..a7c7976 100644 (file)
@@ -512,6 +512,7 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
 
         // Check if the help file has been generated
         if fileinfo(buildDoc_file)==[] then
+            chdir(cur_dir);
             error(msprintf(gettext("%s: %s has not been generated."),"xmltoformat",buildDoc_file));
         end
 
@@ -522,6 +523,7 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
             my_html_files = listfiles(buildDoc_dir);
             for k=1:size(my_html_files,'*')
                 if ~copyfile(my_html_files(k),pathconvert(final_output_dir+"/"+my_html_files(k),%f,%f)) then
+                    chdir(cur_dir);
                     error(msprintf(gettext("%s: %s file hasn''t been moved in the %s directory."),"xmltoformat",my_html_files(k),final_output_dir));
                 end
                 mdelete(my_html_files(k));
@@ -598,6 +600,7 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
 
             // Change Scilab current directory so that Java Indexer works
             if ~chdir(buildDoc_dir) then
+                chdir(cur_dir);
                 error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",buildDoc_dir));
             end
 
@@ -606,6 +609,7 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
 
             // Check if the help file has been generated
             if fileinfo(buildDoc_file)==[] then
+                chdir(cur_dir);
                 error(msprintf(gettext("%s: %s has not been generated."),"xmltoformat",buildDoc_file));
             end
 
@@ -616,6 +620,7 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
                 my_html_files = listfiles(buildDoc_dir);
                 for k=1:size(my_html_files,'*')
                     if ~copyfile(my_html_files(k),pathconvert(final_output_dir+"/"+my_html_files(k),%f,%f)) then
+                        chdir(cur_dir);
                         error(msprintf(gettext("%s: %s file hasn''t been moved in the %s directory."),"xmltoformat",my_html_files(k),final_output_dir));
                     end
                     mdelete(my_html_files(k));
@@ -725,6 +730,7 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
 
              // Check if the help file has been generated
             if fileinfo(buildDoc_file)==[] then
+                chdir(cur_dir);
                 error(msprintf(gettext("%s: %s has not been generated."),"xmltoformat",buildDoc_file));
             end
 
@@ -735,6 +741,7 @@ function generated_files = xmltoformat(output_format,dirs,titles,directory_langu
                 my_html_files = listfiles(buildDoc_dir);
                 for k=1:size(my_html_files,'*')
                     if ~copyfile(my_html_files(k),pathconvert(final_output_dir+"/"+my_html_files(k),%f,%f)) then
+                        chdir(cur_dir);
                         error(msprintf(gettext("%s: %s file hasn''t been moved in the %s directory."),"xmltoformat",my_html_files(k),final_output_dir));
                     end
                     mdelete(my_html_files(k));
diff --git a/scilab/modules/helptools/tests/nonreg_tests/bug_10416.tst b/scilab/modules/helptools/tests/nonreg_tests/bug_10416.tst
new file mode 100644 (file)
index 0000000..f3850e1
--- /dev/null
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - DIGITEO - Allan CORNET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- JVM MANDATORY -->
+//
+// <-- INTERACTIVE TEST -->
+//
+// <-- Non-regression test for bug 10416 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/10416
+//
+// <-- Short Description -->
+// xmltoformat did not return at the root directory in case of error.
+
+// to test here, we can check with toolbox_skeleton and add a error in some xml files
+
+cur_ref_dir = pwd();
+
+edit SCI/contrib/toolbox_skeleton/help/en_US/c_multiplybypi.xml
+
+// add a error in c_multiplybypi.xml 
+
+exec builder.sce;
+
+cur_dir = pwd();
+
+assert_check(cur_dir, cur_ref_dir);