Skip to content

Commit

Permalink
t: add coverage of -L color short option
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chu11 committed Apr 18, 2024
1 parent 1e9638e commit 82bfc7a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
24 changes: 14 additions & 10 deletions t/t0009-dmesg.t
Expand Up @@ -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
'
Expand Down
2 changes: 1 addition & 1 deletion t/t1008-kvs-eventlog.t
Expand Up @@ -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 &&
Expand Down
2 changes: 1 addition & 1 deletion t/t2230-job-info-lookup.t
Expand Up @@ -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 &&
Expand Down
4 changes: 4 additions & 0 deletions t/t3303-system-healthcheck.t
Expand Up @@ -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 "\["
'

Expand Down

0 comments on commit 82bfc7a

Please sign in to comment.