* Eric Blake wrote on Wed, Nov 12, 2008 at 03:46:53AM CET: > According to Ralf Wildenhues on 11/11/2008 3:02 PM: > > tests/testsuite --list > > > > produces some long lines due to long keyword lists. Should they be > > wrapped? > > Do you know a quick way to make awk wrap text lines? Unfortunately, this > is one place where m4_text_wrap won't work, because the list must be a > single line for -k to work; but since --list already invokes an awk > process, we wouldn't be adding any process complexity if we could just > make that existing awk process do the wrapping.
OK? Works with Solaris awk. Of course once the at_groups_all lines hit 2K characters, we will run into the next issues ('sed' for range arguments, job lists, 'grep' for keyword arguments). Oh well, I guess that should teach users when it's time to split tests into parts, that parallelizes better anyway. Thanks, Ralf Wrap keywords in `testsuite --list' output. * lib/autotest/general.m4 (AT_INIT): Rewrite --list awk script, avoid lint warnings from gawk, wrap keyword lists to stay below 80 characters per line if possible. * tests/autotest.at (Keyword wrapping): New test. diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index d170207..b65a190 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -703,13 +703,33 @@ _ATEOF AS_ECHO(["$at_groups$as_nl$at_help_all"]) | awk 'BEGIN { FS = ";" } NR == 1 { - for (n = split($ 0, a, " "); n; n--) selected[[a[n]]] = 1 + for (n = split ($ 0, a, " "); n; n--) + selected[[a[n]]] = 1 next } - { + NF > 0 { if (selected[[$ 1]]) { printf " %3d: %-18s %s\n", $ 1, $ 2, $ 3 - if ($ 4) printf " %s\n", $ 4 + if ($ 4) { + lmax = 79 + indent = " " + line = indent + len = length (line) + n = split ($ 4, a, " ") + for (i = 1; i <= n; i++) { + l = length (a[[i]]) + 1 + if (i > 1 && len + l > lmax) { + print line + line = indent " " a[[i]] + len = length (line) + } else { + line = line " " a[[i]] + len += l + } + } + if (n) + print line + } } }' || at_write_fail=1 exit $at_write_fail diff --git a/tests/autotest.at b/tests/autotest.at index 18856ec..de3cc3b 100644 --- a/tests/autotest.at +++ b/tests/autotest.at @@ -781,6 +781,34 @@ AT_CHECK_KEYS([--list -k none -k first], [none|first], [2], [second|both], [0]) AT_CLEANUP +## ----------------- ## +## Keyword wrapping. ## +## ----------------- ## +AT_SETUP([Keyword wrapping]) + +AT_CHECK_AT_PREP([k], +[[AT_INIT +AT_SETUP([test]) +AT_KEYWORDS([a1 b1 c1 d1 e1 f1 g1 h1 i1 j1 k1 l1 m1 n1 o1 p1 q1 r1 s1 t1]) +AT_KEYWORDS([u1 v1 w1 x1 y1 z1]) +AT_KEYWORDS([a b c d e f g h i j k l m n o p q r s t u v w x y z]) +AT_CLEANUP +AT_SETUP([test with long keywords]) +AT_KEYWORDS( +[this-is-a-long-keyword-that-cannot-be-wrapped-so-we-exceed-the-length-limit-here]) +# surrounded by short ones +AT_KEYWORDS([s]) +AT_KEYWORDS( +[another-very-long-keyword-that-hits-the-line-length-limit-bla-bla-bla-bla]) +AT_KEYWORDS([t]) +AT_CLEANUP +]]) + +AT_CHECK_KEYS([-l], [.{80}], [1], [.{87}], [0]) + +AT_CLEANUP + + ## ----------------------- ## ## parallel test execution ## ## ----------------------- ##