Fix the scilab binary path for "make install" versions
[scilab.git] / scilab / modules / development_tools / macros / unit_test_run.sci
1 //-----------------------------------------------------------------------------
2 // Pierre MARECHAL
3 // Scilab team
4 // Copyright INRIA
5 // Date : 25/10/2007
6 //
7 // Launch unitary tests
8 //-----------------------------------------------------------------------------
9
10 function unit_test_run(varargin)
11         
12         lhs = argn(1);
13         rhs = argn(2);
14         
15         global test_list;
16         global test_count;
17         global displayed_txt;
18         
19         // options
20         
21         global check_ref;
22         global check_error_output;
23         global create_ref;
24         global launch_mode;
25
26         
27         check_ref          = %T;
28         check_error_output = %T;
29         create_ref         = %F;
30         launch_mode        = "-nw";
31         just_list_tests    = %F;
32         print_help         = %F;
33         
34         test_count         = 0;
35         test_passed_count  = 0;
36         test_failed_count  = 0;
37         test_skipped_count = 0;
38         
39         displayed_txt      = '';
40         details_failed     = '';
41         
42         // =======================================================
43         // Gestion des tests à lancer
44         // =======================================================
45         
46         if (rhs == 0) ..
47                                 | ((rhs == 1) & (varargin(1)==[])) ..
48                                 | (((rhs == 2)|(rhs == 3)) & (varargin(1)==[]) & (varargin(2)==[])) then
49                 
50                 // No input argument
51                 // unit_test_run()
52                 // unit_test_run([])
53                 // => Launch each test of each module
54                 
55                 module_list = getmodules();
56                 for k=1:size(module_list,'*')
57                         unit_test_add_module(module_list(k));
58                 end
59         
60         elseif (rhs == 1) ..
61                                 | ((rhs == 2) & (varargin(2)==[])) ..
62                                 | ((rhs == 3) & (varargin(2)==[])) then
63                 
64                 // One input argument
65                 // unit_test_run(<module_name>)
66                 // unit_test_run([<module_name_1>,<module_name_2>])
67                 
68                 // varargin(1) = [<module_name_1>,<module_name_2>]
69                 
70                 module_mat = varargin(1);
71                 
72                 [nl,nc] = size(module_mat);
73                 
74                 // unit_test_run([<module_name_1>,<module_name_2>])
75                 
76                 for i=1:nl
77                         for j=1:nc
78                                 if( with_module(module_mat(i,j)) ) then
79                                         unit_test_add_module(module_mat(i,j));
80                                 else
81                                         error(sprintf(gettext("%s is not an installed module"),module_mat(i,j)));
82                                 end
83                         end
84                 end
85                 
86         elseif (rhs == 2) | (rhs == 3) then
87                 
88                 // Two input arguments
89                 // unit_test_run(<module_name>,<test_name>)
90                 // unit_test_run(<module_name>,[<test_name_1>,<test_name_2>] )
91                 
92                 // varargin(1) = <module_name> ==> string 1x1
93                 // varargin(2) = <test_name_1> ==> mat nl x nc
94                 
95                 module   = varargin(1);
96                 test_mat = varargin(2);
97                 
98                 if ((or(size(module) <> [1,1])) & (test_mat <> [])) then
99                         example = unit_test_examples();
100                         err     = ["" ; gettext("error : Input argument sizes are not valid") ; "" ; example ];
101                         printf("%s\n",err);
102                         return;
103                 end
104                 
105                 [nl,nc] = size(test_mat);
106                 
107                 for i=1:nl
108                         for j=1:nc
109                                 if( fileinfo(SCI+"/modules/"+module+"/unit_tests/"+test_mat(i,j)+".tst") <> [] ) then
110                                         unit_test_add_onetest(module,test_mat(i,j));
111                                 else
112                                         error(sprintf(gettext("The test ""%s"" is not available from the ""%s"" module"),test_mat(i,j),module));
113                                 end
114                         end
115                 end
116         else
117                 error(gettext('Number of parameters incorrect.'));
118         end
119         
120         // =======================================================
121         // Gestion des options
122         // =======================================================
123         
124         if rhs == 3 then
125                 
126                 option_mat =  varargin(3);
127                 
128                 if grep(option_mat,"no_check_ref") <> [] then
129                         check_ref  = %F;
130                 end
131                 
132                 if grep(option_mat,"no_check_error_output") <> [] then
133                         check_error_output  = %F;
134                 end
135                 
136                 if grep(option_mat,"create_ref") <> [] then
137                         create_ref = %T;
138                         check_ref  = %F;
139                 end
140                 
141                 if grep(option_mat,"mode_nw") <> [] then
142                         launch_mode = "-nw";
143                 end
144                 
145                 if grep(option_mat,"mode_nwni") <> [] then
146                         launch_mode = "-nwni";
147                 end
148                 
149                 if grep(option_mat,"list") <> [] then
150                         just_list_tests    = %T;
151                 end
152                 
153                 if grep(option_mat,"help") <> [] then
154                         print_help         = %T;
155                 end
156         end
157
158         if print_help then
159                 
160                 example = unit_test_examples();
161                 printf("%s\n",example);
162                 return;
163         
164         elseif just_list_tests then
165                 
166                 // =======================================================
167                 // Just list tests
168                 // =======================================================
169                 
170                 for i=1:test_count
171                         printf("   %02d - ",i);
172                         printf("[%s] %s\n",test_list(i,1),test_list(i,2));
173                 end
174                 
175         else
176                 
177                 // =======================================================
178                 // Test launch
179                 // =======================================================
180                 
181                 printf("   TMPDIR = %s\n",TMPDIR);
182                 printf("\n");
183                 
184                 for i=1:test_count
185                         
186                         printf("   %02d/%02d - ",i,test_count);
187                         printf("[%s] %s",test_list(i,1),test_list(i,2));
188                         for j = length(test_list(i,2) + test_list(i,1)):50
189                                 printf(".");
190                         end
191                         
192                         [status_id,status_msg,status_details] = unit_test_run_onetest(test_list(i,1),test_list(i,2));
193                         printf("%s \n",status_msg);
194                         
195                         // Recencement des tests
196                         
197                         if status_id == 0 then
198                                 // passed
199                                 test_passed_count = test_passed_count + 1;
200                         
201                         elseif (status_id > 0) & (status_id < 10) then
202                                 // failed
203                                 test_failed_count = test_failed_count + 1;
204                                 details_failed = [ details_failed ; sprintf("   TEST : [%s] %s",test_list(i,1),test_list(i,2))];
205                                 details_failed = [ details_failed ; sprintf("     %s",status_msg) ];
206                                 details_failed = [ details_failed ; status_details ];
207                                 details_failed = [ details_failed ; "" ];
208                         
209                         elseif (status_id > 10) & (status_id < 20) then
210                                 // skipped
211                                 test_skipped_count = test_skipped_count + 1;
212                         end
213                 end
214                 
215                 // Summary
216                 
217                 test_passed_percent  = test_passed_count  / test_count * 100;
218                 test_skipped_percent = test_skipped_count / test_count * 100;
219                 test_failed_percent  = test_failed_count  / test_count * 100;
220                 
221                 printf("\n");
222                 printf("   ---------------------------------------------------------------------------------------\n");
223                 printf("   Summary\n\n");
224                 printf("   tests                     %4d - 100 %% \n",test_count);
225                 printf("   passed                    %4d - %3d %% \n",test_passed_count ,test_passed_percent);
226                 printf("   failed                    %4d - %3d %% \n",test_failed_count ,test_failed_percent);
227                 printf("   skipped                   %4d - %3d %% \n",test_skipped_count,test_skipped_percent);
228                 printf("   ---------------------------------------------------------------------------------------\n");
229                 
230                 if test_failed_count > 0 then
231                         printf("   Details\n\n");
232                         printf("%s\n",details_failed);
233                         printf("\n");
234                         printf("   ---------------------------------------------------------------------------------------\n");
235                 end
236                 
237         end
238         
239 endfunction
240
241 //-----------------------------------------------------------------------------
242 // Pierre MARECHAL
243 // Scilab team
244 // Copyright INRIA
245 // Date : 28 oct. 2007
246 //
247 // => List all test files in the module <module_mat>
248 // => Add them to the test_mat matrix
249 //-----------------------------------------------------------------------------
250
251 function unit_test_add_module(module_mat)
252         
253         module_test_dir = SCI+"/modules/"+module_mat+"/unit_tests";
254         test_mat        = basename(listfiles(module_test_dir+"/*.tst"));
255         
256         nl = size(test_mat,"*");
257         for i=1:nl
258                 unit_test_add_onetest(module_mat,test_mat(i));
259         end
260         
261 endfunction
262
263 //-----------------------------------------------------------------------------
264 // Pierre MARECHAL
265 // Scilab team
266 // Copyright INRIA
267 // Date : 28 oct. 2007
268 //
269 // => Add the test <test> to the test_mat matrix
270 //-----------------------------------------------------------------------------
271
272 function unit_test_add_onetest(module,test)
273         
274         global test_list;
275         global test_count;
276         
277         test_count = test_count + 1;
278         test_list( test_count , 1 ) = module;
279         test_list( test_count , 2 ) = test;
280         
281 endfunction
282
283 //-----------------------------------------------------------------------------
284 // Pierre MARECHAL
285 // Scilab team
286 // Copyright INRIA
287 // Date : 28 oct. 2007
288 //
289 // => Run one test
290 //-----------------------------------------------------------------------------
291
292 function [status_id,status_msg,status_details] = unit_test_run_onetest(module,test)
293         
294         global check_ref;
295         global create_ref;
296         
297         status_id      = 0 ;
298         status_msg     = "passed" ;
299         status_details = "";
300         
301         [status_id,status_msg,status_details] = unit_test_run_checkerror(module,test);
302         
303         if check_ref | create_ref then
304                 // Check ref or create ref
305                 if status_id == 0 then
306                         [status_id,status_msg,status_details] = unit_test_run_proc_ref(module,test);
307                 end
308         end
309         
310         return;
311         
312 endfunction
313
314 //-----------------------------------------------------------------------------
315 // Pierre MARECHAL
316 // Scilab team
317 // Copyright INRIA
318 // Date : 8 novembre 2007
319 //
320 // => Check the test
321 //-----------------------------------------------------------------------------
322
323 function [status_id,status_msg,status_details] = unit_test_run_checkerror(module,test)
324         
325         status_id      = 0 ;
326         status_msg     = "passed" ;
327         status_details = "";
328         
329         global launch_mode;
330         global check_error_output;
331         
332         // Some definitions
333         
334         tstfile     = pathconvert(SCI+"/modules/"+module+"/unit_tests/"+test+".tst",%f,%f);
335         
336         tmp_tstfile = pathconvert(TMPDIR+"/"+test+"_1.tst",%f,%f);
337         tmp_diafile = pathconvert(TMPDIR+"/"+test+"_1.dia",%f,%f);
338         tmp_resfile = pathconvert(TMPDIR+"/"+test+"_1.res",%f,%f);
339         tmp_errfile = pathconvert(TMPDIR+"/"+test+"_1.err",%f,%f);
340         
341         // Remove the previous tmp files
342         if fileinfo(tmp_tstfile) <> [] then
343                 deletefile(tmp_tstfile)
344         end
345         
346         if fileinfo(tmp_diafile) <> [] then
347                 deletefile(tmp_diafile)
348         end
349         
350         if fileinfo(tmp_resfile) <> [] then
351                 deletefile(tmp_resfile)
352         end
353         
354         if fileinfo(tmp_errfile) <> [] then
355                 deletefile(tmp_errfile)
356         end
357         
358         //Reset standard globals
359         rand('seed',0);
360         rand('uniform');
361         
362         // Get the tst file
363         txt = mgetl(tstfile);
364         
365         // Check if it's an interactive test
366         if grep(txt,"<-- INTERACTIVE TEST -->") <> [] then
367                 status_msg = "skipped : interactive test";
368                 status_id  = 10;
369                 return;
370         end
371         
372         if (grep(txt,"<-- TEST WITH GRAPHIC -->") <> []) & (launch_mode=="-nwni") then
373                 status_msg = "skipped : test with graphic";
374                 status_id  = 11;
375                 return;
376         end
377         
378         // Do some modification in tst file
379         txt = strsubst(txt,'pause,end','bugmes();quit;end');
380         txt = strsubst(txt,'-->','@#>'); //to avoid suppression of input --> with prompts
381         txt = strsubst(txt,'halt();','');
382         
383         // Header : the same for each test
384         
385         head = [        "// <-- HEADER START -->";
386                                 "mode(3);" ;
387                                 "clear;" ;
388                                 "lines(28,72);";
389                                 "lines(0);" ;
390                                 "deff(''[]=bugmes()'',''write(%io(2),''''error on test'''')'');" ;
391                                 "predef(''all'');" ;
392                                 "try";
393                                 "diary(''"+tmp_diafile+"'');";
394                                 "// <-- HEADER END -->"];
395                                 
396         tail = [        "// <-- FOOTER START -->";
397                                 "catch";
398                                 "       errmsg = ""<--""+""Error on the test script file""+""-->""";
399                                 "       printf(""%s"",errmsg)";
400                                 "end";
401                                 "diary(0);";
402                                 "exit;";
403                                 "// <-- FOOTER END -->"]
404         
405         txt = [head;
406                 txt;
407                 tail];
408         
409         // and save it in a temporary file
410         mputl(txt,tmp_tstfile);
411         
412         // Gestion de l'emplacement de bin/scilab
413         if (~MSDOS) & (fileinfo(SCI+"/bin/scilab")==[]) then
414                 SCI_BIN = strsubst(SCI,'share/scilab','');
415         else
416                 SCI_BIN = SCI;
417         end
418         
419         // Build the command to launch
420         if MSDOS then
421                 unit_test_cmd = "( """+SCI_BIN+"\bin\scilex.exe"+""""+" "+launch_mode+" -nb -args -nouserstartup -f """+tmp_tstfile+""" > """+tmp_resfile+""" ) 2> """+tmp_errfile+"""";
422         else
423                 unit_test_cmd = "( "+SCI_BIN+"/bin/scilab "+launch_mode+" -nb -args -nouserstartup -f "+tmp_tstfile+" > "+tmp_resfile+" ) 2> "+tmp_errfile;
424         end
425         
426         // Launch the test exec
427         host(unit_test_cmd);
428         
429         // First Check : error output
430         if check_error_output then
431                 tmp_errfile_info = fileinfo(tmp_errfile);
432                 
433                 if ( (tmp_errfile_info <> []) & (tmp_errfile_info(1)<>0) ) then
434                         status_msg = "failed  : error_output not empty"
435                         status_details = sprintf("     Check the following file : \n     - %s",tmp_errfile);
436                         status_id  = 5;
437                         return;
438                 end
439         end
440         
441         //  Do some modification in  dia file
442         dia = mgetl(tmp_diafile);
443         
444         //Check for execution errors
445         if grep(dia,"<--Error on the test scmodules/time/unit_tests/datenum.tstript file-->")<>[] then
446                 status_msg = "failed  : premature end of the test script";
447                 status_details = sprintf("     Check the following file : \n     - %s",tmp_diafile);
448                 status_details = [ status_details ; sprintf("     Or launch the following command : \n     - exec %s;",tstfile) ];
449                 status_id = 3;
450                 return;
451         end
452         
453         // Remove Header and Footer
454         dia = remove_headers(dia);
455         
456         //Check for execution errors
457         
458         if grep(dia,"!--error")<>[] then
459                 status_msg     = "failed  : the string (!--error) has been detected";
460                 status_details = sprintf("     Check the following file : \n     - %s",tmp_diafile);
461                 status_details = [ status_details ; sprintf("     Or launch the following command : \n     - exec %s;",tstfile) ];
462                 status_id  = 1;
463                 return;
464         end
465         
466         if grep(dia,"error on test")<>[] then
467                 status_msg     = "failed  : one or several unit tests failed";
468                 status_details = sprintf("     Check the following file : \n     - %s",tmp_diafile);
469                 status_details = [ status_details ; sprintf("     Or launch the following command : \n     - exec %s;",tstfile) ];
470                 status_id      = 2;
471                 return;
472         end
473         
474         return;
475         
476 endfunction
477
478 //-----------------------------------------------------------------------------
479 // Pierre MARECHAL
480 // Scilab team
481 // Copyright INRIA
482 // Date : 28 oct. 2007
483 //
484 // => Check ref or generate ref
485 //-----------------------------------------------------------------------------
486
487 function [status_id,status_msg,status_details] = unit_test_run_proc_ref(module,test)
488         
489         global create_ref;
490         global check_ref;
491         
492         status_id      = 0 ;
493         status_msg     = "passed" ;
494         status_details = "";
495         
496         // Some definitions
497         
498         tstfile     = pathconvert(SCI+"/modules/"+module+"/unit_tests/"+test+".tst",%f,%f);
499         diafile     = pathconvert(SCI+"/modules/"+module+"/unit_tests/"+test+".dia",%f,%f);
500         reffile     = pathconvert(SCI+"/modules/"+module+"/unit_tests/"+test+".dia.ref",%f,%f);
501         
502         tmp_tstfile = pathconvert(TMPDIR+"/"+test+"_2.tst",%f,%f);
503         tmp_diafile = pathconvert(TMPDIR+"/"+test+"_2.dia",%f,%f);
504         tmp_resfile = pathconvert(TMPDIR+"/"+test+"_2.res",%f,%f);
505         tmp_errfile = pathconvert(TMPDIR+"/"+test+"_2.err",%f,%f);
506         
507         // On test l'existence de la ref si besoin
508         
509         if check_ref then
510                 if fileinfo(reffile) == [] then
511                         status_msg     = "failed  : the ref file doesn''t exist";
512                         status_details = "     Add or create the following file"+reffile+" file";
513                         status_details = sprintf("     Add or create the following file : \n     - %s",reffile);
514                         status_id      = 5;
515                         return;
516                 end
517         end
518         
519         // Remove the previous tmp files
520         if fileinfo(tmp_tstfile) <> [] then
521                 deletefile(tmp_tstfile)
522         end
523         
524         if fileinfo(tmp_diafile) <> [] then
525                 deletefile(tmp_diafile)
526         end
527         
528         if fileinfo(tmp_resfile) <> [] then
529                 deletefile(tmp_resfile)
530         end
531         
532         if fileinfo(tmp_errfile) <> [] then
533                 deletefile(tmp_errfile)
534         end
535         
536         //Reset standard globals
537         rand('seed',0);
538         rand('uniform');
539
540         // Do some modification in  tst file
541         
542         txt = mgetl(tstfile);
543         txt = strsubst(txt,'pause,end','bugmes();quit;end');
544         txt = strsubst(txt,'-->','@#>'); //to avoid suppression of input --> with prompts
545         txt = strsubst(txt,'halt()','');
546         
547         // Header : the same for each test
548         
549         head = [        "// <-- HEADER START -->";
550                                 "mode(3);" ;
551                                 "clear;" ;
552                                 "lines(28,72);";
553                                 "lines(0);" ;
554                                 "deff(''[]=bugmes()'',''write(%io(2),''''error on test'''')'');" ;
555                                 "predef(''all'');" ;
556                                 "tmpdirToPrint = msprintf(''TMPDIR1=''''%s''''\n'',TMPDIR);" ;
557                                 "diary(''"+tmp_diafile+"'');";
558                                 "write(%io(2),tmpdirToPrint);";
559                                 "// <-- HEADER END -->"];
560                                 
561         tail = [        "// <-- FOOTER START -->";
562                                 "diary(0);";
563                                 "exit;";
564                                 "// <-- FOOTER END -->"]
565         
566         txt = [head;
567                 txt;
568                 tail];
569         
570         // and save it in a temporary file
571         mputl(txt,tmp_tstfile);
572         
573         // Delete previous dia file
574         if fileinfo(diafile) <> [] then
575                 deletefile(diafile)
576         end
577         
578         // Gestion de l'emplacement de bin/scilab
579         if (~MSDOS) & (fileinfo(SCI+"/bin/scilab")==[]) then
580                 SCI_BIN = strsubst(SCI,'share/scilab','');
581         else
582                 SCI_BIN = SCI;
583         end
584         
585         // Build the command to launch
586         if MSDOS then
587                 unit_test_cmd = "( """+SCI_BIN+"\bin\scilex.exe"+""""+" "+launch_mode+" -nb -args -nouserstartup -f """+tmp_tstfile+""" > """+tmp_resfile+""" ) 2> """+tmp_errfile+"""";
588         else
589                 unit_test_cmd = "( "+SCI_BIN+"/bin/scilab "+launch_mode+" -nb -args -nouserstartup -f "+tmp_tstfile+" > "+tmp_resfile+" ) 2> "+tmp_errfile;
590         end
591         
592         // Launch the test exec
593         host(unit_test_cmd);
594         
595         // First Check : error output
596         if check_error_output then
597                 tmp_errfile_info = fileinfo(tmp_errfile);
598                 
599                 if ( (tmp_errfile_info <> []) & (tmp_errfile_info(1)<>0) ) then
600                         status_msg = "failed  : error_output not empty"
601                         status_details = sprintf("     Check the following file : \n     - %s",tmp_errfile);
602                         status_id  = 5;
603                         return;
604                 end
605         end
606         
607         //  Do some modification in  dia file
608         dia = mgetl(tmp_diafile);
609         
610         // To get TMPDIR line
611         tmpdir1_line = grep(dia,"TMPDIR1");
612         execstr(dia(tmpdir1_line));
613         
614         // Remove Header and Footer
615         dia = remove_headers(dia);
616         
617         //  Do some modification in  dia file
618         dia(grep(dia,"exec("))                     = [];
619         dia(grep(dia,"write(%io(2),tmpdirToPrint"))= [];
620         dia(grep(dia,"TMPDIR1"))                   = [];
621         dia(grep(dia,"diary(0)"))                  = [];
622         
623         dia = strsubst(dia,TMPDIR,'TMPDIR');
624         dia = strsubst(dia,TMPDIR1,'TMPDIR');
625         dia = strsubst(dia,TMPDIR1,'TMPDIR');
626         dia = strsubst(dia,SCI,'SCI');
627         
628         //suppress the prompts
629         dia = strsubst(dia,'-->','');
630         dia = strsubst(dia,'@#>','-->');
631         dia = strsubst(dia,'-1->','');
632         
633         //standardise  number display
634         dia = strsubst(strsubst(strsubst(strsubst(dia,' .','0.'),'E+','D+'),'E-','D-'),'-.','-0.');
635
636         //not to change the ref files
637         dia=strsubst(dia,'bugmes();return','bugmes();quit');
638
639         if create_ref then
640                 
641                 // Delete previous .dia.ref file
642                 if fileinfo(reffile) <> [] then
643                         deletefile(reffile)
644                 end
645                 
646                 mputl(dia,reffile);
647                 
648                 status_msg = "passed : ref created";
649                 status_id  = 20;
650                 
651                 return;
652                 
653         else
654                 
655                 // write down the resulting dia file
656                 mputl(dia,diafile)
657                 
658                 //Check for diff with the .ref file
659                 
660                 [u,ierr] = mopen(reffile,'r');
661                 if ierr== 0 then //ref file exists
662                         
663                         ref=mgetl(u);
664                         mclose(u)
665                         
666                         // suppress blank (diff -nw)
667                         
668                         dia = strsubst(dia,' ','')
669                         ref = strsubst(ref,' ','')
670                         
671                         dia(find(dia=='')) = [];
672                         ref(find(ref=='')) = [];
673                         
674                         dia(find(dia=='')) = [];
675                         ref(find(ref=='')) = [];
676                         
677                         if or(ref<>dia) then
678                                 if MSDOS then
679                                         status_msg     = "failed  : dia and ref are not equal";
680                                         status_details = sprintf("     Compare the following files : \n     - %s\n     - %s",diafile,reffile);
681                                         status_id      = 4;
682                                 else
683                                         status_msg     = "failed  : dia and ref are not equal";
684                                         status_details = sprintf("     Compare the following files : \n     - %s\n     - %s",diafile,reffile);
685                                         status_id      = 4;
686                                 end
687                         end
688                 else
689                         error(sprintf(gettext("The ref file (%s) doesn''t exist"),reffile));
690                 end
691         end
692         
693         return;
694         
695 endfunction
696
697 //-----------------------------------------------------------------------------
698 // Pierre MARECHAL
699 // Scilab team
700 // Copyright INRIA
701 // Date : 8 novembre 2007
702 //
703 // => remove header from the diary txt
704 //
705 //-----------------------------------------------------------------------------
706
707 function dia_out = remove_headers(dia_in)
708         
709         dia_out = dia_in;
710         
711         body_start = grep(dia_out,"// <-- HEADER END -->");
712         
713         if body_start<>[] then
714                 dia_out(1:body_start(1)) = [];
715         end
716         
717         body_end   = grep(dia_out,"// <-- FOOTER START -->");
718         
719         if body_end<>[] then
720                 [dia_nl,dia_nc] = size(dia);
721                 dia_out(body_end(1):dia_nl) = [];
722         end
723         
724         return;
725         
726 endfunction
727
728 //-----------------------------------------------------------------------------
729 // Pierre MARECHAL
730 // Scilab team
731 // Copyright INRIA
732 // Date : 28 oct. 2007
733 //
734 // => Check ref or generate ref
735 //-----------------------------------------------------------------------------
736
737 function example = unit_test_examples()
738         
739         example = [ sprintf("Examples :\n\n") ];
740
741         
742         example = [ example ; sprintf("// Launch all tests\n") ];
743         example = [ example ; sprintf("unit_test_run();\n") ];
744         example = [ example ; sprintf("unit_test_run([]);\n") ];
745         example = [ example ; sprintf("unit_test_run([],[]);\n") ];
746         example = [ example ; "" ];
747         example = [ example ; sprintf("// Test one or several module\n") ];
748         example = [ example ; sprintf("unit_test_run(''core'');\n") ];
749         example = [ example ; sprintf("unit_test_run(''core'',[]);\n") ];
750         example = [ example ; sprintf("unit_test_run([''core'',''string'']);\n") ];
751         example = [ example ; "" ];
752         example = [ example ; sprintf("// Launch one or several test in a specified module\n") ];
753         example = [ example ; sprintf("unit_test_run(''core'',[''trycatch'',''opcode'']);\n") ];
754         example = [ example ; "" ];
755         example = [ example ; sprintf("// With options\n") ];
756         example = [ example ; sprintf("unit_test_run([],[],''no_check_ref'');\n") ];
757         example = [ example ; sprintf("unit_test_run([],[],''no_check_error_output'');\n") ];
758         example = [ example ; sprintf("unit_test_run([],[],''create_ref'');\n") ];
759         example = [ example ; sprintf("unit_test_run([],[],''list'');\n") ];
760         example = [ example ; sprintf("unit_test_run([],[],''help'');\n") ];
761         example = [ example ; sprintf("unit_test_run([],[],[''no_check_ref'',''mode_nw'']);\n") ];
762         example = [ example ; "" ];
763         
764 endfunction