core/builtins/ciftest.cif
author Tom Sutcliffe <thomas.sutcliffe@accenture.com>
Wed, 13 Oct 2010 12:53:17 +0100
changeset 67 84fefe1cd57f
parent 66 2a78c4ff2eab
permissions -rw-r--r--
merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
66
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     1
# ciftest.cif
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     2
# 
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     3
# Copyright (c) 2010 Accenture. All rights reserved.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     5
# under the terms of the "Eclipse Public License v1.0"
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     8
# 
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     9
# Initial Contributors:
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    10
# Accenture - Initial contribution
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    11
#
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    12
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    13
==name ciftest
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    14
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    15
==short-description
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    16
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    17
Run fshell command smoke tests.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    18
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    19
==long-description
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    20
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
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.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    22
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    23
Example CIF file that supports ciftest:
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    24
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    25
    ==name mycmd
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    26
    
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    27
    [...]
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    28
    
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    29
    ==smoke-test
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    30
    
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    31
    mycmd | export -s RESULT
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    32
    var RESULT == "Expected results of running mycmd" || $Error
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    33
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
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:
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    35
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    36
=over 5
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    37
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    38
=item * Error
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    39
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
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>.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    41
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    42
=item * SCRIPT_NAME
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    43
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    44
The script name is appended with ":smoke-test", eg "cifname.cif:smoke-test".
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    45
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    46
=item * SCRIPT_PATH, 0
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    47
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    48
Set as in any other script.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    49
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    50
=item * SCRIPT_LINE
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    51
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
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.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    53
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    54
=item * Quiet
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    55
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
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:
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    57
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    58
    mynoisycommand $Quiet
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    59
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    60
Equivalent to putting C<E<gt>/dev/null> on the end of the command.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    61
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    62
=item * Silent
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    63
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    64
Supresses both stdout and stderr. Useful when an operation is expected to fail. Usage:
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    65
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    66
    mycommand expectfailure $Silent && $Error
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    67
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
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.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    69
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    70
=item * Verbose
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    71
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    72
Defined if the C<--verbose> option was given to ciftest. Example usage:
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    73
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    74
    var Verbose defined && echo "About to test something-or-other"
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    75
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    76
=back
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    77
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
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").
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    79
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    80
==argument string command optional
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    81
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
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.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    83
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    84
==option bool v verbose
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    85
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
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.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    87
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    88
==option bool k keep-going
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    89
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
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.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    91
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    92
==copyright
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    93
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    94
Copyright (c) 2010 Accenture. All rights reserved.
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    95
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    96
==smoke-test
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    97
2a78c4ff2eab Migrated ciftest and various fixes from FCL to MCL.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    98
# Ciftest itself doesn't have a smoketest!