14
14
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:id="test_run" xml:lang="en">
16
<refname>test_run</refname>
17
<refpurpose>Launch tests</refpurpose>
20
<title>Calling Sequence</title>
23
status = test_run(module)
24
status = test_run(module, test_name)
25
status = test_run(module, test_name, options, exportToFile)
29
<title>Arguments</title>
34
<para>A String array. This input argument must be</para>
38
the name of an internal Scilab module ("core", "time", ...) or a sub-module (e.g. "optimization|neldermead").
43
the name of an ATOMS module ("module_lycee", "nisp", ...). To be taken into account, the module must be loaded when test_run() is called.
48
the absolute directory path of a module.
55
<term>test_name</term>
57
<para>A string array</para>
63
<para>A string array</para>
66
<term>no_check_ref</term>
68
<para>does not check if the .dia and .dia.ref are equal</para>
72
<term>no_check_error_output</term>
74
<para>The error output stream is not checked. This option can be used when Scilab complains about the localization being not available.</para>
78
<term>create_ref</term>
80
<para>create the .dia.ref file and does not check if the .dia and .dia.ref are equal</para>
84
<term>show_error</term>
86
<para>If an error occurs, show the last 10 lines of the execution</para>
90
<term>show_diff</term>
93
If a difference is found, show the result of the command <literal>diff -u</literal>
100
<para>Does not perform the tests but displays a list of available tests</para>
106
<para>display some examples about how to use this command</para>
112
<para>Add the "-nw" option to the launch</para>
116
<term>mode_nwni</term>
118
<para>Add the "-nwni" option to the launch</para>
122
<term>nonreg_test</term>
124
<para>runs only the non-regression tests, skipping unit tests</para>
128
<term>unit_test</term>
130
<para>Runs only the unit tests, skipping non-regression tests</para>
134
<term>skip_tests</term>
136
<para>Skip the tests</para>
140
<term>enable_lt</term>
142
<para>Enable long-time execution tests</para>
146
<term>short_summary</term>
148
<para>Does not display statistics nor execution time after execution (only number of executed, passed, failed and skipped tests will be displayed on a single line).</para>
155
<term>exportToFile</term>
158
Export to a XML file the result of the test. This file follows the specification of the XUnit format.
159
Note that the usage of this option enables <literal>show_diff</literal> and <literal>show_error</literal>.
162
If the file pointed by <varname>exportToFile</varname> already exists, the new result will be added to the existing file.
171
Returns %t if no error has been detected
172
Returns %f if any error has been detected
179
<title>Description</title>
181
Search for .tst files in the unit test and non-regression test library
182
execute them, and display a report about success of failures.
183
The .tst files are searched in directories SCI+"/modules/*/tests/unit_tests"
184
and SCI+"/modules/*/tests/nonreg_tests".
185
Whenever a test is executed, a .dia file is generated which contains
186
the full list of commands executed along with message which appears in the
187
console. When the script is done, the .dia file is compared with
188
the .dia.ref file which is expected to be in the same directory
189
as the .tst file. If the two file are different, the test fails.
192
Special tags may be inserted in the .tst file, which help to
193
control the processing of the corresponding test. These tags
194
are expected to be found in Scilab comments.
196
<para>These are the available tags:</para>
200
<-- INTERACTIVE TEST -->
201
This test will be skipped because it is interactive.
206
<-- LONG TIME EXECUTION -->
207
This test will be skipped because it needs long-time duration. To enable
208
the test, call test_run with the following option: "enable_lt"
213
<-- NOT FIXED -->
214
This test will be skipped because it is a known, but unfixed bug.
219
<-- TEST WITH GRAPHIC -->
220
This test will not be executed if the option "mode_nwni" is used.
225
<-- NO TRY CATCH -->
230
<-- NO CHECK ERROR OUTPUT -->
231
The error output file is not checked
236
<-- NO CHECK REF -->
237
The .dia and the .dia.ref files are not compared.
242
<-- ENGLISH IMPOSED -->
243
This test will be executed with the -l en_US option.
248
<-- FRENCH IMPOSED -->
249
This test will be executed with the -l fr_FR option.
254
<-- CLI SHELL MODE -->
255
(was: <-- JVM NOT MANDATORY -->)
256
This test will be executed with scilab-cli (nwni mode) by default.
261
<-- WINDOWS ONLY -->
262
If the operating system isn't Windows, the test is skipped.
267
<-- UNIX ONLY -->
268
If the operating system isn't an Unix OS, the test is skipped.
273
<-- LINUX ONLY -->
274
If the operating system isn't GNU/Linux, the test is skipped.
279
<-- MACOSX ONLY -->
280
If the operating system isn't Mac OS X, the test is skipped.
285
<-- XCOS TEST -->
286
This test will launch all the necessary Xcos libs. This test
287
will be launched in nw mode.
292
Each test is executed in a separated process, created with the "host" command.
293
That enables the current command to continue, even if the test as
294
created an unstable environment. It also enables the tests to be
295
independent from one another.
299
<title>Platform-specific tests</title>
301
It may happen that the output of a test depends on the platform on which it is
302
executed. In this case, the <literal>.ref</literal> file cannot be correct for
303
all platforms and unit tests may fail for some platform. In this case, we can
304
create a default <literal>.ref</literal> and create additionnal <literal>.ref</literal>
305
file for each platform.
308
The various platform-specific <literal>.ref</literal> files must have one of the following extensions.
313
<literal>.unix.dia.ref</literal> for Unix platform,
318
<literal>.linux.dia.ref</literal> for GNU/Linux platform,
323
<literal>.win.dia.ref</literal> for Windows platform,
328
<literal>.macosx.dia.ref</literal> for Mac OS X platform.
333
The algorithm is the following.
334
First, the <literal>.ref</literal> is considered. If this file does not exist,
335
the platform-specific <literal>.ref</literal> file is examined depending on the current platform.
340
on Windows platforms: <literal>.win.dia.ref</literal>,
345
on Max OS X platforms: <literal>.unix.dia.ref</literal>, <literal>.macosx.dia.ref</literal>,
350
on GNU/Linux platforms: <literal>.unix.dia.ref</literal>, <literal>.linux.dia.ref</literal>.
356
<title>Examples</title>
357
<programlisting role="example"><![CDATA[
16
<refname>test_run</refname>
17
<refpurpose>Launch tests</refpurpose>
20
<title>Calling Sequence</title>
23
status = test_run(module)
24
status = test_run(module, test_name)
25
status = test_run(module, test_name, options, exportToFile)
29
<title>Arguments</title>
34
<para>A String array. This input argument must be</para>
38
the name of an internal Scilab module ("core", "time", ...) or a sub-module (e.g. "optimization|neldermead").
43
the name of an ATOMS module ("module_lycee", "nisp", ...). To be taken into account, the module must be loaded when test_run() is called.
48
the absolute directory path of a module.
55
<term>test_name</term>
57
<para>A string array</para>
63
<para>A string array</para>
66
<term>no_check_ref</term>
68
<para>does not check if the .dia and .dia.ref are equal</para>
72
<term>no_check_error_output</term>
74
<para>The error output stream is not checked. This option can be used when Scilab complains about the localization being not available.</para>
78
<term>create_ref</term>
80
<para>create the .dia.ref file and does not check if the .dia and .dia.ref are equal</para>
84
<term>show_error</term>
86
<para>If an error occurs, show the last 10 lines of the execution</para>
90
<term>show_diff</term>
93
If a difference is found, show the result of the command <literal>diff -u</literal>
100
<para>Does not perform the tests but displays a list of available tests</para>
106
<para>display some examples about how to use this command</para>
112
<para>Add the "-nw" option to the launch</para>
116
<term>mode_nwni</term>
118
<para>Add the "-nwni" option to the launch</para>
122
<term>nonreg_test</term>
124
<para>runs only the non-regression tests, skipping unit tests</para>
128
<term>unit_test</term>
130
<para>Runs only the unit tests, skipping non-regression tests</para>
134
<term>skip_tests</term>
136
<para>Skip the tests</para>
140
<term>enable_lt</term>
142
<para>Enable long-time execution tests</para>
146
<term>short_summary</term>
148
<para>Does not display statistics nor execution time after execution (only number of executed, passed, failed and skipped tests will be displayed on a single line).</para>
155
<term>exportToFile</term>
158
Export to a XML file the result of the test. This file follows the specification of the XUnit format.
159
Note that the usage of this option enables <literal>show_diff</literal> and <literal>show_error</literal>.
162
If the file pointed by <varname>exportToFile</varname> already exists, the new result will be added to the existing file.
171
Returns %t if no error has been detected
172
Returns %f if any error has been detected
179
<title>Description</title>
181
Search for .tst files in the unit test and non-regression test library
182
execute them, and display a report about success of failures.
183
The .tst files are searched in directories SCI+"/modules/*/tests/unit_tests"
184
and SCI+"/modules/*/tests/nonreg_tests".
185
Whenever a test is executed, a .dia file is generated which contains
186
the full list of commands executed along with message which appears in the
187
console. When the script is done, the .dia file is compared with
188
the .dia.ref file which is expected to be in the same directory
189
as the .tst file. If the two file are different, the test fails.
192
Special tags may be inserted in the .tst file, which help to
193
control the processing of the corresponding test. These tags
194
are expected to be found in Scilab comments.
196
<para>These are the available tags:</para>
200
<-- INTERACTIVE TEST -->
201
This test will be skipped because it is interactive.
206
<-- LONG TIME EXECUTION -->
207
This test will be skipped because it needs long-time duration. To enable
208
the test, call test_run with the following option: "enable_lt"
213
<-- NOT FIXED -->
214
This test will be skipped because it is a known, but unfixed bug.
219
<-- TEST WITH GRAPHIC -->
220
This test will not be executed if the option "mode_nwni" is used.
225
<-- NO TRY CATCH -->
230
<-- NO CHECK ERROR OUTPUT -->
231
The error output file is not checked
236
<-- NO CHECK REF -->
237
The .dia and the .dia.ref files are not compared.
242
<-- ENGLISH IMPOSED -->
243
This test will be executed with the -l en_US option.
248
<-- FRENCH IMPOSED -->
249
This test will be executed with the -l fr_FR option.
254
<-- CLI SHELL MODE -->
255
(was: <-- JVM NOT MANDATORY -->)
256
This test will be executed with scilab-cli (nwni mode) by default.
261
<-- WINDOWS ONLY -->
262
If the operating system isn't Windows, the test is skipped.
267
<-- UNIX ONLY -->
268
If the operating system isn't an Unix OS, the test is skipped.
273
<-- LINUX ONLY -->
274
If the operating system isn't GNU/Linux, the test is skipped.
279
<-- MACOSX ONLY -->
280
If the operating system isn't Mac OS X, the test is skipped.
285
<-- XCOS TEST -->
286
This test will launch all the necessary Xcos libs. This test
287
will be launched in nw mode.
292
Each test is executed in a separated process, created with the "host" command.
293
That enables the current command to continue, even if the test as
294
created an unstable environment. It also enables the tests to be
295
independent from one another.
299
<title>Platform-specific tests</title>
301
It may happen that the output of a test depends on the platform on which it is
302
executed. In this case, the <literal>.ref</literal> file cannot be correct for
303
all platforms and unit tests may fail for some platform. In this case, we can
304
create a default <literal>.ref</literal> and create additionnal <literal>.ref</literal>
305
file for each platform.
308
The various platform-specific <literal>.ref</literal> files must have one of the following extensions.
313
<literal>.unix.dia.ref</literal> for Unix platform,
318
<literal>.linux.dia.ref</literal> for GNU/Linux platform,
323
<literal>.win.dia.ref</literal> for Windows platform,
328
<literal>.macosx.dia.ref</literal> for Mac OS X platform.
333
The algorithm is the following.
334
First, the <literal>.ref</literal> is considered. If this file does not exist,
335
the platform-specific <literal>.ref</literal> file is examined depending on the current platform.
340
on Windows platforms: <literal>.win.dia.ref</literal>,
345
on Max OS X platforms: <literal>.unix.dia.ref</literal>, <literal>.macosx.dia.ref</literal>,
350
on GNU/Linux platforms: <literal>.unix.dia.ref</literal>, <literal>.linux.dia.ref</literal>.
356
<title>Examples</title>
357
<programlisting role="example"><![CDATA[
358
358
// Launch all tests
359
359
// =============================================
418
418
// Combine several options
419
419
test_run([],[],['no_check_ref','mode_nw']);
420
420
]]></programlisting>
422
<programlisting role="example"><![CDATA[
422
<programlisting role="example"><![CDATA[
423
423
// Run unitary tests of an external module (with his path)
424
424
test_run('SCI/contrib/toolbox_skeleton')
425
425
]]></programlisting>
427
<programlisting role="example"><![CDATA[
427
<programlisting role="example"><![CDATA[
428
428
// Export to a XML Xunit file
429
429
test_run('boolean',[],[],TMPDIR+"/boolean_test_run.xml");
430
430
test_run('time','datenum',[],TMPDIR+"/time_datenum_test_run.xml");
431
431
]]></programlisting>
434
<title>Internal Design</title>
436
The tests are performed in the temporary directory, not in the directory
437
which originaly contain the tests files.
438
The .tst file is copied into the temporary directory, the test is performed
439
and the .dia.ref is copied back into the original location.
442
The .tst script is not run as is. Instead, a header and a footer are
443
inserted at the beginning and at the end of the .tst at the time
444
the script is copied into the temporary directory.
445
The role of this modification is to redirect the output messages
446
into the .dia file, so that the user can have a log file once the test
451
<title>History</title>
454
<revnumber>5.4.0</revnumber>
455
<revdescription>test_run returns a status:
456
<itemizedlist><listitem>
457
Returns %t if no error has been detected
460
Returns %f if any error has been detected
464
<literal>show_diff</literal> and <literal>show_error</literal> added as new options
467
<literal>CLI SHELL MODE</literal> tag is added. Replaces <literal>JVM NOT MANDATORY</literal> (still supported)
470
<literal>test_run</literal> can work on an external module.
474
Fourth argument added to export to a XML file
434
<title>Internal Design</title>
436
The tests are performed in the temporary directory, not in the directory
437
which originaly contain the tests files.
438
The .tst file is copied into the temporary directory, the test is performed
439
and the .dia.ref is copied back into the original location.
442
The .tst script is not run as is. Instead, a header and a footer are
443
inserted at the beginning and at the end of the .tst at the time
444
the script is copied into the temporary directory.
445
The role of this modification is to redirect the output messages
446
into the .dia file, so that the user can have a log file once the test
451
<title>History</title>
454
<revnumber>5.4.0</revnumber>
455
<revdescription>test_run returns a status:
456
<itemizedlist><listitem>
457
Returns %t if no error has been detected
460
Returns %f if any error has been detected
464
<literal>show_diff</literal> and <literal>show_error</literal> added as new options
467
<literal>CLI SHELL MODE</literal> tag is added. Replaces <literal>JVM NOT MANDATORY</literal> (still supported)
470
<literal>test_run</literal> can work on an external module.
474
Fourth argument added to export to a XML file