diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-08-30 14:13:12 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-08-30 18:55:59 +0200 |
commit | 9eb4c31eb78c28dd9f72d1cbb940270311be343c (patch) | |
tree | ea3078bc1b002a9f948ed41445ca32318002a1d3 /tests/ls/color-norm.sh | |
parent | 00f5ba15dd91a3d9780fe1fbd06a4df436ae6714 (diff) | |
download | coreutils-9eb4c31eb78c28dd9f72d1cbb940270311be343c.tar.xz |
tests: add .sh and .pl suffixes to shell and perl tests, respectively
Not only this shrinks the size of the generated Makefile (from > 6300
lines to ~3000), but will allow further simplifications in future
changes.
* tests/Makefile.am (TEST_EXTENSIONS): Add '.sh' and '.pl'.
(PL_LOG_COMPILER, SH_LOG_COMPILER): New, still defined simply to
$(LOG_COMPILER) for the time being.
(TESTS, root_tests): Adjust as described.
* All tests: Rename as described.
Diffstat (limited to 'tests/ls/color-norm.sh')
-rwxr-xr-x | tests/ls/color-norm.sh | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/ls/color-norm.sh b/tests/ls/color-norm.sh new file mode 100755 index 000000000..28366fb5c --- /dev/null +++ b/tests/ls/color-norm.sh @@ -0,0 +1,84 @@ +#!/bin/sh +# Ensure "ls --color" properly colors "normal" text and files. +# I.E. that it uses NORMAL to style non file name output and +# file names with no associated color (unless FILE is also set). + +# Copyright (C) 2010-2012 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_ ls + +# Don't let a different umask perturb the results. +umask 22 + +# Output time as something constant +export TIME_STYLE="+norm" + +# helper to strip ls columns up to "norm" time +qls() { sed 's/-r.*norm/norm/'; } + +touch exe || framework_failure_ +chmod u+x exe || framework_failure_ +touch nocolor || framework_failure_ + +TCOLORS="no=7:ex=01;32" + +# Non coloured files inherit NORMAL attributes +LS_COLORS=$TCOLORS ls -gGU --color exe nocolor | qls >> out || fail=1 +LS_COLORS=$TCOLORS ls -xU --color exe nocolor >> out || fail=1 +LS_COLORS=$TCOLORS ls -gGU --color nocolor exe | qls >> out || fail=1 +LS_COLORS=$TCOLORS ls -xU --color nocolor exe >> out || fail=1 + +# NORMAL does not override FILE though +LS_COLORS=$TCOLORS:fi=1 ls -gGU --color nocolor exe | qls >> out || fail=1 + +# Support uncolored ordinary files that do _not_ inherit from NORMAL. +# Note there is a redundant RESET output before a non colored +# file in this case which may be removed in future. +LS_COLORS=$TCOLORS:fi= ls -gGU --color nocolor exe | qls >> out || fail=1 +LS_COLORS=$TCOLORS:fi=0 ls -gGU --color nocolor exe | qls >> out || fail=1 + +# A caveat worth noting is that commas (-m), indicator chars (-F) +# and the "total" line, do not currently use NORMAL attributes +LS_COLORS=$TCOLORS ls -mFU --color nocolor exe >> out || fail=1 + +# Ensure no coloring is done unless enabled +LS_COLORS=$TCOLORS ls -gGU nocolor exe | qls >> out || fail=1 + +cat -A out > out.display || framework_failure_ +mv out.display out || framework_failure_ + +cat <<\EOF > exp || framework_failure_ +^[[0m^[[7mnorm ^[[m^[[01;32mexe^[[0m$ +^[[7mnorm nocolor^[[0m$ +^[[0m^[[7m^[[m^[[01;32mexe^[[0m ^[[7mnocolor^[[0m$ +^[[0m^[[7mnorm nocolor^[[0m$ +^[[7mnorm ^[[m^[[01;32mexe^[[0m$ +^[[0m^[[7mnocolor^[[0m ^[[7m^[[m^[[01;32mexe^[[0m$ +^[[0m^[[7mnorm ^[[m^[[1mnocolor^[[0m$ +^[[7mnorm ^[[m^[[01;32mexe^[[0m$ +^[[0m^[[7mnorm ^[[m^[[mnocolor^[[0m$ +^[[7mnorm ^[[m^[[01;32mexe^[[0m$ +^[[0m^[[7mnorm ^[[m^[[0mnocolor^[[0m$ +^[[7mnorm ^[[m^[[01;32mexe^[[0m$ +^[[0m^[[7mnocolor^[[0m, ^[[7m^[[m^[[01;32mexe^[[0m*$ +norm nocolor$ +norm exe$ +EOF + +compare exp out || fail=1 + +Exit $fail |