From 82bfc7a3441ef6aa17fb407e3a9a84fb01894d29 Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Wed, 17 Apr 2024 15:15:12 -0700 Subject: [PATCH] t: add coverage of -L color short option Problem: In several tests the --color option is tested but either the short -L option is not tested or it is not tested with arguments. Add additionl tests in t0009-dmesg.t t1008-kvs-eventlog.t t2230-job-info-lookup.t t3303-system-healthcheck.t --- t/t0009-dmesg.t | 24 ++++++++++++++---------- t/t1008-kvs-eventlog.t | 2 +- t/t2230-job-info-lookup.t | 2 +- t/t3303-system-healthcheck.t | 4 ++++ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/t/t0009-dmesg.t b/t/t0009-dmesg.t index 5665c517bc17..3dccfc52bcf2 100755 --- a/t/t0009-dmesg.t +++ b/t/t0009-dmesg.t @@ -138,16 +138,20 @@ test_expect_success 'dmesg -H, --human --delta works' ' test_expect_success 'dmesg --delta without --human fails' ' test_must_fail flux dmesg --delta ' -test_expect_success 'dmesg -H, --human --color works' ' - flux dmesg --human --color | sed -n 1p | grep "^" && - flux dmesg --human --color | sed -n 2p | grep "^" -' -test_expect_success 'dmesg colorizes lines by severity' ' - for s in emerg alert crit err warning notice debug; do - flux logger --severity=$s severity=$s && - flux dmesg --human --color | grep "[^ ]*severity=$s" - done -' + +for opt in "-L" "-Lalways" "--color" "--color=always"; do + test_expect_success "dmesg -H, --human $opt works" ' + flux dmesg --human $opt | sed -n 1p | grep "^" && + flux dmesg --human $opt | sed -n 2p | grep "^" + ' + test_expect_success "dmesg colorizes lines by severity" ' + for s in emerg alert crit err warning notice debug; do + flux logger --severity=$s severity=$s && + flux dmesg --human $opt | grep "[^ ]*severity=$s" + done + ' +done + test_expect_success 'dmesg with invalid --color option fails' ' test_must_fail flux dmesg --color=foo ' diff --git a/t/t1008-kvs-eventlog.t b/t/t1008-kvs-eventlog.t index 70ed1d3ab2dc..c72afa5bb59a 100755 --- a/t/t1008-kvs-eventlog.t +++ b/t/t1008-kvs-eventlog.t @@ -69,7 +69,7 @@ test_expect_success 'flux kvs eventlog get/wait-event reject invalid --color' ' test_must_fail flux kvs eventlog get --color=foo test.human && test_must_fail flux kvs eventlog wait-event --color=foo test.human primus ' -for opt in "-L" "--color" "--color=always"; do +for opt in "-L" "-Lalways" "--color" "--color=always"; do test_expect_success "flux kvs eventlog get $opt forces color on" ' name=notty${opt##--color=} && outfile=color-${name:-default}.out && diff --git a/t/t2230-job-info-lookup.t b/t/t2230-job-info-lookup.t index 668121c04a9f..fb1c742a526b 100755 --- a/t/t2230-job-info-lookup.t +++ b/t/t2230-job-info-lookup.t @@ -255,7 +255,7 @@ test_expect_success 'flux job eventlog/wait-event reject invalid --color' ' test_must_fail flux job eventlog --color=foo $jobid && test_must_fail flux job wait-event --color=foo $jobid ' -for opt in "-L" "--color" "--color=always"; do +for opt in "-L" "-Lalways" "--color" "--color=always"; do test_expect_success "flux job eventlog $opt forces color on" ' name=notty${opt##--color=} && outfile=color-${name:-default}.out && diff --git a/t/t3303-system-healthcheck.t b/t/t3303-system-healthcheck.t index 60828fa59c60..1481ba0387bf 100755 --- a/t/t3303-system-healthcheck.t +++ b/t/t3303-system-healthcheck.t @@ -97,9 +97,13 @@ test_expect_success 'flux overlay status --highlight expected failures' ' ' test_expect_success 'flux overlay status --color option works' ' + test_must_fail flux overlay status -Lfoo && test_must_fail flux overlay status --color=foo && + flux overlay status -Lnever --highlight=0 | grep "<<0" && flux overlay status --color=never --highlight=0 | grep "<<0" && + flux overlay status -Lauto --highlight=0 | grep "<<0" && flux overlay status --color=auto --highlight=0 | grep "<<0" && + flux overlay status -L --highlight=0 | grep "\[" && flux overlay status --color --highlight=0 | grep "\[" '