File: cmdline.test

package info (click to toggle)
fossil 1%3A2.27-2
  • links: PTS
  • area: main
  • in suites: sid
  • size: 28,724 kB
  • sloc: ansic: 334,116; tcl: 14,158; javascript: 10,327; sh: 6,791; makefile: 4,290; pascal: 1,139; cpp: 1,001; cs: 879; sql: 376; asm: 281; perl: 166; xml: 95
file content (54 lines) | stat: -rw-r--r-- 1,417 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#
# Copyright (c) 2012 D. Richard Hipp
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the Simplified BSD License (also
# known as the "2-Clause License" or "FreeBSD License".)
#
# This program is distributed in the hope that it will be useful,
# but without any warranty; without even the implied warranty of
# merchantability or fitness for a particular purpose.
#
# Author contact information:
#   drh@hwaci.com
#   http://www.hwaci.com/drh/
#
############################################################################
#
# Test command line parsing
#

test_setup ""

proc cmd-line {usefile testname args} {
  set i 1
  foreach {cmdline result} $args {
    if {$usefile} {
      set cmdlinefile [file join \
          [getTemporaryPath] fossil-cmd-line-$testname.txt]

      write_file $cmdlinefile $cmdline
      fossil test-echo --args $cmdlinefile
      file delete $cmdlinefile
    } else {
      fossil test-echo $cmdline
    }

    test cmd-line-$testname.$i \
        {[lrange [split $::RESULT \n] 3 end]=="\{argv\[2\] = \[$result\]\}"}

    incr i
  }
}

cmd-line false 100 abc abc a\"bc a\"bc \"abc\" \"abc\"

#
# NOTE: Use an --args file on Windows to avoid unwanted glob expansion
#       from MinGW and/or the MSVCRT.
#
cmd-line $is_windows 101 * * *.* *.*

###############################################################################

test_cleanup