|
1
|
# |
|
2
|
# Copyright (c) 2012 D. Richard Hipp |
|
3
|
# |
|
4
|
# This program is free software; you can redistribute it and/or |
|
5
|
# modify it under the terms of the Simplified BSD License (also |
|
6
|
# known as the "2-Clause License" or "FreeBSD License".) |
|
7
|
# |
|
8
|
# This program is distributed in the hope that it will be useful, |
|
9
|
# but without any warranty; without even the implied warranty of |
|
10
|
# merchantability or fitness for a particular purpose. |
|
11
|
# |
|
12
|
# Author contact information: |
|
13
|
# [email protected] |
|
14
|
# http://www.hwaci.com/drh/ |
|
15
|
# |
|
16
|
############################################################################ |
|
17
|
# |
|
18
|
# Test command line parsing |
|
19
|
# |
|
20
|
|
|
21
|
test_setup "" |
|
22
|
|
|
23
|
proc cmd-line {usefile testname args} { |
|
24
|
set i 1 |
|
25
|
foreach {cmdline result} $args { |
|
26
|
if {$usefile} { |
|
27
|
set cmdlinefile [file join \ |
|
28
|
[getTemporaryPath] fossil-cmd-line-$testname.txt] |
|
29
|
|
|
30
|
write_file $cmdlinefile $cmdline |
|
31
|
fossil test-echo --args $cmdlinefile |
|
32
|
file delete $cmdlinefile |
|
33
|
} else { |
|
34
|
fossil test-echo $cmdline |
|
35
|
} |
|
36
|
|
|
37
|
test cmd-line-$testname.$i \ |
|
38
|
{[lrange [split $::RESULT \n] 3 end]=="\{argv\[2\] = \[$result\]\}"} |
|
39
|
|
|
40
|
incr i |
|
41
|
} |
|
42
|
} |
|
43
|
|
|
44
|
cmd-line false 100 abc abc a\"bc a\"bc \"abc\" \"abc\" |
|
45
|
|
|
46
|
# |
|
47
|
# NOTE: Use an --args file on Windows to avoid unwanted glob expansion |
|
48
|
# from MinGW and/or the MSVCRT. |
|
49
|
# |
|
50
|
cmd-line $ittp://www.hwaci.com/drh/ |
|
51
|
# |
|
52
|
################################################# |