From a3e46c320956f59cba909b438a78974b1a14b8a0 Mon Sep 17 00:00:00 2001 From: brarcher Date: Sat, 4 Jan 2014 18:33:58 +0000 Subject: [PATCH] Add tests for CK_VERBOSITY env var There were previously no tests that checked this. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@1021 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- tests/ex_output.c | 9 ++++++++- tests/test_output.sh | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/ex_output.c b/tests/ex_output.c index 2347a6f..c601255 100644 --- a/tests/ex_output.c +++ b/tests/ex_output.c @@ -112,11 +112,14 @@ static Suite *make_xml_esc_suite (void) static void print_usage(void) { - printf ("Usage: ex_output (CK_SILENT | CK_MINIMAL | CK_NORMAL | CK_VERBOSE"); + printf ("Usage: ex_output (CK_SILENT | CK_MINIMAL | CK_NORMAL | CK_VERBOSE | CK_ENV"); #if ENABLE_SUBUNIT printf (" | CK_SUBUNIT"); #endif printf (") (STDOUT | LOG | TAP | XML) (NORMAL | EXIT_TEST)\n"); + printf(" If CK_ENV is used, the environment variable CK_VERBOSITY can be set to\n"); + printf(" one of these: silent, minimal, or verbose. If it is not set to these, or\n"); + printf(" if CK_VERBOSITY is not set, then CK_NORMAL will be used\n"); } static void run_tests (int printmode, char * log_type, int include_exit_test) @@ -183,6 +186,10 @@ int main (int argc, char **argv) { printmode = CK_VERBOSE; } + else if (strcmp (argv[OUTPUT_TYPE_ARG], "CK_ENV") == 0) + { + printmode = CK_ENV; + } #if ENABLE_SUBUNIT else if (strcmp (argv[OUTPUT_TYPE_ARG], "CK_SUBUNIT") == 0) { diff --git a/tests/test_output.sh b/tests/test_output.sh index fa67979..f9b4e83 100755 --- a/tests/test_output.sh +++ b/tests/test_output.sh @@ -123,9 +123,15 @@ ${SRCDIR}ex_output.c:58: fail \" ' < > & message fi act_silent=`./ex_output${EXEEXT} CK_SILENT STDOUT NORMAL | tr -d "\r"` +act_silent_env=`CK_VERBOSITY=silent ./ex_output${EXEEXT} CK_ENV STDOUT NORMAL | tr -d "\r"` act_minimal=`./ex_output${EXEEXT} CK_MINIMAL STDOUT NORMAL | tr -d "\r"` +act_minimal_env=`CK_VERBOSITY=minimal ./ex_output${EXEEXT} CK_ENV STDOUT NORMAL | tr -d "\r"` act_normal=`./ex_output${EXEEXT} CK_NORMAL STDOUT NORMAL | tr -d "\r"` +act_normal_env=`CK_VERBOSITY=normal CK_VERBOSITY='' ./ex_output${EXEEXT} CK_ENV STDOUT NORMAL | tr -d "\r"` +act_normal_env_blank=`CK_VERBOSITY='' ./ex_output${EXEEXT} CK_ENV STDOUT NORMAL | tr -d "\r"` +act_normal_env_invalid=`CK_VERBOSITY='BLARGS' ./ex_output${EXEEXT} CK_ENV STDOUT NORMAL | tr -d "\r"` act_verbose=`./ex_output${EXEEXT} CK_VERBOSE STDOUT NORMAL | tr -d "\r"` +act_verbose_env=`CK_VERBOSITY=verbose ./ex_output${EXEEXT} CK_ENV STDOUT NORMAL | tr -d "\r"` if test 1 -eq $ENABLE_SUBUNIT; then act_subunit=`./ex_output${EXEEXT} CK_SUBUNIT STDOUT NORMAL | tr -d "\r"` fi @@ -144,9 +150,15 @@ test_output ( ) { } test_output "$exp_silent" "$act_silent" "CK_SILENT STDOUT NORMAL"; +test_output "$exp_silent" "$act_silent_env" "CK_ENV STDOUT NORMAL"; test_output "$exp_minimal" "$act_minimal" "CK_MINIMAL STDOUT NORMAL"; +test_output "$exp_minimal" "$act_minimal_env" "CK_ENV STDOUT NORMAL"; test_output "$exp_normal" "$act_normal" "CK_NORMAL STDOUT NORMAL"; +test_output "$exp_normal" "$act_normal_env" "CK_ENV STDOUT NORMAL"; +test_output "$exp_normal" "$act_normal_env_blank" "CK_ENV STDOUT NORMAL"; +test_output "$exp_normal" "$act_normal_env_invalid" "CK_ENV STDOUT NORMAL"; test_output "$exp_verbose" "$act_verbose" "CK_VERBOSE STDOUT NORMAL"; +test_output "$exp_verbose" "$act_verbose_env" "CK_ENV STDOUT NORMAL"; if test 1 -eq $ENABLE_SUBUNIT; then test_output "$exp_subunit" "$act_subunit" "CK_SUBUNIT STDOUT NORMAL"; fi -- 2.40.0