summaryrefslogtreecommitdiff
path: root/tests/misc/sort-debug-warn
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2010-05-11 18:46:21 +0100
committerPádraig Brady <P@draigBrady.com>2010-05-16 01:08:33 +0100
commit03f6f32c416e4bca1cfe66fe85834a91636f499d (patch)
treeb7a5b44a0197e5b1b847d5771dad823d399cb782 /tests/misc/sort-debug-warn
parent144d6e5f53b59cec504b1194b4f420144896f9ae (diff)
downloadcoreutils-03f6f32c416e4bca1cfe66fe85834a91636f499d.tar.xz
sort: --debug: output data independent warnings and info
* src/sort.c (usage): Mention --debug can output warnings to stderr. Also split the translatable string to aid translation. (default_key_compare): A new function refactored from main(), and now also called from the new key_warnings() function. (key_to_opts): A new function refactored from incompatible_options(), and now also called from the new key_warnings() function. (key_numeric): A new function refactored to test if key is numeric. (key_warnings): A new function to output warnings to stderr, about questionable use of various options. Currently it warns about zero length keys and ineffective global options. (incompatible_options): Refactor out key_to_opts() (main): Use key_init() to initialize gkey. Refactor out default_key_compare(). Call key_warnings() in debug mode. * doc/coreutils.texi (sort invocation): Mention that warnings are output by --debug. * tests/misc/sort-debug-warn: A new test for debug warnings. * tests/Makefile.am: Reference the new test. * NEWS: Mention the new feature
Diffstat (limited to 'tests/misc/sort-debug-warn')
-rwxr-xr-xtests/misc/sort-debug-warn91
1 files changed, 91 insertions, 0 deletions
diff --git a/tests/misc/sort-debug-warn b/tests/misc/sort-debug-warn
new file mode 100755
index 000000000..3a7b01a0c
--- /dev/null
+++ b/tests/misc/sort-debug-warn
@@ -0,0 +1,91 @@
+#!/bin/sh
+# Test warnings for sort options
+
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# 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. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ sort --version
+fi
+
+. $srcdir/test-lib.sh
+
+cat <<\EOF > exp
+sort: using simple byte comparison
+sort: key 1 has zero width and will be ignored
+sort: leading blanks are significant in key 1; consider also specifying `b'
+sort: using simple byte comparison
+sort: options `-bghMRrV' are ignored
+sort: using simple byte comparison
+sort: options `-bghMRV' are ignored
+sort: option `-r' only applies to last-resort comparison
+sort: using simple byte comparison
+sort: option `-r' only applies to last-resort comparison
+sort: using simple byte comparison
+sort: leading blanks are significant in key 2; consider also specifying `b'
+sort: options `-bg' are ignored
+sort: using simple byte comparison
+sort: using simple byte comparison
+sort: option `-b' is ignored
+sort: using simple byte comparison
+sort: using simple byte comparison
+sort: leading blanks are significant in key 1; consider also specifying `b'
+sort: using simple byte comparison
+sort: leading blanks are significant in key 1; consider also specifying `b'
+sort: using simple byte comparison
+sort: leading blanks are significant in key 1; consider also specifying `b'
+sort: option `-d' is ignored
+sort: using simple byte comparison
+sort: leading blanks are significant in key 1; consider also specifying `b'
+sort: option `-i' is ignored
+sort: using simple byte comparison
+sort: using simple byte comparison
+sort: using simple byte comparison
+EOF
+
+sort -s -k2,1 --debug /dev/null 2>>out
+sort -s -rRVMhgb -k1,1n --debug /dev/null 2>>out
+sort -rRVMhgb -k1,1n --debug /dev/null 2>>out
+sort -r -k1,1n --debug /dev/null 2>>out
+sort -gbr -k1,1n -k1,1r --debug /dev/null 2>>out
+sort -b -k1b,1bn --debug /dev/null 2>>out # no warning
+sort -b -k1,1bn --debug /dev/null 2>>out
+sort -b -k1,1bn -k2b,2 --debug /dev/null 2>>out # no warning
+sort -r -k1,1r --debug /dev/null 2>>out # no warning for redundant options
+sort -i -k1,1i --debug /dev/null 2>>out # no warning
+sort -d -k1,1b --debug /dev/null 2>>out
+sort -i -k1,1d --debug /dev/null 2>>out
+sort -r --debug /dev/null 2>>out #no warning
+sort -rM --debug /dev/null 2>>out #no warning
+sort -rM -k1,1 --debug /dev/null 2>>out #no warning
+
+compare exp out || fail=1
+
+cat <<\EOF > exp
+sort: using simple byte comparison
+sort: key 1 is numeric and spans multiple fields
+sort: obsolescent key `+2 -1' used; consider `-k 3,1' instead
+sort: key 2 has zero width and will be ignored
+sort: leading blanks are significant in key 2; consider also specifying `b'
+sort: option `-b' is ignored
+sort: option `-r' only applies to last-resort comparison
+EOF
+
+sort --debug -rb -k2n +2 -1b /dev/null 2>out
+
+compare exp out || fail=1
+
+Exit $fail