|
1 #!fshell |
|
2 # fshell-ccommandbase-test.script |
|
3 # |
|
4 # Copyright (c) 2010 Accenture. All rights reserved. |
|
5 # This component and the accompanying materials are made available |
|
6 # under the terms of the "Eclipse Public License v1.0" |
|
7 # which accompanies this distribution, and is available |
|
8 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 # |
|
10 # Initial Contributors: |
|
11 # Accenture - Initial contribution |
|
12 # |
|
13 |
|
14 # Syntax: fshell fshell-ccommandbase-test.script |
|
15 # Tests various features of CCommandBase relating to argument and option parsing |
|
16 |
|
17 source $SCRIPT_PATH\errordef.script |
|
18 |
|
19 # Check that negative integers are parsed correctly |
|
20 tinteger -1 -2 -3 -4 # -1 is a short option, -2 is an integer argument, -3 is a short option that takes an int (being -4). If any of them don't get filled in correctly tinteger will bail |
|
21 tinteger -3 -4 -2 -1 # This should be equivalent |
|
22 export TESTINT "-8" |
|
23 var TESTINT subtract "-5" # "subtract -5" is a trickier-to-parse equivalent of "add 5" |
|
24 var TESTINT == "-3" || $Error |
|
25 #TODO hmm should we have to quote the string arguments that start with a dash? |
|
26 |
|
27 # Check that 64-bit types are handled ok (these don't get used much so worth testing here) |
|
28 # If tfshellarguments doesn't see these exact values it will error |
|
29 tfshellarguments 1099511627776 3.1415927 |
|
30 tfshellarguments 0x10000000000 31415927.0e-7 |
|
31 tfshellarguments 0x10000000000 31415927 2>/dev/null && $Error # If this *succeeds* it's an error, because the floating point arg is wrong, hence the use of && rather than || |
|
32 |
|
33 # Check that options and args can be filled in from the environment (run tenvarguments first with all args specified on command line as a control) |
|
34 tenvarguments StringArg 1234 0x1234 --boolopt --stringopt StringOpt --intopt 4321 --uintopt 0x4321 |
|
35 export STRINGARG StringArg |
|
36 export INTARG 1234 |
|
37 export UINTARG 0x1234 |
|
38 export BOOLOPT 1 |
|
39 export STRINGOPT StringOpt |
|
40 export INTOPT 4321 |
|
41 export UINTOPT 0x4321 |
|
42 tenvarguments # CCommandBase will moan if anything non-optional is not filled in, and tenvarguments itself checks the values it receives are what it expects. |
|
43 tnoncifenvarguments # same but testing that the behaviour is the same when not using a CIF (the way the arguments are set up is a slightly different code path) |