first version of new test_run 56/3556/8
Antoine ELIAS [Thu, 17 Mar 2011 17:01:47 +0000 (18:01 +0100)]
Change-Id: Ie6c82d88b19c6dec1ebb68633b9a0c75d1b74c86

SEP/INDEX
SEP/SEP_55_add_timeout_option_to_host_function.odt [new file with mode: 0644]
scilab/modules/development_tools/macros/test_run.sci

index 248a935..669a6f7 100644 (file)
--- a/SEP/INDEX
+++ b/SEP/INDEX
@@ -49,4 +49,5 @@ SEP #49 : repmat function
 SEP #50 : Xcos Help Folders
 SEP #51 : Linear Programming
 SEP #52 : Assert
+SEP #55 : add timeout option to host function
 
diff --git a/SEP/SEP_55_add_timeout_option_to_host_function.odt b/SEP/SEP_55_add_timeout_option_to_host_function.odt
new file mode 100644 (file)
index 0000000..a840bad
Binary files /dev/null and b/SEP/SEP_55_add_timeout_option_to_host_function.odt differ
index f45f961..0150fa7 100644 (file)
@@ -1,6 +1,7 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2007-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
 // Copyright (C) 2009-2010 - DIGITEO - Michael Baudin
+// Copyright (C) 2011-2010 - DIGITEO - Antoine ELIAS
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
 
 function test_run(varargin)
 
-    lhs = argn(1);
-    rhs = argn(2);
-
-    // test type
-    type_filter  = "all_tests"; // By default, lauch nonreg tests AND unitary tests
-    skip_mat     = [];          // The list of test to skip
+    lhs         = argn(1);
+    rhs         = argn(2);
 
     // =========================================================================
     // Print test_run help
     // =========================================================================
-
     if (rhs >= 3) & (~ isempty(grep(varargin(3),"help"))) then
         example = test_examples();
         printf("%s\n",example);
         return;
     end
 
+    status.details_failed       = "";
+    status.test_count           = 0;
+    status.test_passed_count    = 0;
+    status.test_failed_count    = 0;
+    status.test_skipped_count   = 0;
+    status.totalTime            = 0;
+    status.list                 = [];
+
+    params.longtime             = %t;
+    params.wanted_mode          = "NW";
+    params.error_output         = "check";
+    params.reference            = "check";
+    params.testTypes            = "all_tests";
+    params.skip_mat             = [];
+    params.tests_mat            = [];
+    params.test_passed_percent  = 0;
+    params.test_failed_percent  = 0;
+    params.test_skipped_percent = 0;
+
     // =======================================================
-    // Gestion des types de tests à lancer
+    // Gestion des types de tests à lancer et des options
     // =======================================================
-
-    global MACOSX;
-    global LINUX;
-
-    if getos() <> 'Windows' then
-        OSNAME = unix_g('uname');
-        MACOSX = (strcmpi(OSNAME,"darwin") == 0);
-        LINUX  = (strcmpi(OSNAME,"linux") == 0);
-    else
-        MACOSX = %F;
-        LINUX  = %F;
-    end
-
-    global testsuite;
-    testsuite = testsuite_new();
-
     if rhs >= 3 then
 
         option_mat = varargin(3);
-
         if (or(option_mat == "unit_tests") & or(option_mat == "nonreg_tests")) | (or(option_mat == "all_tests") ) then
-            type_filter = "all_tests";
-
+            params.testTypes = "all_tests";
         elseif or(option_mat == "unit_tests") then
-            type_filter = "unit_tests";
-
+            params.testTypes = "unit_tests";
         elseif or(option_mat == "nonreg_tests") then
-            type_filter = "nonreg_tests";
+            params.testTypes = "nonreg_tests";
         end
 
         if or(option_mat == "skip_tests") then
-            skip_mat = varargin(2);
+            params.skip_mat = varargin(2);
         end
 
-    end
+        // Mode
+        if grep(option_mat,"mode_nw") <> [] then
+            params.wanted_mode = "NW";
+        end
 
-    // =======================================================
-    // Stacksize management
-    // =======================================================
+        if grep(option_mat,"mode_nwni") <> [] then
+            params.wanted_mode = "NWNI";
+        end
 
-    gstacksize(10000000);
-    stacksize(10000000);
+        // Reference
+        if grep(option_mat,"no_check_ref") <> [] then
+            params.reference = "skip";
+        end
+
+        if grep(option_mat,"create_ref") <> [] then
+            params.reference = "create";
+        end
 
+        if grep(option_mat,"list") <> [] then
+            params.reference = "list";
+        end
+
+        // Error Output
+        if grep(option_mat,"no_check_error_output") <> [] then
+            params.error_output = "skip";
+        end
+
+        // Enable long-time tests
+        if grep(option_mat,"disable_lt") <> [] then
+            params.longtime = %f;
+        end
+
+        if grep(option_mat,"enable_lt") <> [] then
+            params.longtime = %t;
+        end
+    end
+
+    if params.reference <> "list"
+        printf("   TMPDIR = %s\n",TMPDIR);
+        printf("\n");
+    end
     // =======================================================
     // Gestion des tests à lancer
     // =======================================================
-
     if (rhs == 0) ..
                 | ((rhs == 1) & (varargin(1)==[])) ..
                 | (((rhs == 2)|(rhs == 3)) & (varargin(1)==[]) & (varargin(2)==[])) then
@@ -188,60 +215,68 @@ function test_run(varargin)
         module_list = getmodules();
         module_list = gsort(module_list,"lr","i");
 
-        for i=1:size(module_list,"*")
-            module    = module_new();
-            module    = module_set_name(module,module_list(i))
-            module    = module_set_path(module,pathconvert(SCI+"/modules/"+module.name,%F));
-            tests     = get_tests_from_module(module,type_filter,skip_mat);
-            testsuite = testsuite_add_tests( testsuite, tests );
+        test_count = size(module_list,"*");
+        for i=1:test_count
+            if params.reference <> "list" then
+                printf("   %03d/%03d - [%s] : \n\n", i, test_count, module_list(i));
+            end
+
+            params.tests_mat            = [];
+            params.moduleName           =  module_list(i);
+            
+            result                      = test_module(params);
+
+            if params.reference <> "list" then
+                status.details_failed       = [status.details_failed; result.details_failed];
+                status.test_count           = status.test_count + result.test_count;
+                status.test_passed_count    = status.test_passed_count + result.test_passed_count;
+                status.test_failed_count    = status.test_failed_count + result.test_failed_count;
+                status.test_skipped_count   = status.test_skipped_count + result.test_skipped_count;
+                status.totalTime            = status.totalTime + result.totalTime;
+                printf("\n");
+            else
+                status.test_count           = status.test_count + result.test_count;
+                status.list                 = [status.list; result.list];
+            end
         end
 
     elseif (rhs == 1) ..
                 | ((rhs == 2) & (varargin(2)==[])) ..
                 | ((rhs == 3) & (varargin(2)==[])) ..
-                | ( ~ isempty(skip_mat)) then
+                | ( ~ isempty(params.skip_mat)) then
 
         // One input argument
         // test_run(<module_name>)
         // test_run([<module_name_1>,<module_name_2>])
-
         // varargin(1) = [<module_name_1>,<module_name_2>]
 
         module_mat = varargin(1);
 
-        // test_run([<module_name_1>,<module_name_2>])
-
-        for i=1:size(module_mat,"*")
-
-            module = module_new();
-            module = module_set_name(module,module_mat(i))
-
-             // It's a scilab internal module
-            if with_module(module.items(i)) then
-                module = module_set_path(module,pathconvert(SCI+"/modules/"+module.items(i),%F));
-
-            // It's an ATOMS module
-            elseif or(librarieslist() == "atomslib") ..
-                    & atomsIsLoaded(module.items(i)) then
-                module = module_set_path(module,pathconvert(atomsGetLoadedPath(module.items(i)),%F,%T));
-
-            // It's an external module
-            elseif isdir(module.items(i)) then
-                module = module_set_path(module,pathconvert(module.items(i),%F));
+        test_count = size(module_mat,"*");
+        for i = 1:test_count
+            if params.reference <> "list" then
+                printf("   %03d/%03d - [%s] : \n\n", i, test_count, module_mat(i));
+            end
 
-            // It's an error
+            params.tests_mat            = [];
+            params.moduleName           =  module_mat(i);
+            
+            result                      = test_module(params);
+
+            status.test_count           = status.test_count + result.test_count;
+            if params.reference <> "list" then
+                status.details_failed       = [status.details_failed; result.details_failed];
+                status.test_passed_count    = status.test_passed_count + result.test_passed_count;
+                status.test_failed_count    = status.test_failed_count + result.test_failed_count;
+                status.test_skipped_count   = status.test_skipped_count + result.test_skipped_count;
+                status.totalTime            = status.totalTime + result.totalTime;
+                printf("\n");
             else
-                error(sprintf(gettext("%s is not an installed module or toolbox"),module_mat(i)));
+                status.test_count           = status.test_count + result.test_count;
+                status.list                 = [status.list; result.list];
             end
-
-            tests = get_tests_from_module(module,type_filter,skip_mat);
-
-            testsuite = testsuite_add_tests( testsuite , tests);
-
         end
-
     elseif or(rhs==[2 3]) then
-
         // Two input arguments
         // test_run(<module_name>,<test_name>)
         // test_run(<module_name>,[<test_name_1>,<test_name_2>] )
@@ -249,865 +284,412 @@ function test_run(varargin)
         // varargin(1) = <module_name> ==> string 1x1
         // varargin(2) = <test_name_1> ==> mat nl x nc
 
-        module_in  = varargin(1);
-        test_mat   = varargin(2);
-
-        if ((or(size(module_in) <> [1,1])) & (test_mat <> [])) then
+        params.tests_mat            = varargin(2);
+        params.moduleName           = varargin(1);
 
+        if ((or(size(params.moduleName) <> [1,1])) & (params.tests_mat <> [])) then
             example = test_examples();
             err     = ["" ; msprintf(gettext("%s: Wrong size for input argument."),"test_run") ; "" ; example ];
             printf("%s\n",err);
             return;
         end
 
-        module = module_new();
-        module = module_set_name(module,module_in);
-
-        // It's a scilab internal module
-        if with_module(module.items(1)) then
-            module = module_set_path(module,pathconvert(SCI+"/modules/"+module.items(1),%F));
-
-        // It's an ATOMS module
-        elseif or(librarieslist() == "atomslib") ..
-                & atomsIsLoaded(module.items(1)) then
-            module = module_set_path(module,pathconvert(atomsGetLoadedPath(module.items(1)),%F,%T));
-
-        // It's an external module
-        elseif isdir(module.items(1)) then
-            module = module_set_path(module,pathconvert(module.items(1),%F));
-
-        // It's an error
+        result                      = test_module(params);
+    
+        if params.reference <> "list" then
+            status.totalTime            = result.totalTime;
+            status.details_failed       = [status.details_failed; result.details_failed];
+            status.test_count           = status.test_count + result.test_count;
+            status.test_passed_count    = status.test_passed_count + result.test_passed_count;
+            status.test_failed_count    = status.test_failed_count + result.test_failed_count;
+            status.test_skipped_count   = status.test_skipped_count + result.test_skipped_count;
         else
-            error(sprintf(gettext("%s is not an installed module or toolbox"),module.items(1)));
+            status.test_count           = status.test_count + result.test_count;
+            status.list                 = [status.list; result.list];
         end
-
-        for i=1:size(test_mat,"*")
-
-            types    = ["unit_tests";"nonreg_tests"]
-            my_tests = list();
-
-            for j=1:size(types,"*")
-
-                if (type_filter<>"all_tests") & (type_filter<>types(j)) then
-                    continue;
-                end
-
-                // Get the list of directories where search
-
-                test_directory_path = module.path + "/tests/" + types(j);
-                for k=2:size(module.items,"*")
-                    test_directory_path = test_directory_path + "/" + module.items(k);
-                end
-
-                // The main directory doesn't exist, continue the loop
-
-                if ~ isdir(test_directory_path) then
-                    continue;
-                end
-
-                test_main_directory = directory_new();
-                test_main_directory = directory_set_type(test_main_directory,types(j));
-                test_main_directory = directory_set_module(test_main_directory,module);
-                test_main_directory = directory_set_path(test_main_directory,test_directory_path);
-
-                test_directories = get_directories(test_main_directory);
-
-                for k=1:size(test_directories)
-
-                    this_directory = test_directories(k);
-
-                    test = st_new();
-                    test = st_set_name(   test , test_mat(i) );
-                    test = st_set_module( test , this_directory.module );
-                    test = st_set_type(   test , types(j) );
-                    test = st_set_path(   test , pathconvert( this_directory.path + "/" + test.name + ".tst" , %F ) );
-
-                    if ~ isempty( fileinfo(test.path) ) then
-                        test = st_analyse(test);
-                        my_tests($+1) = test;
-                    end
-
-                end
-
-            end
-
-            if size(my_tests) == 0 then
-                error(sprintf(gettext("The test ""%s"" is not available from the ""%s"" module"),test_mat(i),module.name));
-            end
-
-            testsuite = testsuite_add_tests(testsuite,my_tests);
-
-        end
-
     else
         error(msprintf(gettext('%s: Wrong number of input arguments.'),"test_run"));
     end
 
-    // =========================================================================
-    // Gestion des options
-    // =========================================================================
-
-    if rhs >= 3 then
-
-        // Mode
-
-        if grep(option_mat,"mode_nw") <> [] then
-            testsuite = testsuite_set_WM(testsuite,"NW");
-        end
-
-        if grep(option_mat,"mode_nwni") <> [] then
-            testsuite = testsuite_set_WM(testsuite,"NWNI");
-        end
-
-        // Reference
-
-        if grep(option_mat,"no_check_ref") <> [] then
-            testsuite = testsuite_set_reference(testsuite,"skip")
-        end
-
-        if grep(option_mat,"create_ref") <> [] then
-            testsuite = testsuite_set_reference(testsuite,"create")
-        end
-
-        // Error Output
-
-        if grep(option_mat,"no_check_error_output") <> [] then
-            testsuite = testsuite_set_EO(testsuite,"skip")
-        end
-
-        // Enable long-time tests
-
-        if grep(option_mat,"disable_lt") <> [] then
-            testsuite = testsuite_set_LT(testsuite,"skip")
-        end
-
-        if grep(option_mat,"enable_lt") <> [] then
-            testsuite = testsuite_set_LT(testsuite,"enable")
+    if params.reference == "list" then
+        test_count = size(status.list, "r");
+        for i=1:test_count
+            printf("   %4.d - [%s] %s\n", i, status.list(i, 1), status.list(i,2));
         end
-
-    end
-
-    // =========================================================================
-    // List test
-    // =========================================================================
-
-    if (rhs >= 3) & (~ isempty(grep(option_mat,"list"))) then
-        testsuite_list(testsuite);
-        clearglobal testsuite;
         return;
-
-    // =========================================================================
-    // Test launch
-    // =========================================================================
-
+    end
+    //pourcent computation
+    if status.test_count <> 0 then
+        test_passed_percent  = status.test_passed_count  / status.test_count * 100;
+        test_skipped_percent = status.test_skipped_count / status.test_count * 100;
+        test_failed_percent  = status.test_failed_count  / status.test_count * 100;
     else
-        testsuite_run(testsuite);
-        clearglobal testsuite;
-        return;
+        test_passed_percent  = 0;
+        test_skipped_percent = 0;
+        test_failed_percent  = 0;
     end
 
-endfunction
+    printf("\n");
+    printf("   --------------------------------------------------------------------------\n");
+    printf("   Summary\n\n");
+    printf("   tests                     %4d - 100 %% \n", status.test_count);
+    printf("   passed                    %4d - %3d %% \n", status.test_passed_count , test_passed_percent);
+    printf("   failed                    %4d - %3d %% \n", status.test_failed_count , test_failed_percent);
+    printf("   skipped                   %4d - %3d %% \n", status.test_skipped_count, test_skipped_percent);
+    printf("   length                          %4.2f sec \n", status.totalTime);
+    printf("   --------------------------------------------------------------------------\n");
 
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 28 oct. 2007
-//
-// => List all test files in the module <module_mat>
-// => Add them to the test_mat matrix
-//-----------------------------------------------------------------------------
+    if status.test_failed_count > 0 then
+        printf("   Details\n\n");
+        printf("%s\n",status.details_failed);
+        printf("\n");
+        printf("   --------------------------------------------------------------------------\n");
+    end
+endfunction
 
-function my_tests = get_tests_from_module(module,type_filter,skip_mat)
+function status = test_module(_params)
 
+    name = splitModule(_params.moduleName);
+    
+    if with_module(_params.moduleName) then
+        // It's a scilab internal module
+        module.path = pathconvert(SCI + "/modules/" + name(1), %F);
+    elseif or(librarieslist() == "atomslib") & atomsIsLoaded(name(1)) then
+        // It's an ATOMS module
+        module.path = pathconvert(atomsGetLoadedPath(name(1)) , %F, %T);
+    elseif isdir(name(1)) then
+        // It's an external module
+        module.path = pathconvert(name(1), %F);
+    else
+        // It's an error
+        error(sprintf(gettext("%s is not an installed module or toolbox"), name(1)));
+    end
+    
+    //get tests from path
     my_types = ["unit_tests","nonreg_tests"];
 
-    // 1st action : build the list of directories to explore
-    // test_type : {"all_tests"|"unit_tests"|"nonreg_tests"}
-
-    // Example of a directory :
-    //   path: "/home/robert/scilab/modules/time/tests/unit_tests/date"
-    //   type: "unit_tests"
-    //   module: "time|date"
-
-    my_directories = list();
-
+    directories = [];
     for i=1:size(my_types,"*")
+        if (_params.testTypes == "all_tests") | (_params.testTypes == my_types(i)) then
+            directory_path = module.path + "/tests/" + my_types(i);
 
-        if (type_filter == "all_tests") | (type_filter == my_types(i)) then
-
-            directory = directory_new();
-            directory = directory_set_type(directory,my_types(i));
-            directory = directory_set_module(directory,module);
-
-            directory_path = module.path+"/tests/"+my_types(i);
-            module_items   = module.items;
-
-            for j=2:size(module_items,"*")
-                directory_path = directory_path + "/" + module_items(j);
+            for j=2:size(name,"*")
+                directory_path = directory_path + filesep() + module_items(j);
             end
 
-            directory = directory_set_path(directory,directory_path);
-
-            if isdir(directory.path) then
-                my_directories = lstcat( my_directories , get_directories(directory) );
+            if isdir(directory_path) then
+                directories = [directories;getDirectories(directory_path + filesep())];
             end
         end
     end
 
-    // 2nd action : Build the list of tests
-    // Example of a test :
-    //   name: "bug_793"
-    //   path: "/home/robert/scilab/modules/time/tests/nonreg_tests/bug_793.tst"
-    //   type: "nonreg_tests"
-    //   module: "time"
-
-    my_tests = list();
-
-    for i=1:length(my_directories)
-
-        directory = my_directories(i);
-        tests_in  = get_tests_from_directory(directory.path);
-        tests_out = list();
-
-        for j=1:length(tests_in)
-            test = tests_in(j);
-            if or(test.name==skip_mat) then
-                continue;
+    tests = [];
+    if( _params.tests_mat == [])
+        for i=1:size(directories, "*")
+            currentDir = directories(i);
+            tests_mat = gsort(basename(listfiles(currentDir + filesep() + "*.tst")),"lr","i");
+            for j = 1:size(tests_mat, "*")
+                if or(tests_mat(j) == _params.skip_mat) == %f then
+                    tests($+1, [1,2]) = [currentDir, tests_mat(j)];
+                end
+            end
+        end
+    else
+        //not empty tests_mat
+        for i = 1:size(_params.tests_mat, "*")
+            for j = 1:size(directories, "*")
+                currentDir = directories(j);
+                testFile = currentDir + filesep() + _params.tests_mat(i) + ".tst";
+                if isfile(testFile) then
+                    tests($+1, [1,2]) = [currentDir, _params.tests_mat(i)];
+                end
             end
-            test = st_set_type(test,directory.type);
-            test = st_set_module(test,directory.module);
-            test = st_analyse(test);
-            tests_out($+1) = test;
         end
-
-        my_tests = lstcat( my_tests , tests_out );
-
     end
 
-endfunction
-
-
-
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 28 août 2009
-//
-// List all test file in the directory
-//-----------------------------------------------------------------------------
-
-function tests = get_tests_from_directory(directory)
-
-    tests = list();
+    //initialize counter
+    details_failed     = "";
+    test_count         = size(tests, "r");
+    test_passed_count  = 0;
+    test_failed_count  = 0;
+    test_skipped_count = 0;
 
-    if isdir(directory) then
-        test_mat = gsort(basename(listfiles(directory+"/*.tst")),"lr","i");
-        for i=1:size(test_mat,"*")
-            this_test  = st_new();
-            this_test  = st_set_name(this_test,test_mat(i));
-            this_test  = st_set_path(this_test,pathconvert(directory)+test_mat(i)+".tst");
-            tests($+1) = this_test;
+    moduleName = _params.moduleName;
+    // Improve the display of the module
+    if isdir(moduleName) then
+        if part(moduleName,1:length(SCI)) == SCI then
+            moduleName = "SCI" + part(moduleName,length(SCI)+1:length(moduleName));
+        elseif part(moduleName,1:length(SCIHOME)) == SCIHOME then
+            moduleName = "SCIHOME" + part(moduleName,length(SCIHOME)+1:length(moduleName));
         end
     end
 
-endfunction
-
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 28 août 2009
-//
-// => Get subdirectories of a directory
-//
-// directories is a list of "directory" object (See directory interface)
-//-----------------------------------------------------------------------------
-
-function directories = get_directories(directory)
-
-    this_directory_type   = directory.type;
-
-    directories           = list();
-    directories($+1)      = directory;
-
-    items = gsort(listfiles(directory.path),"lr","i");
-
-    for i=1:size(items,"*")
-        if isdir(pathconvert(directory.path) + items(i)) then
-
-            new_module = module_new();
-            new_module = module_set_name( new_module , directory.module.name +  "|" + items(i) );
-            new_module = module_set_path( new_module , pathconvert(directory.path) + items(i) );
-
-            new_dir = directory_new();
-            new_dir = directory_set_path(new_dir,pathconvert(directory.path) + items(i));
-            new_dir = directory_set_module(new_dir,new_module);
-            new_dir = directory_set_type(new_dir,directory.type)
-
-            directories = lstcat( directories , get_directories(new_dir) );
+    //don't test only return list of tests.
+    if _params.reference == "list" then
+        for i = 1:test_count
+            path = getPath(tests(i,1), my_types);
+            if ~isempty(path) then
+                displayModuleName = sprintf("%s", moduleName);
+                for j=1:size(path, "*")
+                    displayModuleName = displayModuleName + sprintf("|%s", path(j));
+                end
+            else
+                displayModuleName = sprintf("%s", moduleName);
+            end
+            tests(i,1) = displayModuleName;
         end
+        status.list         = tests;
+        status.test_count   = test_count;
+        return;
     end
 
-endfunction
-
-
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 8 novembre 2007
-//
-// => remove header from the diary txt
-//
-//-----------------------------------------------------------------------------
-
-function dia_out = remove_headers(dia_in)
-
-    dia_out = dia_in;
-
-    body_start = grep(dia_out,"// <-- HEADER END -->");
-
-    if body_start<>[] then
-        dia_out(1:body_start(1)) = [];
-    end
+    tic();
+    for i = 1:test_count
+        printf("   %03d/%03d - ",i, test_count);
+        path = getPath(tests(i,1), my_types);
+        if ~isempty(path) then
+            displayModuleName = sprintf("[%s", moduleName);
+            for j=1:size(path, "*")
+                displayModuleName = displayModuleName + sprintf("|%s", path(j));
+            end
+            displayModuleName = displayModuleName + sprintf("] %s", tests(i,2));
+        else
+            displayModuleName = sprintf("[%s] %s", moduleName, tests(i,2));
+        end
+        printf("%s", displayModuleName);
+        for j = length(displayModuleName):50
+            printf(".");
+        end
+        
+        result = test_single(_params, tests(i,1), tests(i,2));
 
-    body_end   = grep(dia_out,"// <-- FOOTER START -->");
+        if result.id == 0 then
+            printf("passed\n");
+            test_passed_count = test_passed_count + 1;
+        else
+            msg = sprintf(result.message);
+            printf("%s \n", msg(1));
+            for kline = 2:size(msg, "*")
+                printf(part(" ", 1:62) + "%s \n", msg(2));
+            end
+            
+            if result.id < 10 then
+                //failed
+                test_failed_count = test_failed_count + 1;
+                details_failed = [ details_failed ; sprintf("   TEST : [%s] %s", _params.moduleName, tests(i,2))];
+                details_failed = [ details_failed ; sprintf("     %s", result.message) ];
+                details_failed = [ details_failed ; result.details ];
+                details_failed = [ details_failed ; "" ];
+            elseif (result.id >= 10) & (result.id < 20) then
+                // skipped
+                test_skipped_count = test_skipped_count + 1;
+            end  
 
-    if body_end<>[] then
-        [dia_nl,dia_nc] = size(dia);
-        dia_out(body_end(1):dia_nl) = [];
+        end
     end
+    elapsedTime = toc();
+    status.totalTime = elapsedTime;
+    status.test_passed_count  = test_passed_count;
+    status.test_failed_count  = test_failed_count;
+    status.test_skipped_count = test_skipped_count;
 
-    return;
-
-endfunction
-
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 28 oct. 2007
-//
-// => Check ref or generate ref
-//-----------------------------------------------------------------------------
-
-function example = test_examples()
-
-    example = [ sprintf("Examples :\n\n") ];
-
-
-    example = [ example ; sprintf("// Launch all tests\n") ];
-    example = [ example ; sprintf("test_run();\n") ];
-    example = [ example ; sprintf("test_run([]);\n") ];
-    example = [ example ; sprintf("test_run([],[]);\n") ];
-    example = [ example ; "" ];
-    example = [ example ; sprintf("// Test one or several module\n") ];
-    example = [ example ; sprintf("test_run(''core'');\n") ];
-    example = [ example ; sprintf("test_run(''core'',[]);\n") ];
-    example = [ example ; sprintf("test_run([''core'',''string'']);\n") ];
-    example = [ example ; "" ];
-    example = [ example ; sprintf("// Launch one or several test in a specified module\n") ];
-    example = [ example ; sprintf("test_run(''core'',[''trycatch'',''opcode'']);\n") ];
-    example = [ example ; "" ];
-    example = [ example ; sprintf("// With options\n") ];
-    example = [ example ; sprintf("test_run([],[],''no_check_ref'');\n") ];
-    example = [ example ; sprintf("test_run([],[],''no_check_error_output'');\n") ];
-    example = [ example ; sprintf("test_run([],[],''create_ref'');\n") ];
-    example = [ example ; sprintf("test_run([],[],''list'');\n") ];
-    example = [ example ; sprintf("test_run([],[],''help'');\n") ];
-    example = [ example ; sprintf("test_run([],[],[''no_check_ref'',''mode_nw'']);\n") ];
-    example = [ example ; "" ];
-
-endfunction
-
-// =============================================================================
-// Pierre MARECHAL
-// Scilab team
-// Date : 31 août 2009
-//
-// singletest interface
-// =============================================================================
-
-// constructor
-// -----------------------------------------------------------------------------
-
-function st = st_new()
-
-    st = tlist([ "T_SINGLETEST"   ..
-                 "name"           ..
-                 "type"           ..
-                 "path"           ..
-                 "module"         ..
-                 "skip"           ..
-                 "content"        ..
-                 "interactive"    ..
-                 "notyetfixed"    ..
-                 "longtime"       ..    // needs long-time duration
-                 "reopened"       ..
-                 "platform"       ..
-                 "language"       ..
-                 "jvm_mandatory"  ..
-                 "graphic"        ..
-                 "mode"           ..    // NW, NWNI, GUI
-                 "reference"      ..    // check, create, skip
-                 "error_output"   ..    // check, skip
-                 "try_catch"      ..
-                 "path_dia"       ..    // diary file
-                 "path_dia_ref"   ..    // reference file
-                 "tmp_tst"        ..    // diary file
-                 "tmp_dia"        ..    // reference file
-                 "tmp_res"        ..    // diary file
-                 "tmp_err"        ..    // reference file
-                 "status"         ..    // status
-                 "xcos"           ..    // xcos test ?
-                 "cmd"            ..    // command to launch
-                 ] );
-
-    // Default values
-    st.skip          = %F;
-    st.interactive   = %F;
-    st.notyetfixed   = %F;
-    st.longtime      = %F;
-    st.reopened      = %F;
-    st.jvm_mandatory = %T;
-    st.graphic       = %F;
-    st.mode          = "";
-    st.platform      = "all";
-    st.language      = "any";
-    st.try_catch     = %T;
-    st.error_output  = "check";
-    st.reference     = "check";
-
-    st.path_dia      = "";
-    st.path_dia_ref  = "";
-
-    st.tmp_tst       = "";
-    st.tmp_dia       = "";
-    st.tmp_res       = "";
-    st.tmp_err       = "";
-
-    st.cmd           = "";
-
-    st.content       = "";
-
-    st.status        = status_new();
-
-    st.xcos          = %F;
-
-endfunction
-
-// setters
-// -----------------------------------------------------------------------------
-
-function st = st_set_name(st,name)
-
-    st.name = name;
-
-    st.tmp_tst       = pathconvert( TMPDIR + "/" + name + ".tst"     , %F);
-    st.tmp_dia       = pathconvert( TMPDIR + "/" + name + ".dia.tmp" , %F);
-    st.tmp_res       = pathconvert( TMPDIR + "/" + name + ".res"     , %F);
-    st.tmp_err       = pathconvert( TMPDIR + "/" + name + ".err"     , %F);
-    st.path_dia      = pathconvert( TMPDIR + "/" + name + ".dia"     , %F);
-endfunction
-
-function st = st_set_type(st,sttype)
-    st.type = sttype;
+    // Summary
+    status.test_count       = test_count;
+    status.details_failed   = details_failed;
 endfunction
 
-function st = st_set_path(st,path)
-
-    st.path         = path;
-    basepath        = strsubst(path,"/\.tst$/","","r");
-    st.path_dia_ref = basepath + ".dia.ref";
-
+function status = test_single(_module, _testPath, _testName)
+    //option flag
+    skip            = %F;
+    interactive     = %F;
+    notyetfixed     = %F;
+    longtime        = %F;
+    reopened        = %F;
+    jvm             = %T;
+    graphic         = %F;
+    execMode        = "";
+    platform        = "all";
+    language        = "any";
+    try_catch       = %T;
+    error_output    = "check";
+    reference       = "check";
+    xcosNeeded      = %F;
+
+    //some paths    
+    tmp_tst         = pathconvert( TMPDIR + "/" + _testName + ".tst", %F);    
+    tmp_dia         = pathconvert( TMPDIR + "/" + _testName + ".dia.tmp", %F);    
+    tmp_res         = pathconvert( TMPDIR + "/" + _testName + ".res", %F);    
+    tmp_err         = pathconvert( TMPDIR + "/" + _testName + ".err", %F);    
+    path_dia        = pathconvert( TMPDIR + "/" + _testName + ".dia", %F);    
+
+    path_dia_ref    = _testPath + _testName + ".dia.ref";
     // Reference file management OS by OS
     if getos() == 'Windows' then
-        altreffile = [ basepath+".win.dia.ref" ];
-    elseif MACOSX then
-        altreffile = [ basepath+".unix.dia.ref" ; basepath+".macosx.dia.ref" ];
-    elseif LINUX then
-        altreffile = [ basepath+".unix.dia.ref" ; basepath+".linux.dia.ref" ];
+        altreffile  = [ _testPath + _testName + ".win.dia.ref" ];
+    elseif getos() == 'Darwin' then
+        altreffile  = [ _testPath + _testName + ".unix.dia.ref" ; _testPath + _testName + ".macosx.dia.ref" ];
+    elseif getos() == 'Linux' then
+        altreffile  = [ _testPath + _testName + ".unix.dia.ref" ; _testPath + _testName + ".linux.dia.ref" ];
     else
-        altreffile = [ basepath+".unix.dia.ref" ];
+        altreffile  = [ _testPath + _testName + ".unix.dia.ref" ];
     end
 
     for i=1:size(altreffile,"*")
-        if ~ isempty(fileinfo(altreffile(i))) then
-            st.path_dia_ref = altreffile(i);
+        if isfile(altreffile(i)) then
+            path_dia_ref = altreffile(i);
         end
     end
 
-endfunction
-
-function st = st_set_module(st,module)
-    st.module = module;
-endfunction
-
-function st = st_set_skip(st,skip)
-    st.skip = skip;
-endfunction
-
-function st = st_set_content(st,content)
-    st.content = content;
-endfunction
-
-function st = st_set_interactive(st,interactive)
-    st.interactive = interactive;
-endfunction
-
-function st = st_set_notyetfixed(st,notyetfixed)
-    st.notyetfixed = notyetfixed;
-endfunction
-
-function st = st_set_longtime(st,longtime)
-    st.longtime = longtime;
-endfunction
-
-function st = st_set_reopened(st,reopened)
-    st.reopened = reopened;
-endfunction
-
-function st = st_set_platform(st,platform)
-    st.platform = platform;
-endfunction
-
-function st = st_set_jvm_mandatory(st,jvm_mandatory)
-    st.jvm_mandatory = jvm_mandatory;
-endfunction
-
-function st = st_set_graphic(st,graphic)
-    st.graphic = graphic;
-endfunction
-
-function st = st_set_language(st,language)
-    st.language = language;
-endfunction
-
-function st = st_set_try_catch(st,try_catch)
-    st.try_catch = try_catch;
-endfunction
-
-function st = st_set_error_output(st,error_output)
-    st.error_output = error_output;
-endfunction
-
-function st = st_set_reference(st,reference)
-    st.reference = reference;
-endfunction
-
-function st = st_set_status(st,status)
-    st.status = status;
-endfunction
-
-function st = st_set_cmd(st,cmd)
-    st.cmd = cmd;
-endfunction
-
-function st = st_set_mode(st,smode)
-    st.mode = smode;
-endfunction
-
-function st = st_set_xcos(st,xmode)
-    st.xcos = xmode;
-endfunction
-
-// show
-// -----------------------------------------------------------------------------
-
-function st_show(st)
-
-    if st.skip           then st_skip           = "Yes"; else st_skip           = "No"; end
-    if st.interactive    then st_interactive    = "Yes"; else st_interactive    = "No"; end
-    if st.notyetfixed    then st_notyetfixed    = "Yes"; else st_notyetfixed    = "No"; end
-    if st.longtime       then st_longtime       = "Yes"; else st_longtime       = "No"; end
-    if st.reopened       then st_reopened       = "Yes"; else st_reopened       = "No"; end
-    if st.jvm_mandatory  then st_jvm_mandatory  = "Yes"; else st_jvm_mandatory  = "No"; end
-    if st.graphic        then st_graphic        = "Yes"; else st_graphic        = "No"; end
-    if st.try_catch      then st_try_catch      = "Yes"; else st_try_catch      = "No"; end
-    if st.xcos           then st_xcos           = "Yes"; else st_xcos           = "No"; end
-
-    mprintf("Test :\n");
-    mprintf("  name           = %s\n"   ,st.name);
-    mprintf("  type           = %s\n"   ,st.type);
-    mprintf("  module         = %s\n"   ,st.module.name);
-    mprintf("\n");
-
-    mprintf("Test paths :\n");
-    mprintf("  path           = %s\n"   ,st.path);
-    mprintf("  path_dia       = %s\n"   ,st.path_dia);
-    mprintf("  path_dia_ref   = %s\n"   ,st.path_dia_ref);
-    mprintf("  tmp_tst        = %s\n"   ,st.tmp_tst);
-    mprintf("  tmp_dia        = %s\n"   ,st.tmp_dia);
-    mprintf("  tmp_res        = %s\n"   ,st.tmp_res);
-    mprintf("  tmp_err        = %s\n"   ,st.tmp_err);
-    mprintf("\n");
-
-    mprintf("Test features :\n");
-    mprintf("  skip           = %s\n"   ,st_skip);
-    mprintf("  interactive    = %s\n"   ,st_interactive);
-    mprintf("  notyetfixed    = %s\n"   ,st_notyetfixed);
-    mprintf("  longtime       = %s\n"   ,st_longtime);
-    mprintf("  reopened       = %s\n"   ,st_reopened);
-    mprintf("  platform       = %s\n"   ,st.platform);
-    mprintf("  jvm_mandatory  = %s\n"   ,st_interactive);
-    mprintf("  graphic        = %s\n"   ,st_graphic);
-    mprintf("  mode           = %s\n"   ,st.mode);
-    mprintf("  reference      = %s\n"   ,st.reference);
-    mprintf("  error_output   = %s\n"   ,st.error_output);
-    mprintf("  try_catch      = %s\n"   ,st_try_catch);
-    mprintf("  xcos           = %s\n"   ,st_xcos);
-    mprintf("\n");
-
-    mprintf("Test scilab cmd :\n");
-    mprintf("  cmd            = %s\n"   ,st.cmd);
-    mprintf("\n");
-
-    module_show(test.module);
-    status_show(test.status);
-
-endfunction
-
-// Analyse
-// -----------------------------------------------------------------------------
-
-function st = st_analyse(st)
-
-    if typeof(st) <> "T_SINGLETEST" then
-        error(msprintf(gettext("%s: Wrong type for input argument #%d: %s expected.\n"),"st_analyse","T_SINGLETEST",1));
-    end
-
-    if isempty( fileinfo(st.path) ) then
-        error(msprintf(gettext("%s: The test ''%s'' doesn''t exist or is not read available.\n"),"st_analyse",st.path));
-    end
-
-    // Get the test content
-    st = st_set_content(st,mgetl(st.path));
+    //output structure
+    status.id = 0;
+    status.message = "";
+    status.details = "";
 
-    // Test status
-    // =========================================================================
+    //Reset standard globals
+    rand("seed",0);
+    rand("uniform");
 
-    if ~ isempty( grep(st.content,"<-- NOT FIXED -->") ) then
-        st = st_set_notyetfixed(st,%T);
+    //load file
+    testFile = _testPath + _testName + ".tst";
+    sciFile = mgetl(testFile);
+    
+    //read options
+    if ~isempty(grep(sciFile, "<-- NOT FIXED -->")) then
+        status.id = 10;
+        status.message = "skipped: not yet fixed";
+        return;
     end
 
-    if ~ isempty( grep(st.content,"<-- REOPENED -->") ) then
-        st = st_set_reopened(st,%T);
+    if ~isempty(grep(sciFile, "<-- REOPENED -->")) then
+        status.id = 10;
+        status.message = "skipped: Bug reopened";
+        return;
     end
 
     // platform
-    // =========================================================================
-
-    if ~ isempty( grep(st.content,"<-- WINDOWS ONLY -->") ) then
-        st = st_set_platform(st,"windows");
-    end
-
-    if ~ isempty( grep(st.content,"<-- LINUX ONLY -->") ) then
-        st = st_set_platform(st,"linux");
+    if ~isempty(grep(sciFile, "<-- WINDOWS ONLY -->")) & getos() <> "Windows" then
+        status.id = 10;
+        status.message = "skipped: Windows only";
+        return;
     end
 
-    if ~ isempty( grep(st.content,"<-- MACOSX ONLY -->") ) then
-        st = st_set_platform(st,"macosx");
+    if ~isempty(grep(sciFile, "<-- LINUX ONLY -->")) & getos() <> "Linux" then
+        status.id = 10;
+        status.message = "skipped: Linux only";
+        return;
     end
 
-    if ~ isempty( grep(st.content,"<-- MACOSX ONLY -->") ) then
-        st = st_set_platform(st,"macosx");
+    if ~isempty(grep(sciFile, "<-- MACOSX ONLY -->")) & getos() <> "Darwin" then
+        status.id = 10;
+        status.message = "skipped: MacOSX only";
+        return;
     end
 
     // Test execution
-    // =========================================================================
-
-    if ~ isempty( grep(st.content,"<-- INTERACTIVE TEST -->") ) then
-        st = st_set_interactive(st,%T);
-    end
-
-    if ~ isempty( grep(st.content,"<-- LONG TIME EXECUTION -->") ) then
-        st = st_set_longtime(st,%T);
-    end
-
-    if ~ isempty( grep(st.content,"<-- TEST WITH GRAPHIC -->") ) then
-        st = st_set_graphic(st,%T);
-        st = st_set_jvm_mandatory(st,%T);
-        st = st_set_mode(st,"NW");
-    end
-
-    if ~ isempty( grep(st.content,"<-- JVM NOT MANDATORY -->") ) then
-        st = st_set_jvm_mandatory(st,%F);
-        st = st_set_mode(st,"NWNI");
-    end
-
-    if ~ isempty( grep(st.content,"<-- XCOS TEST -->") ) then
-        st = st_set_xcos(st,%T);
-        st = st_set_jvm_mandatory(st,%T);
-    end
-    // Language
-    // =========================================================================
-
-    if ~ isempty( grep(st.content,"<-- FRENCH IMPOSED -->") ) then
-        st = st_set_language(st,"fr_FR");
-    end
-
-    if ~ isempty( grep(st.content,"<-- ENGLISH IMPOSED -->") ) then
-        st = st_set_language(st,"en_US");
-    end
-
-    // Test building
-    // =========================================================================
-
-    if ~ isempty( grep(st.content,"<-- NO TRY CATCH -->") ) then
-        st = st_set_try_catch(st,%F);
-    end
-
-    // Test result
-    // =========================================================================
-
-    if ~ isempty( grep(st.content,"<-- NO CHECK ERROR OUTPUT -->") ) then
-        st = st_set_error_output(st,"skip");
-    end
-
-    if ~ isempty( grep(st.content,"<-- NO CHECK REF -->") ) then
-        st = st_set_reference(st,"skip");
-    end
-
-endfunction
-
-
-//-----------------------------------------------------------------------------
-// Pierre MARECHAL
-// Scilab team
-// Date : 28 oct. 2007
-//
-// => Run one test
-//
-// Example of test variable :
-//    name: "bug_793"
-//    path: "/home/robert/scilab/modules/time/tests/nonreg_tests/bug_793.tst"
-//    type: "nonreg_tests"
-//    module: "time"
-//
-//-----------------------------------------------------------------------------
-
-function st = st_run(st)
-
-    //Reset standard globals
-    rand("seed",0);
-    rand("uniform");
-
-    st.status = status_new();
-
-    // Case where the test is skipped
-    // =========================================================================
-
-    // The test is interactive
-
-    if st.interactive then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : interactive test");
+    if ~isempty(grep(sciFile, "<-- INTERACTIVE TEST -->")) then
+        status.id = 10;
+        status.message = "skipped: interactive test";
         return;
     end
 
-    // The test needs long-time duration
-
-    if st.longtime & (testsuite.longtime == "skip") then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : Long time duration");
+    if ~isempty(grep(sciFile, "<-- LONG TIME EXECUTION -->")) & _module.longtime then
+        status.id = 10;
+        status.message = "skipped: Long time duration";
         return;
     end
 
-    // The bug is not yet fixed
-
-    if st.notyetfixed then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : not yet fixed");
-        return;
+    if ~isempty(grep(sciFile, "<-- TEST WITH GRAPHIC -->")) then
+        if _module.wanted_mode == "NWNI" then
+            status.id = 10;
+            status.message = "skipped: Test with graphic";
+            return;
+        end
+        
+        graphic = %T;
+        jvm = %T;
+        execMode = "NW";
     end
 
-    // The bug is reopenned
-
-    if st.reopened then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : Bug reopened");
-        return;
+    if ~isempty(grep(sciFile, "<-- JVM NOT MANDATORY -->")) then
+        jvm = %F;
+        execMode = "NWNI";
     end
 
-    // The test cannot be launched on this platform
-
-    if (st.platform=="windows") & (getos() <> 'Windows') then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : Windows only");
-        return;
+    if ~isempty(grep(sciFile, "<-- XCOS TEST -->")) then
+        xcosNeeded = %T;
+        jvm = %T;
     end
 
-    if (st.platform=="unix") & getos() == 'Windows' then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : Unix only");
-        return;
+    // Language
+    if ~isempty(grep(sciFile, "<-- FRENCH IMPOSED -->")) then
+        language = "fr_FR";
     end
 
-    if (st.platform=="linux") & (~LINUX) then
-        st.status = status_set_id(status,10);
-        st.status = status_set_message(status,"skipped : Linux only");
-        return;
+    if ~isempty(grep(sciFile, "<-- ENGLISH IMPOSED -->")) then
+        language = "en_US";
     end
 
-    if (st.platform=="macosx") & (~MACOSX) then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : MacOSX only");
-        return;
+    // Test building
+    if ~isempty(grep(sciFile, "<-- NO TRY CATCH -->")) then
+        try_catch = %F;
     end
 
-    // The test launches some graphic windows
-
-    if st.graphic & (testsuite.wanted_mode == "NWNI") then
-        st.status = status_set_id(st.status,10);
-        st.status = status_set_message(st.status,"skipped : Test with graphic");
-        return;
+    // Test result
+    if ~isempty(grep(sciFile, "<-- NO CHECK ERROR OUTPUT -->")) then
+        error_output = "skip";
     end
 
-    // Build the test
-    // =========================================================================
-
-    txt = st.content;
+    if ~isempty(grep(sciFile, "<-- NO CHECK REF -->")) then
+        reference = "skip";
+    end
+    
+    //build real test file
 
     // Do some modification in tst file
-    txt = strsubst(txt,"pause,end" ,"bugmes();quit;end");
-    txt = strsubst(txt,"pause, end","bugmes();quit;end");
-    txt = strsubst(txt,"pause;end" ,"bugmes();quit;end");
-    txt = strsubst(txt,"pause; end","bugmes();quit;end");
-    txt = strsubst(txt,"-->","@#>"); //to avoid suppression of input --> with prompts
-    txt = strsubst(txt,"halt();","");
-
-    // Test header
-
+    //replace "pause,end" by "bugmes();quit;end"
+    sciFile = strsubst(sciFile, "pause,end", "bugmes();quit;end");
+    sciFile = strsubst(sciFile, "pause, end", "bugmes();quit;end");
+    sciFile = strsubst(sciFile, "pause;end", "bugmes();quit;end");
+    sciFile = strsubst(sciFile, "pause; end", "bugmes();quit;end");
+    
+    //to avoid suppression of input --> with prompts
+    sciFile = strsubst(sciFile, "-->", "@#>"); 
+    //remove halt calls
+    sciFile = strsubst(sciFile, "halt();", "");
+
+    // Build test header
     head = [                                                                    ...
         "// <-- HEADER START -->";                                              ...
         "mode(3);" ;                                                            ...
         "lines(28,72);";                                                        ...
         "lines(0);" ;                                                           ...
-        "function %onprompt" ;                                                           ...
-        "quit;" ;                                                           ...
-        "endfunction" ;                                                           ...
+        "function %onprompt" ;                                                  ...
+        "quit;" ;                                                               ...
+        "endfunction" ;                                                         ...
         "deff(''[]=bugmes()'',''write(%io(2),''''error on test'''')'');" ;      ...
         "predef(''all'');" ;                                                    ...
         "tmpdirToPrint = msprintf(''TMPDIR1=''''%s''''\n'',TMPDIR);"            ...
     ]
 
-    if st.xcos then
+    if xcosNeeded then
         head = [ head ; "loadXcosLibs();"];
     end
 
-    if st.try_catch then
+    if try_catch then
         head = [ head ; "try" ];
     end
-
+    
     head = [                                                                    ...
         head ;                                                                  ...
-        "diary(''"+st.tmp_dia+"'');";                                          ...
+        "diary(''" + tmp_dia + "'');";                                          ...
         "write(%io(2),tmpdirToPrint);";                                         ...
         "// <-- HEADER END -->"                                                 ...
     ];
-
-    // Test footer
-
+    
+    // Build test footer
     tail = [ "// <-- FOOTER START -->" ];
 
-    if st.try_catch then
+    if try_catch then
         tail = [ tail;                                                          ...
             "catch";                                                            ...
             "   errmsg = ""<--""+""Error on the test script file""+""-->"";";   ...
@@ -1119,309 +701,268 @@ function st = st_run(st)
 
     tail = [ tail; "diary(0);" ];
 
-    if st.graphic then
+    if graphic then
         tail = [ tail; "xdel(winsid());sleep(1000);" ];
     end
 
     tail = [ tail; "exit;" ; "// <-- FOOTER END -->" ];
-
-    // Assembly
-
-    txt = [head;
-        txt;
-        tail];
-
-    // Build the command
-    // =========================================================================
-
-    // Gestion de l'emplacement de bin/scilab
-    // -------------------------------------------------------------------------
-
-    if (getos() <> 'Windows') & (fileinfo(SCI+"/bin/scilab")==[]) then
+    //Build final test
+    sciFile = [head ; sciFile ; tail];
+    //Build command to execute
+    
+    //scilab path
+    if (getos() <> 'Windows') & ~isfile(SCI+"/bin/scilab") then
         SCI_BIN = strsubst(SCI,'share/scilab','');
     else
         SCI_BIN = SCI;
     end
-
-    // Mode Argument (NW, NWNI, GUI)
-    // -------------------------------------------------------------------------
-
-    if testsuite.wanted_mode == "NW" then
+    
+    //mode
+    if _module.wanted_mode == "NW" then
         mode_arg = "-nw";
-
-    elseif testsuite.wanted_mode == "NWNI" then
+    elseif _module.wanted_mode == "NWNI" then
         mode_arg = "-nwni";
-
     else
-        if st.mode == "NWNI" then
+        if mode == "NWNI" then
             mode_arg = "-nwni";
-        elseif st.mode == "NW" then
+        elseif mode == "NW" then
             mode_arg = "-nw";
         else
             mode_arg = "-nw";
         end
     end
-
-    // Language Argument (en_US, fr_FR, ... )
-    // -------------------------------------------------------------------------
-
-    if st.language == "any" then
+    
+    //language
+    if language == "any" then
         language_arg = "";
     elseif getos() == 'Windows' then
-        language_arg = "-l "+ st.language;
+        language_arg = "-l "+ language;
     else
-        language_arg = "LANG=" + st.language + " ; ";
+        language_arg = "LANG=" + language + " ; ";
     end
 
-    // Assembly
-    // -------------------------------------------------------------------------
-
+    //Buld final command
     if getos() == 'Windows' then
-        test_cmd = "( """+SCI_BIN+"\bin\scilex.exe"+""""+" "+mode_arg+" "+language_arg+" -nb -f """+st.tmp_tst+""" > """+st.tmp_res+""" ) 2> """+st.tmp_err+"""";
+        test_cmd = "( """ + SCI_BIN + "\bin\scilex.exe" + """" + " " + mode_arg + " " + language_arg + " -nb -f """ + tmp_tst + """ > """ + tmp_res + """ ) 2> """ + tmp_err + """";
     else
-        test_cmd = "( "+language_arg+" "+SCI_BIN+"/bin/scilab "+mode_arg+" -nb -f "+st.tmp_tst+" > "+st.tmp_res+" ) 2> "+st.tmp_err;
+        test_cmd = "( " + language_arg + " " + SCI_BIN + "/bin/scilab " + mode_arg + " -nb -f " + tmp_tst + " > " + tmp_res + " ) 2> " + tmp_err;
     end
-
-    st= st_set_cmd(st,test_cmd);
-
-    // Remove the previous tmp files
-    // =========================================================================
-
-    if ~ isempty(fileinfo(st.tmp_tst)) then
-        deletefile(st.tmp_tst);
+   
+    //clean previous tmp files
+    if isfile(tmp_tst) then
+        deletefile(tmp_tst);
     end
 
-    if ~ isempty(fileinfo(st.tmp_dia)) then
-        deletefile(st.tmp_dia);
+    if isfile(tmp_dia) then
+        deletefile(tmp_dia);
     end
 
-    if ~ isempty(fileinfo(st.tmp_res)) then
-        deletefile(st.tmp_res);
+    if isfile(tmp_res) then
+        deletefile(tmp_res);
     end
 
-    if ~ isempty(fileinfo(st.tmp_err)) then
-        deletefile(st.tmp_err);
+    if isfile(tmp_err) then
+        deletefile(tmp_err);
     end
+        
+    //create tmp test file
+    mputl(sciFile, tmp_tst);
+            
+    //execute test
+    host(test_cmd);
 
-
-    // Write the tmp test file
-    // =========================================================================
-    mputl(txt,st.tmp_tst);
-
-
-    // Launch the test exec
-    // =========================================================================
-    host(st.cmd);
-
-
-
-    // First Check : error output
-    // =========================================================================
-
-    if (st.error_output == "check") & (testsuite.error_output == "check") then
-
+    //Check errors
+    if (error_output == "check") & (_module.error_output == "check") then
         if getos() == "Darwin" then
-            tmp_errfile_info = fileinfo(st.tmp_err);
+            tmp_errfile_info = fileinfo(tmp_err);
             msg = "JavaVM: requested Java version (1.5) not available. Using Java at ""/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"" instead."
 
             if ~isempty(tmp_errfile_info) then
-                txt = mgetl(st.tmp_err);
+                txt = mgetl(tmp_err);
                 txt(txt==msg) = [];
                 if isempty(txt) then
-                    deletefile(st.tmp_err);
+                    deletefile(tmp_err);
                 end
             end
         end
 
-        tmp_errfile_info = fileinfo(st.tmp_err);
+        tmp_errfile_info = fileinfo(tmp_err);
 
-        if ( (tmp_errfile_info <> []) & (tmp_errfile_info(1)<>0) ) then
-            st.status = status_set_id(st.status,5);
-            st.status = status_set_message(st.status,"failed  : error_output not empty\n     Use ''no_check_error_output'' option to disable this check.");
-            st.status = status_set_details(st.status,st_checkthefile(st.tmp_err));
+        if isfile(tmp_err) & tmp_errfile_info(1) <> 0 then
+            status.id = 5;
+            status.message = "failed: error_output not empty\n     Use ''no_check_error_output'' option to disable this check.";
+            status.details = checkthefile(tmp_err);
             return;
         end
     end
 
-    //  Get the dia file
-    dia = mgetl(st.tmp_dia);
+    //Process output files    
+
+    //Get the dia file
+    dia = mgetl(tmp_dia);
 
     // To get TMPDIR value
-    tmpdir1_line = grep(dia,"TMPDIR1");
+    tmpdir1_line = grep(dia, "TMPDIR1");
     execstr(dia(tmpdir1_line));
 
     //Check for execution errors
-    if st.try_catch & grep(dia,"<--Error on the test script file-->")<>[] then
-        details = [ st_checkthefile(st.tmp_dia); ..
-                    st_launchthecommand(st.path) ];
-        st.status = status_set_id(st.status,3);
-        st.status = status_set_message(st.status,"failed  : premature end of the test script");
-        st.status = status_set_details(st.status,details);
+    if try_catch & grep(dia,"<--Error on the test script file-->") <> [] then
+        details = [ checkthefile(tmp_dia); ..
+                    launchthecommand(testFile)];
+        status.id = 3;
+        status.message = "failed: premature end of the test script";
+        status.details = details;
         return;
     end
-
+    
     // Remove Header and Footer
     dia = remove_headers(dia);
-
+    
     //Check for execution errors
-    dia_tmp                     = dia;
-    dia_tmp(grep(dia_tmp,"//")) = [];  // remove commented lines
-
-    if st.try_catch & grep(dia_tmp,"!--error")<>[] then
-        details = [ st_checkthefile(st.tmp_dia); ..
-                    st_launchthecommand(st.path) ];
-        st.status = status_set_id(st.status,1);
-        st.status = status_set_message(st.status,"failed  : the string (!--error) has been detected");
-        st.status = status_set_details(st.status,details);
+    dia_tmp = dia;
+    
+    // remove commented lines
+    dia_tmp(grep(dia_tmp, "//")) = [];
+
+    if try_catch & grep(dia_tmp, "!--error") <> [] then
+        details = [ checkthefile(tmp_dia); ..
+                    launchthecommand(testFile) ];
+        status.id = 1;
+        status.message = "failed: the string (!--error) has been detected";
+        status.details = details;
         return;
     end
 
 
     if grep(dia_tmp,"error on test")<>[] then
-        details = [ st_checkthefile(st.tmp_dia); ..
-                    st_launchthecommand(st.path) ];
-        st.status = status_set_id(st.status,2);
-        st.status = status_set_message(st.status, "failed  : one or several tests failed");
-        st.status = status_set_details(st.status,details);
+        details = [ checkthefile(tmp_dia); ..
+                    launchthecommand(testFile) ];
+        status.id = 2;
+        status.message = "failed: one or several tests failed";
+        status.details = details;
         return;
     end
 
 
     if tmpdir1_line == [] then
-        st.status = status_set_id(st.status,6);
-        st.status = status_set_message(st.status, "failed  : the dia file is not correct");
-        st.status = status_set_details(st.status,st_checkthefile(st.tmp_dia));
+        status.id = 6;
+        status.message = "failed: the dia file is not correct";
+        status.details = checkthefile(tmp_dia);
         return;
     end
-
-
+    
 
     // Check the reference file only if check_ref (i.e. for the whole
     // test sequence) is true and this_check_ref (i.e. for the specific current .tst)
     // is true.
 
-    if (st.reference=="check") & (testsuite.reference=="check")  then
-        if isempty(fileinfo(st.path_dia_ref)) then
-            st.status = status_set_id(st.status,5);
-            st.status = status_set_message(st.status,"failed  : the ref file doesn''t exist\n     Use ''no_check_ref'' option to disable this check.");
-            st.status = status_set_details(st.status,st_createthefile(st.path_dia_ref));
+    if (reference=="check") & (_module.reference=="check")  then
+        if isfile(path_dia_ref) == %f then
+            status.id = 5;
+            status.message = "failed: the ref file doesn''t exist\n     Use ''no_check_ref'' option to disable this check.";
+            status.details = createthefile(path_dia_ref);
             return;
         end
     end
 
     // Comparaison ref <--> dia
 
-    if ( (st.reference=="check") & (testsuite.reference=="check") ) | (testsuite.reference=="create") then
-
+    if ( (reference=="check") & (_module.reference=="check") ) | (_module.reference=="create") then
         //  Do some modification in  dia file
-        dia(grep(dia,"write(%io(2),tmpdirToPrint"))= [];
-        dia(grep(dia,"TMPDIR1"))                   = [];
-        dia(grep(dia,"diary(0)"))                  = [];
+        dia(grep(dia, "write(%io(2), tmpdirToPrint")) = [];
+        dia(grep(dia, "TMPDIR1")) = [];
+        dia(grep(dia, "diary(0)")) = [];
 
         dia = strsubst(dia,TMPDIR ,"TMPDIR");
-        dia = strsubst(dia,TMPDIR1,"TMPDIR");
+        dia = strsubst(dia,TMPDIR1, "TMPDIR");
 
         if getos() == 'Windows' then
-            dia = strsubst(dia,strsubst(TMPDIR ,"\","/"),"TMPDIR");
-            dia = strsubst(dia,strsubst(TMPDIR1,"\","/"),"TMPDIR");
-            dia = strsubst(dia,strsubst(TMPDIR ,"/","\"),"TMPDIR");
-            dia = strsubst(dia,strsubst(TMPDIR1,"/","\"),"TMPDIR");
-            dia = strsubst(dia,strsubst(getshortpathname(TMPDIR) ,"\","/"),"TMPDIR");
-            dia = strsubst(dia,strsubst(getshortpathname(TMPDIR1),"\","/"),"TMPDIR");
-            dia = strsubst(dia,getshortpathname(TMPDIR) ,"TMPDIR");
-            dia = strsubst(dia,getshortpathname(TMPDIR1),"TMPDIR");
+            dia = strsubst(dia, strsubst(TMPDIR, "\","/"), "TMPDIR");
+            dia = strsubst(dia, strsubst(TMPDIR1, "\","/"), "TMPDIR");
+            dia = strsubst(dia, strsubst(TMPDIR, "/","\"), "TMPDIR");
+            dia = strsubst(dia, strsubst(TMPDIR1, "/","\"), "TMPDIR");
+            dia = strsubst(dia, strsubst(getshortpathname(TMPDIR), "\","/"), "TMPDIR");
+            dia = strsubst(dia, strsubst(getshortpathname(TMPDIR1), "\","/"), "TMPDIR");
+            dia = strsubst(dia, getshortpathname(TMPDIR), "TMPDIR");
+            dia = strsubst(dia, getshortpathname(TMPDIR1), "TMPDIR");
         end
 
-        dia = strsubst(dia,SCI,"SCI");
+        dia = strsubst(dia, SCI, "SCI");
 
         if getos() == 'Windows' then
-            dia = strsubst(dia,strsubst(SCI ,"\","/"),"SCI");
-            dia = strsubst(dia,strsubst(SCI ,"/","\"),"SCI");
-            dia = strsubst(dia,strsubst(getshortpathname(SCI) ,"\","/"),"SCI");
-            dia = strsubst(dia,getshortpathname(SCI) ,"SCI");
+            dia = strsubst(dia, strsubst(SCI, "\","/"), "SCI");
+            dia = strsubst(dia, strsubst(SCI, "/","\"), "SCI");
+            dia = strsubst(dia, strsubst(getshortpathname(SCI), "\","/"), "SCI");
+            dia = strsubst(dia, getshortpathname(SCI), "SCI");
         end
 
         //suppress the prompts
-        dia = strsubst(dia,"-->" ,"");
-        dia = strsubst(dia,"@#>" ,"-->");
-        dia = strsubst(dia,"-1->","");
+        dia = strsubst(dia, "-->", "");
+        dia = strsubst(dia, "@#>", "-->");
+        dia = strsubst(dia, "-1->", "");
 
         //standardise  number display
 
-        // strsubst(dia," .","0.");
-        // strsubst(dia,"-.","-0.")
-        // strsubst(dia,"E+","D+");
-        // strsubst(dia,"E-","D-");
+        // strsubst(dia, " .", "0.");
+        // strsubst(dia, "-.", "-0.")
+        // strsubst(dia, "E+", "D+");
+        // strsubst(dia, "E-", "D-");
 
         //not to change the ref files
-        dia = strsubst(dia,"bugmes();return","bugmes();quit");
-
-        if testsuite.reference=="create" then
+        dia = strsubst(dia ,"bugmes();return", "bugmes();quit");
 
+        if _module.reference=="create" then
             // Delete previous .dia.ref file
-            if fileinfo(st.path_dia_ref) <> [] then
-                deletefile(st.path_dia_ref)
+            if isfile(path_dia_ref) then
+                deletefile(path_dia_ref)
             end
 
-            mputl(dia,st.path_dia_ref);
-
-            st.status = status_set_id(st.status,20);
-            st.status = status_set_message(st.status,"passed : ref created");
+            mputl(dia, path_dia_ref);
+            status.id = 20;
+            status.message = "passed: ref created";
             return;
-
         else
-
             // write down the resulting dia file
-            mputl(dia,st.path_dia);
+            mputl(dia, path_dia);
 
             //Check for diff with the .ref file
-
-            [u,ierr] = mopen(st.path_dia_ref,"r");
+            [u,ierr] = mopen(path_dia_ref, "r");
             if ierr== 0 then //ref file exists
-
                 ref=mgetl(u);
                 mclose(u)
 
                 // suppress blank (diff -nw)
+                dia = strsubst(dia, ' ', '')
+                ref = strsubst(ref, ' ', '')
 
-                dia = strsubst(dia,' ','')
-                ref = strsubst(ref,' ','')
+                dia(find(dia == '')) = [];
+                ref(find(ref == '')) = [];
 
-                dia(find(dia=='')) = [];
-                ref(find(ref=='')) = [];
+                dia(find(dia == '')) = [];
+                ref(find(ref == '')) = [];
 
-                dia(find(dia=='')) = [];
-                ref(find(ref=='')) = [];
+                dia(find(part(dia, (1:2)) == "//")) = [];
+                ref(find(part(ref, (1:2)) == "//")) = [];
 
-                dia( find(part(dia,(1:2))=="//") ) = [];
-                ref( find(part(ref,(1:2))=="//") ) = [];
-
-                if or(ref<>dia) then
-                    st.status = status_set_id(st.status,4);
-                    st.status = status_set_message(st.status,"failed  : dia and ref are not equal");
-                    st.status = status_set_details(st.status,st_comparethefiles(st.path_dia,st.path_dia_ref));
+                if or(ref <> dia) then
+                    status.id = 4;
+                    status.message = "failed: dia and ref are not equal";
+                    status.details = comparethefiles(path_dia, path_dia_ref);
                     return;
                 end
 
             else
-                error(sprintf(gettext("The ref file (%s) doesn''t exist"),st.path_dia_ref));
+                error(sprintf(gettext("The ref file (%s) doesn''t exist"), path_dia_ref));
             end
         end
-
     end
-
-    st.status = status_set_id(st.status,0);
-    st.status = status_set_message(st.status,"passed");
-
-    return;
-
 endfunction
 
-
-// st_checkthefile
-// -----------------------------------------------------------------------------
-
-function msg = st_checkthefile ( filename )
+// checkthefile
+function msg = checkthefile( filename )
   // Returns a 2-by-1 matrix of strings, containing a message such as:
   //     Check the following file :
   //     - C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.tst
@@ -1430,12 +971,8 @@ function msg = st_checkthefile ( filename )
   msg(2) = "     - "+filename
 endfunction
 
-
-
-// st_launchthecommand
-// -----------------------------------------------------------------------------
-
-function msg = st_launchthecommand ( filename )
+// launchthecommand
+function msg = launchthecommand( filename )
   // Returns a 2-by-1 matrix of strings, containing a message such as:
   //     Or launch the following command :
   //     - exec("C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.tst")
@@ -1444,24 +981,23 @@ function msg = st_launchthecommand ( filename )
   msg(2) = "     - exec(""" + filename + """);"
 endfunction
 
-// st_comparethefiles
-// -----------------------------------------------------------------------------
+// => remove header from the diary txt
+function dia_out = remove_headers(dia_in)
+    dia_out = dia_in;
+    body_start = grep(dia_out,"// <-- HEADER END -->");
+    if body_start <> [] then
+        dia_out(1:body_start(1)) = [];
+    end
 
-function msg = st_comparethefiles ( filename1 , filename2 )
-  // Returns a 3-by-1 matrix of strings, containing a message such as:
-  //     Compare the following files :
-  //     - C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.dia
-  //     - C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.dia.ref
-  // Workaround for bug #4827
-  msg(1) = "     Compare the following files :"
-  msg(2) = "     - "+filename1
-  msg(3) = "     - "+filename2
+    body_end   = grep(dia_out,"// <-- FOOTER START -->");
+    if body_end <> [] then
+        [dia_nl,dia_nc] = size(dia);
+        dia_out(body_end(1):dia_nl) = [];
+    end
 endfunction
 
-// st_createthefile
-// -----------------------------------------------------------------------------
-
-function msg = st_createthefile ( filename )
+//createthefile
+function msg = createthefile ( filename )
   // Returns a 2-by-1 matrix of strings, containing a message such as:
   //     Add or create the following file :
   //     - C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.dia.ref
@@ -1470,349 +1006,67 @@ function msg = st_createthefile ( filename )
   msg(2) = "     - "+filename
 endfunction
 
-
-
-
-
-
-// =============================================================================
-// Pierre MARECHAL
-// Scilab team
-// Date : 31 août 2009
-//
-// module interface
-// =============================================================================
-
-// constructor
-// -----------------------------------------------------------------------------
-
-function md = module_new()
-
-    md = tlist([  "T_MODULE" ..
-                  "name" ..
-                  "path" ..
-                  "items" ] );
-
-endfunction
-
-// setters
-// -----------------------------------------------------------------------------
-
-function md = module_set_name(md,name)
-    md.name  = name;
-    if isempty( regexp(stripblanks(name),"/\|/") ) then
-        md.items = [ name ];
-    else
-        md.items = stripblanks( strsubst( strsplit(name,regexp(stripblanks(name),"/\|/")) , "/\|$/","","r" ) );
-    end
-endfunction
-
-function md = module_set_path(md,path)
-    md.path = path;
-endfunction
-
-// show
-// -----------------------------------------------------------------------------
-
-function module_show(module)
-        mprintf("Module :\n");
-        mprintf("  name           = %s\n"   ,module.name);
-        mprintf("  path           = %s\n"   ,module.path);
-        mprintf("  items          = %s\n"   ,module.items);
-        mprintf("\n");
-endfunction
-
-
-
-// =============================================================================
-// Pierre MARECHAL
-// Scilab team
-// Date : 31 août 2009
-//
-// directory interface
-// =============================================================================
-
-// constructor
-// -----------------------------------------------------------------------------
-
-function directory = directory_new()
-
-    directory = tlist([  "T_DIRECTORY" ..
-                  "path"         ..
-                  "module"       ..
-                  "type"         ..
-                  ]);
-
-endfunction
-
-// setters
-// -----------------------------------------------------------------------------
-
-function directory = directory_set_path(directory,path)
-    directory.path = path;
-endfunction
-
-function directory = directory_set_module(directory,module)
-    directory.module = module;
-endfunction
-
-function directory = directory_set_type(directory,dtype)
-    directory.type = dtype;
-endfunction
-
-
-// show
-// -----------------------------------------------------------------------------
-
-function directory_show(directory)
-    mprintf("Directory :\n");
-    mprintf("  path           = %s\n"   ,directory.path);
-    mprintf("  module         = %s\n"   ,directory.module.name);
-    mprintf("  type           = %s\n"   ,directory.type);
-    mprintf("\n");
-endfunction
-
-
-
-
-// =============================================================================
-// Pierre MARECHAL
-// Scilab team
-// Date : 31 août 2009
-//
-// testsuite interface
-// =============================================================================
-
-// constructor
-// -----------------------------------------------------------------------------
-
-function testsuite = testsuite_new()
-
-    testsuite = tlist([  "T_TESTSUITE" ..
-                 "items"           ..
-                 "current_mode"    ..    // NW, NWNI, GUI
-                 "wanted_mode"     ..    // NW, NWNI, GUI
-                 "reference"       ..    // check, create, skip
-                 "error_output"    ..    // check, skip
-                 "longtime"        ..    // enable, skip
-                 ]);
-
-    testsuite.items = list();
-
-    // Default values
-
-    if and(getscilabmode() <> ["NW";"STD"]) then
-        testsuite.current_mode = "NWNI";
-    else
-        testsuite.current_mode = "NW";
-    end
-
-    testsuite.wanted_mode  = "";
-    testsuite.reference    = "check";
-    testsuite.error_output = "check";
-    testsuite.longtime     = "skip";
-
-endfunction
-
-// Add tests
-// -----------------------------------------------------------------------------
-
-function testsuite = testsuite_add_tests(testsuite,tests)
-    testsuite.items = lstcat(testsuite.items,tests);
-endfunction
-
-function testsuite = testsuite_add_one_test(testsuite,test)
-    testsuite.items($+1) = test;
-endfunction
-
-// Number of tests
-// -----------------------------------------------------------------------------
-
-function l = testsuite_length(testsuite)
-    l = size(testsuite.items);
-endfunction
-
-// Setters
-// -----------------------------------------------------------------------------
-
-function testsuite = testsuite_set_WM(testsuite,wanted_mode)
-    testsuite.wanted_mode = wanted_mode;
-endfunction
-
-function testsuite = testsuite_set_reference(testsuite,reference)
-    testsuite.reference = reference;
-endfunction
-
-function testsuite = testsuite_set_EO(testsuite,error_output)
-    testsuite.error_output = error_output;
-endfunction
-
-// Enable/Disable Long Time Execution tests
-function testsuite = testsuite_set_LT(testsuite,lt)
-    testsuite.longtime = lt;
+// comparethefiles
+function msg = comparethefiles ( filename1 , filename2 )
+  // Returns a 3-by-1 matrix of strings, containing a message such as:
+  //     Compare the following files :
+  //     - C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.dia
+  //     - C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.dia.ref
+  // Workaround for bug #4827
+  msg(1) = "     Compare the following files :"
+  msg(2) = "     - "+filename1
+  msg(3) = "     - "+filename2
 endfunction
 
-// List tests
-// -----------------------------------------------------------------------------
+function directories = getDirectories(directory)
+    directories = directory;
+    items = gsort(listfiles(directory),"lr","i");
 
-function testsuite_list(testsuite)
-
-    for i=1:size(testsuite.items)
-        test = testsuite.items(i);
-        printf("   %03d - ",i);
-        printf("[%s] %s\n",test.module.name,test.name);
+    for i=1:size(items,"*")
+        if isdir(directory + items(i)) then
+            directories = [directories; getDirectories(directory + items(i) + filesep())];
+        end
     end
-
 endfunction
 
-// Launch tests
-// -----------------------------------------------------------------------------
-
-function testsuite_run(testsuite)
-
-    details_failed     = "";
-    test_count         = 0;
-    test_passed_count  = 0;
-    test_failed_count  = 0;
-    test_skipped_count = 0;
-
-    printf("   TMPDIR = %s\n",TMPDIR);
-    printf("\n");
-
-    start_date = getdate();
-    test_count = length(testsuite.items);
-
-    for i=1:test_count
-
-        test        = testsuite.items(i);
-        test_module = test.module.name;
-        test_name   = test.name;
-
-        // Improve the display of the module
-        if isdir(test_module) then
-            if part(test.module.name,1:length(SCI)) == SCI then
-                test_module = "SCI" + part(test_module,length(SCI)+1:length(test_module));
-            elseif part(test.module.name,1:length(SCIHOME)) == SCIHOME then
-                test_module = "SCIHOME" + part(test_module,length(SCIHOME)+1:length(test_module));
-            end
-        end
-
-        printf("   %03d/%03d - ",i,test_count);
-        printf("[%s] %s",test_module,test_name);
-        for j = length(test_name+test_module):50
-            printf(".");
-        end
-
-        test = st_run(test);
-
-        msg = sprintf(test.status.message);
-        printf("%s \n", msg(1));
-        for kline = 2:size(msg, "*")
-          printf(part(" ", 1:62) + "%s \n", msg(2));
-        end
-
-        // Recencement des tests
-
-        if test.status.id == 0 then
-            // passed
-            test_passed_count = test_passed_count + 1;
-
-        elseif (test.status.id > 0) & (test.status.id < 10) then
-            // failed
-            test_failed_count = test_failed_count + 1;
-            details_failed = [ details_failed ; sprintf("   TEST : [%s] %s",test.module.name,test.name)];
-            details_failed = [ details_failed ; sprintf("     %s",test.status.message) ];
-            details_failed = [ details_failed ; test.status.details ];
-            details_failed = [ details_failed ; "" ];
-
-        elseif (test.status.id >= 10) & (test.status.id < 20) then
-            // skipped
-            test_skipped_count = test_skipped_count + 1;
+function path = getPath(directory, ref_dir)
+    path = strsplit(directory, ["\","/"]);
+    path(path == "") = [];
+    for i = 1:size(ref_dir, "*")
+        if find(path == ref_dir(i)) then
+            path(1:find(path == ref_dir(i))) = [];
         end
     end
-
-    end_date = getdate();
-
-    // Summary
-
-    if test_count<>0 then
-        test_passed_percent  = test_passed_count  / test_count * 100;
-        test_skipped_percent = test_skipped_count / test_count * 100;
-        test_failed_percent  = test_failed_count  / test_count * 100;
-    else
-        test_passed_percent  = 0;
-        test_skipped_percent = 0;
-        test_failed_percent  = 0;
-    end
-
-    printf("\n");
-    printf("   --------------------------------------------------------------------------\n");
-    printf("   Summary\n\n");
-    printf("   tests                     %4d - 100 %% \n",test_count);
-    printf("   passed                    %4d - %3d %% \n",test_passed_count ,test_passed_percent);
-    printf("   failed                    %4d - %3d %% \n",test_failed_count ,test_failed_percent);
-    printf("   skipped                   %4d - %3d %% \n",test_skipped_count,test_skipped_percent);
-    printf("   length                          %4.2f sec \n" ,etime(end_date,start_date));
-    printf("   --------------------------------------------------------------------------\n");
-
-    if test_failed_count > 0 then
-        printf("   Details\n\n");
-        printf("%s\n",details_failed);
-        printf("\n");
-        printf("   --------------------------------------------------------------------------\n");
-    end
-
-endfunction
-
-
-// =============================================================================
-// Pierre MARECHAL
-// Scilab team
-// Date : 1 septembre 2009
-//
-// status
-// =============================================================================
-
-// constructor
-// -----------------------------------------------------------------------------
-
-function status = status_new()
-    status = tlist([  "T_STATUS" ..
-                "id"             ..
-                "message"        ..
-                "details"        ..
-                ]);
-
-    status.id      = 0;
-    status.message = "";
-    status.details = "";
-
-endfunction
-
-// setters
-// -----------------------------------------------------------------------------
-
-function status = status_set_id(status,id)
-    status.id = id;
 endfunction
 
-function status = status_set_message(status,smessage)
-    status.message = smessage;
-endfunction
-
-function status = status_set_details(status,details)
-    status.details = details;
+function name = splitModule(name)
+    if ~isempty( regexp(stripblanks(name),"/\|/") ) then
+        name = stripblanks( strsubst( strsplit(name,regexp(stripblanks(name),"/\|/")) , "/\|$/","","r" ) );
+    end
 endfunction
 
-// show
-// -----------------------------------------------------------------------------
-
-function status_show(status)
-    mprintf("Status :\n");
-    mprintf("  id             = %d\n"   ,status.id);
-    mprintf("  message        = %s\n"   ,status.message);
-    mprintf("  details        = %s\n"   ,status.details);
-    mprintf("\n");
+function example = test_examples()
+    example = [ sprintf("Examples :\n\n") ];
+    example = [ example ; sprintf("// Launch all tests\n") ];
+    example = [ example ; sprintf("test_run();\n") ];
+    example = [ example ; sprintf("test_run([]);\n") ];
+    example = [ example ; sprintf("test_run([],[]);\n") ];
+    example = [ example ; "" ];
+    example = [ example ; sprintf("// Test one or several module\n") ];
+    example = [ example ; sprintf("test_run(''core'');\n") ];
+    example = [ example ; sprintf("test_run(''core'',[]);\n") ];
+    example = [ example ; sprintf("test_run([''core'',''string'']);\n") ];
+    example = [ example ; "" ];
+    example = [ example ; sprintf("// Launch one or several test in a specified module\n") ];
+    example = [ example ; sprintf("test_run(''core'',[''trycatch'',''opcode'']);\n") ];
+    example = [ example ; "" ];
+    example = [ example ; sprintf("// With options\n") ];
+    example = [ example ; sprintf("test_run([],[],''no_check_ref'');\n") ];
+    example = [ example ; sprintf("test_run([],[],''no_check_error_output'');\n") ];
+    example = [ example ; sprintf("test_run([],[],''create_ref'');\n") ];
+    example = [ example ; sprintf("test_run([],[],''list'');\n") ];
+    example = [ example ; sprintf("test_run([],[],''help'');\n") ];
+    example = [ example ; sprintf("test_run([],[],[''no_check_ref'',''mode_nw'']);\n") ];
+    example = [ example ; "" ];
 endfunction
 
-