core/builtins/ciftest.cif
author Tom Sutcliffe <thomas.sutcliffe@accenture.com>
Wed, 15 Sep 2010 00:44:34 +0100
changeset 70 b06038904ef8
child 75 3c3961c1ae26
permissions -rw-r--r--
Added ==smoke-test support and ciftest command. Commands can now define a "==smoke-test" section in their CIF files, which defines a snippet of fshell script that will be run as part of "fshell smoketest" or by invoking ciftest directly. See the ciftest documentation for more details. Added ==smoke-test sections to a few commands, the ones that were easy to test!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
70
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     1
# ciftest.cif
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     2
# 
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     3
# Copyright (c) 2010 Accenture. All rights reserved.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     5
# under the terms of the "Eclipse Public License v1.0"
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     8
# 
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     9
# Initial Contributors:
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    10
# Accenture - Initial contribution
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    11
#
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    12
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    13
==name ciftest
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    14
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    15
==short-description
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    16
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    17
Run fshell command smoke tests.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    18
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    19
==long-description
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    20
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    21
This command runs smoke-tests for any or all commands that define a C<==smoke-test> section in their CIF file. A C<==smoke-test> section defines a short snippet of fshell script which tests the basic functionality offered by the command. It can be as simple as running the command with no arguments to make sure nothing catastrophic is wrong, or it can be a more in-depth test of all the command's functionality, or anything in between.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    22
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    23
Example CIF file that supports ciftest:
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    24
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    25
    ==name mycmd
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    26
    
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    27
    [...]
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    28
    
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    29
    ==smoke-test
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    30
    
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    31
    mycmd | export -s RESULT
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    32
    var RESULT == "Expected results of running mycmd" || $Error
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    33
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    34
The following environment variables are defined for convenience when ciftest runs a smoke-test section:
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    35
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    36
=over 5
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    37
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    38
=item * Error
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    39
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    40
Expands to a string that will cause a test to fail. Additionally it prints the current environment, hence is useful to use when C<var> commands fail, as in the above example. Equivalent to something like C<env && error>.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    41
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    42
=item * SCRIPT_NAME
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    43
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    44
The script name is appended with ":smoke-test", eg "cifname.cif:smoke-test".
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    45
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    46
=item * SCRIPT_PATH, 0
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    47
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    48
Set as in any other script.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    49
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    50
=item * SCRIPT_LINE
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    51
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    52
Set as in any other script. Line numbers are relative to the start of the CIF file, not the first line of the smoke-test section.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    53
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    54
=item * Quiet
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    55
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    56
Used to supress stdout from a command, for when you don't want it to appear in the smoketest results. Usage:
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    57
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    58
    mynoisycommand $Quiet
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    59
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    60
Equivalent to putting C<E<gt>/dev/null> on the end of the command.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    61
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    62
=item * Silent
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    63
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    64
Supresses both stdout and stderr. Useful when an operation is expected to fail. Usage:
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    65
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    66
    mycommand expectfailure $Silent && $Error
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    67
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    68
Note how $Silent is combined with C<&& $Error> such that if the command actually succeeded where it was expected to fail, the $Error case would cause the script to abort.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    69
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    70
=item * Verbose
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    71
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    72
Defined if the C<--verbose> option was given to ciftest. Example usage:
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    73
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    74
    var Verbose defined && echo "About to test something-or-other"
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    75
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    76
=back
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    77
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    78
The environment used for running the smoke-test snippets is not shared between commands, so do not set things in one smoketest script and expect to be able to see them in another. (Ie the snippets are run as if with "fshell" not "source").
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    79
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    80
==argument string command optional
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    81
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    82
If specified, run the tests associated with the specified command. If not specified, run tests for all commands.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    83
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    84
==option bool v verbose
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    85
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    86
Print information about every test even when they succeed. By default only failures are printed. Also causes a summary to be printed at the end. Scripts can also print extra information themselves if this flag is set, by checking for the C<Verbose> environment variable.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    87
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    88
==option bool k keep-going
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    89
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    90
Rather than stop on the first failure, attempt to run all tests even if some of them fail. Only relevant if no command argument is given.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    91
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    92
==copyright
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    93
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    94
Copyright (c) 2010 Accenture. All rights reserved.