summaryrefslogtreecommitdiff
path: root/test/cmdline.test
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
committercashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
commit4f49b16079b27d7ce633619e4cddfdf2bffbc952 (patch)
treec296c1e7f3c3e2f6859c6d3a1b1b208779b89679 /test/cmdline.test
downloadrelic-master.tar.gz
initial commitHEADmaster
Diffstat (limited to 'test/cmdline.test')
-rw-r--r--test/cmdline.test54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/cmdline.test b/test/cmdline.test
new file mode 100644
index 0000000..ff1c595
--- /dev/null
+++ b/test/cmdline.test
@@ -0,0 +1,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