From 85aee474d93028a91c1cd69632845c75a427edf6 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Wed, 14 Apr 2010 13:52:51 +0200 Subject: [PATCH] Refactor tests on Automake TESTS color output. * tests/color.test: Tests using the expect program moved out to... * tests/color2.test: ... this new file. * tests/Makefile.am (TESTS): Extended accordingly. --- ChangeLog | 7 +++ tests/Makefile.am | 1 + tests/Makefile.in | 2 + tests/color.test | 22 ++-------- tests/color2.test | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+), 18 deletions(-) create mode 100755 tests/color2.test diff --git a/ChangeLog b/ChangeLog index c491037..32404d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-04-14 Stefano Lattarini + + Refactor tests on Automake TESTS color output. + * tests/color.test: Tests using the expect program moved out to... + * tests/color2.test: ... this new file. + * tests/Makefile.am (TESTS): Extended accordingly. + 2010-04-12 Stefano Lattarini Fix typos in comments in test confh5.test diff --git a/tests/Makefile.am b/tests/Makefile.am index eb63337..f09e843 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -144,6 +144,7 @@ colon5.test \ colon6.test \ colon7.test \ color.test \ +color2.test \ comment.test \ comment2.test \ comment3.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 58e7554..0c557d4 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -263,6 +263,7 @@ check7-p.test \ check8-p.test \ check9-p.test \ color-p.test \ +color2-p.test \ comment9-p.test \ dejagnu-p.test \ exeext4-p.test \ @@ -381,6 +382,7 @@ colon5.test \ colon6.test \ colon7.test \ color.test \ +color2.test \ comment.test \ comment2.test \ comment3.test \ diff --git a/tests/color.test b/tests/color.test index 6fa686d..9d86785 100755 --- a/tests/color.test +++ b/tests/color.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc. +# Copyright (C) 2007, 2008, 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 @@ -14,7 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Test Automake TESTS color output. +# Test Automake TESTS color output, by forcing it. +# Keep this in sync with the sister test `color2.test'. . ./defs || Exit 1 @@ -34,7 +35,7 @@ std='' # GNU or BSD 'grep -a' works on files, but is not portable. case `echo "$std" | grep .` in $std) ;; - *) Exit 77 ;; + *) echo "$me: grep can't parse nonprinting characters" >&2; Exit 77;; esac cat >>configure.in <expect-make <<'END' -#! /usr/bin/expect -f -spawn $env(MAKE) -e check -expect eof -END - AM_COLOR_TESTS=always $MAKE -e check >stdout && { cat stdout; Exit 1; } cat stdout test_color - -MAKE=$MAKE expect -f expect-make >stdout || { cat stdout; Exit 77; } -cat stdout -test_color - -AM_COLOR_TESTS=no MAKE=$MAKE expect -f expect-make >stdout || { cat stdout; Exit 77; } -cat stdout -test_no_color -: diff --git a/tests/color2.test b/tests/color2.test new file mode 100755 index 0000000..eedd37d --- /dev/null +++ b/tests/color2.test @@ -0,0 +1,124 @@ +#! /bin/sh +# Copyright (C) 2007, 2008, 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 2, 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 . + +# Test Automake TESTS color output, using the expect(1) program. +# Keep this in sync with the sister test `color.test'. + +. ./defs || Exit 1 + +set -e + +TERM=ansi +export TERM + +red='' +grn='' +lgn='' +blu='' +std='' + +# Check that grep can parse nonprinting characters. +# BSD 'grep' works from a pipe, but not a seekable file. +# GNU or BSD 'grep -a' works on files, but is not portable. +case `echo "$std" | grep .` in + $std) ;; + *) echo "$me: grep can't parse nonprinting characters" >&2; Exit 77;; +esac + +# Check that we have a working expect program. +cat >expect-check <<'END' +#! /usr/bin/expect -f +spawn $env(THE_SYSTEM_SHELL) -c : +expect eof +END +THE_SYSTEM_SHELL=/bin/sh expect -f expect-check || { + echo "$me: failed to find a working expect program" >&2 + Exit 77 +} + +# Do the tests. + +cat >>configure.in <Makefile.am <<'END' +AUTOMAKE_OPTIONS = color-tests +TESTS = $(check_SCRIPTS) +check_SCRIPTS = pass fail skip xpass xfail +XFAIL_TESTS = xpass xfail +END + +cat >pass <fail <skip <expect-make <<'END' +#! /usr/bin/expect -f +spawn $env(MAKE) -e check +expect eof +END + +MAKE=$MAKE expect -f expect-make >stdout \ + || { cat stdout; Exit 1; } +cat stdout +test_color + +AM_COLOR_TESTS=no MAKE=$MAKE expect -f expect-make >stdout \ + || { cat stdout; Exit 1; } +cat stdout +test_no_color -- 2.7.4