1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-18 13:21:58 +02:00
Files
coreutils/tests/misc/sort-debug-keys
Jim Meyering a2c811db42 tests: use "compare exp out", not "compare out exp"
Likewise, when an empty file is expected, use "compare /dev/null out",
not "compare out /dev/null". I.e., specify the expected/desired contents
via the first file name.  Prompted by a suggestion from Bruno Haible
in http://thread.gmane.org/gmane.comp.gnu.grep.bugs/4020/focus=29154

Run these commands:

    git grep -l -E 'compare [^ ]+ exp' \
      |xargs perl -pi -e 's/(compare) (\S+) (exp\S*)/$1 $3 $2/'
    git grep -l -E 'compare [^ ]+ /dev/null' \
      |xargs perl -pi -e 's/(compare) (\S+) (\/dev\/null)/$1 $3 $2/'

* tests/chgrp/no-x: As above.
* tests/chmod/no-x: Likewise.
* tests/chmod/silent: Likewise.
* tests/chmod/thru-dangling: Likewise.
* tests/chown/basic: Likewise.
* tests/chown/deref: Likewise.
* tests/chown/preserve-root: Likewise.
* tests/cp/abuse: Likewise.
* tests/cp/backup-is-src: Likewise.
* tests/cp/cp-a-selinux: Likewise.
* tests/cp/cp-mv-enotsup-xattr: Likewise.
* tests/cp/fail-perm: Likewise.
* tests/cp/into-self: Likewise.
* tests/cp/proc-zero-len: Likewise.
* tests/cp/src-base-dot: Likewise.
* tests/cp/thru-dangling: Likewise.
* tests/dd/reblock: Likewise.
* tests/dd/unblock-sync: Likewise.
* tests/du/2g: Likewise.
* tests/du/8gb: Likewise.
* tests/du/basic: Likewise.
* tests/du/bigtime: Likewise.
* tests/du/deref-args: Likewise.
* tests/du/exclude: Likewise.
* tests/du/files0-from-dir: Likewise.
* tests/du/hard-link: Likewise.
* tests/du/inacc-dest: Likewise.
* tests/du/inacc-dir: Likewise.
* tests/du/long-sloop: Likewise.
* tests/du/max-depth: Likewise.
* tests/du/move-dir-while-traversing: Likewise.
* tests/du/no-deref: Likewise.
* tests/du/no-x: Likewise.
* tests/du/one-file-system: Likewise.
* tests/du/slash: Likewise.
* tests/du/trailing-slash: Likewise.
* tests/install/strip-program: Likewise.
* tests/ln/hard-backup: Likewise.
* tests/ls/block-size: Likewise.
* tests/ls/color-clear-to-eol: Likewise.
* tests/ls/color-dtype-dir: Likewise.
* tests/ls/color-norm: Likewise.
* tests/ls/dangle: Likewise.
* tests/ls/dired: Likewise.
* tests/ls/file-type: Likewise.
* tests/ls/follow-slink: Likewise.
* tests/ls/infloop: Likewise.
* tests/ls/m-option: Likewise.
* tests/ls/no-arg: Likewise.
* tests/ls/recursive: Likewise.
* tests/ls/rt-1: Likewise.
* tests/ls/stat-dtype: Likewise.
* tests/ls/stat-failed: Likewise.
* tests/ls/stat-free-symlinks: Likewise.
* tests/ls/x-option: Likewise.
* tests/misc/arch: Likewise.
* tests/misc/cat-buf: Likewise.
* tests/misc/cat-proc: Likewise.
* tests/misc/chcon: Likewise.
* tests/misc/csplit: Likewise.
* tests/misc/df-P: Likewise.
* tests/misc/fmt-long-line: Likewise.
* tests/misc/groups-dash: Likewise.
* tests/misc/groups-version: Likewise.
* tests/misc/head-pos: Likewise.
* tests/misc/nl: Likewise.
* tests/misc/od-N: Likewise.
* tests/misc/od-multiple-t: Likewise.
* tests/misc/od-x8: Likewise.
* tests/misc/printf: Likewise.
* tests/misc/printf-hex: Likewise.
* tests/misc/pwd-option: Likewise.
* tests/misc/readlink-fp-loop: Likewise.
* tests/misc/runcon-no-reorder: Likewise.
* tests/misc/seq-long-double: Likewise.
* tests/misc/sort-NaN-infloop: Likewise.
* tests/misc/sort-benchmark-random: Likewise.
* tests/misc/sort-debug-keys: Likewise.
* tests/misc/sort-float: Likewise.
* tests/misc/sort-merge-fdlimit: Likewise.
* tests/misc/sort-unique-segv: Likewise.
* tests/misc/stat-hyphen: Likewise.
* tests/misc/stat-slash: Likewise.
* tests/misc/stdbuf: Likewise.
* tests/misc/sum-sysv: Likewise.
* tests/misc/tac-2-nonseekable: Likewise.
* tests/misc/tac-continue: Likewise.
* tests/misc/tr-case-class: Likewise.
* tests/misc/truncate-fail-diag: Likewise.
* tests/misc/wc-files0: Likewise.
* tests/mkdir/selinux: Likewise.
* tests/mv/backup-dir: Likewise.
* tests/mv/backup-is-src: Likewise.
* tests/mv/diag: Likewise.
* tests/mv/dir2dir: Likewise.
* tests/mv/dup-source: Likewise.
* tests/mv/force: Likewise.
* tests/mv/hard-verbose: Likewise.
* tests/mv/i-link-no: Likewise.
* tests/mv/into-self: Likewise.
* tests/mv/into-self-2: Likewise.
* tests/mv/into-self-3: Likewise.
* tests/mv/mv-special-1: Likewise.
* tests/mv/part-fail: Likewise.
* tests/mv/perm-1: Likewise.
* tests/mv/sticky-to-xpart: Likewise.
* tests/mv/trailing-slash: Likewise.
* tests/rm/rm1: Likewise.
* tests/rm/rm2: Likewise.
* tests/rm/cycle: Likewise.
* tests/rm/dir-no-w: Likewise.
* tests/rm/dir-nonrecur: Likewise.
* tests/rm/fail-2eperm: Likewise.
* tests/rm/fail-eacces: Likewise.
* tests/rm/i-never: Likewise.
* tests/rm/inaccessible: Likewise.
* tests/rm/interactive-always: Likewise.
* tests/rm/interactive-once: Likewise.
* tests/rm/isatty: Likewise.
* tests/rm/one-file-system: Likewise.
* tests/rm/rm3: Likewise.
* tests/rm/rm5: Likewise.
* tests/rm/unread2: Likewise.
* tests/rm/v-slash: Likewise.
* tests/sample-test: Likewise.
* tests/split/b-chunk: Likewise.
* tests/split/fail: Likewise.
* tests/split/l-chunk: Likewise.
* tests/split/lines: Likewise.
* tests/split/r-chunk: Likewise.
* tests/split/suffix-length: Likewise.
* tests/tail-2/big-4gb: Likewise.
* tests/tail-2/follow-name: Likewise.
* tests/tail-2/follow-stdin: Likewise.
* tests/tail-2/pipe-f: Likewise.
* tests/tail-2/pipe-f2: Likewise.
* tests/tail-2/start-middle: Likewise.
* tests/touch/60-seconds: Likewise.
* tests/touch/fail-diag: Likewise.
* tests/touch/not-owner: Likewise.
* tests/touch/relative: Likewise.
2011-11-22 10:35:03 +01:00

331 lines
4.7 KiB
Bash
Executable File

#!/bin/sh
# Test annotation of sort keys
# Copyright (C) 2010-2011 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/>.
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ sort
number() { cat -n | sed 's/^ *//'; }
cat <<\EOF > exp
1
^ no match for key
^ no match for key
44
^ no match for key
33
^ no match for key
2
^ no match for key
1
^ no match for key
^ no match for key
44
^ no match for key
33
^ no match for key
2
^ no match for key
^ no match for key
1
_
2
_
33
__
44
__
2>
^ no match for key
3>1
_
1>2
_
1
^ no match for key
^ no match for key
44
^ no match for key
33
^ no match for key
2
^ no match for key
1
^ no match for key
^ no match for key
44
^ no match for key
33
^ no match for key
2
^ no match for key
^ no match for key
1
_
2
_
33
__
44
__
2>
^ no match for key
3>1
_
1>2
_
1
^ no match for key
^ no match for key
44
^ no match for key
33
^ no match for key
2
^ no match for key
1
^ no match for key
^ no match for key
44
^ no match for key
33
^ no match for key
2
^ no match for key
^ no match for key
1
_
2
_
33
__
44
__
2>
^ no match for key
3>1
_
1>2
_
^ no match for key
JAN
___
FEB
___
FEB
^ no match for key
^ no match for key
JAN
^ no match for key
JAZZ
^ no match for key
^ no match for key
JAN
___
FEB
___
2>JAZZ
^ no match for key
3>
^ no match for key
4>JAN
___
1>FEB
___
^ no match for key
JANZ
___
JAN
___
FEB
___
3>
^ no match for key
2>JANZ
___
4>JAN
___
1>FEB
___
1.2ignore
___
1.1e4ignore
_____
>>a
___
>b
__
a
^ no match for key
^ no match for key
a
_
b
_
-3
__
-2
__
-0
__
--Mi-1
^ no match for key
-0
__
1
_
1
_
__
1
_
_
1
_
1
_
1
__
1
_
2,5
_
2.4
___
2.,,3
__
2.4
___
2,,3
_
2.4
___
1a
_
2b
_
>a
_
A>chr10
^ no match for key
B>chr1
^ no match for key
EOF
(
for type in n h g; do
printf '1\n\n44\n33\n2\n' | sort -s -k2$type --debug
printf '1\n\n44\n33\n2\n' | sort -s -k1.3$type --debug
printf '1\n\n44\n33\n2\n' | sort -s -k1$type --debug
printf '2\n\n1\n' | number | sort -s -k2g --debug
done
printf 'FEB\n\nJAN\n' | sort -s -k1M --debug
printf 'FEB\n\nJAN\n' | sort -s -k2,2M --debug
printf 'FEB\nJAZZ\n\nJAN\n' | sort -s -k1M --debug
printf 'FEB\nJAZZ\n\nJAN\n' | number | sort -s -k2,2M --debug
printf 'FEB\nJANZ\n\nJAN\n' | sort -s -k1M --debug
printf 'FEB\nJANZ\n\nJAN\n' | number | sort -s -k2,2M --debug
printf ' 1.2ignore\n 1.1e4ignore\n' | sort -s -g --debug
printf '\tb\n\t\ta\n' | sort -s -d --debug # ignore = 1
printf 'a\n\n' | sort -s -k2,2 --debug #lena = 0
printf 'b\na\n' | sort -s -k1 --debug #otherwise key compare
printf -- '-0\n1\n-2\n--Mi-1\n-3\n-0\n' | sort -s --debug -k1,1h
printf ' 1\n1\n' | sort -b --debug
printf ' 1\n1\n' | sort -sb --debug
printf ' 1\n1\n' | sort --debug
# strnumcmp is a bit weird, so we don't match exactly
printf '2,5\n2.4\n' | sort -s -k1n --debug
printf '2.,,3\n2.4\n' | sort -s -k1n --debug
printf '2,,3\n2.4\n' | sort -s -k1n --debug
# -z means we convert \0 to \n
env printf '1a\x002b\x00' | sort -s -n -z --debug
# Check that \0 and \t intermix.
printf '\0\ta\n' | sort -s -k2b,2 --debug | tr -d '\0'
# Check that key end before key start is not underlined
printf 'A\tchr10\nB\tchr1\n' | sort -s -k2.4b,2.3n --debug
) > out
compare exp out || fail=1
cat <<\EOF > exp
1²---++3 1,234 Mi
_
_________
________________________
1²---++3 1,234 Mi
_____
________
_______________________
+1234 1234Gi 1,234M
^ no match for key
_____
^ no match for key
____
____
_____
_____
_____
______
___________________
EOF
unset LC_ALL
f=$LOCALE_FR_UTF8
: ${LOCALE_FR_UTF8=none}
if test "$LOCALE_FR_UTF8" != "none"; then
(
echo ' 1²---++3 1,234 Mi' |
LC_ALL=C sort --debug -k2g -k1b,1
echo ' 1²---++3 1,234 Mi' |
LC_COLLATE=$f LC_CTYPE=$f LC_NUMERIC=$f LC_MESSAGES=C \
sort --debug -k2g -k1b,1
echo '+1234 1234Gi 1,234M' |
LC_COLLATE=$f LC_CTYPE=$f LC_NUMERIC=$f LC_MESSAGES=C \
sort --debug -k1,1n -k1,1g \
-k1,1h -k2,2n -k2,2g -k2,2h -k3,3n -k3,3g -k3,3h
) > out
compare exp out || fail=1
fi
Exit $fail