* tests/atgeneral.m4: Use it.
+2001-01-15 Akim Demaille <akim@epita.fr>
+
+ * sh.m4 (AS_BOX, _AS_BOX_LITERAL, _AS_BOX_INDIR): New.
+ * tests/atgeneral.m4: Use it.
+
2001-01-15 Akim Demaille <akim@epita.fr>
* acgeneral.m4 (AC_VAR_INDIR_IFELSE): Move as...
# over files, the full test suite cleans up both before and after test groups.
if $1 --version | grep "$at_package.*$at_version" >/dev/null; then
- at_banner="Testing suite for $at_package, version $at_version"
- at_dashes=`echo $at_banner | sed s/./=/g`
- echo "$at_dashes"
- echo "$at_banner"
- echo "$at_dashes"
+ AS_BOX([Testing suite for $at_package, version $at_version])
else
- echo '======================================================='
- echo 'ERROR: Not using the proper version, no tests performed'
- echo '======================================================='
+ AS_BOX([ERROR: Not using the proper version, no tests performed])
exit 1
fi
at_banner="ERROR: Suite unsuccessful, $at_fail_count of $at_test_count tests failed"
fi
fi
-at_dashes=`echo $at_banner | sed s/./=/g`
-echo
-echo "$at_dashes"
-echo "$at_banner"
-echo "$at_dashes"
+AS_BOX($at_banner)
if test $at_debug = false && test -n "$at_failed_list"; then
echo
# This section is lexicographically sorted.
+
+# AS_BOX(MESSAGE, [FRAME-CHARACTER = `='])
+# ----------------------------------------
+# Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
+# must not be `/').
+m4_define([AS_BOX],
+[AS_LITERAL_IF([$1],
+ [_AS_BOX_LITERAL($@)],
+ [_AS_BOX_INDIR($@)])])
+
+# _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `='])
+# -------------------------------------------------
+m4_define([_AS_BOX_LITERAL],
+[cat <<\_ASBOX
+m4_patsubst([$1], [.], m4_if([$2], [], [[=]], [[$2]]))
+$1
+m4_patsubst([$1], [.], m4_if([$2], [], [[=]], [[$2]]))
+_ASBOX])
+
+# _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `='])
+# -----------------------------------------------
+m4_define([_AS_BOX_INDIR],
+[sed 'h;s/./m4_default([$2], [=])/g;p;x;p;x' <<_ASBOX
+$1
+_ASBOX])
+
+
# AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
# -----------------------------------------------------
# If EXPRESSION has shell indirections ($var or `expr`), expand
# This section is lexicographically sorted.
+
+# AS_BOX(MESSAGE, [FRAME-CHARACTER = `='])
+# ----------------------------------------
+# Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
+# must not be `/').
+m4_define([AS_BOX],
+[AS_LITERAL_IF([$1],
+ [_AS_BOX_LITERAL($@)],
+ [_AS_BOX_INDIR($@)])])
+
+# _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `='])
+# -------------------------------------------------
+m4_define([_AS_BOX_LITERAL],
+[cat <<\_ASBOX
+m4_patsubst([$1], [.], m4_if([$2], [], [[=]], [[$2]]))
+$1
+m4_patsubst([$1], [.], m4_if([$2], [], [[=]], [[$2]]))
+_ASBOX])
+
+# _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `='])
+# -----------------------------------------------
+m4_define([_AS_BOX_INDIR],
+[sed 'h;s/./m4_default([$2], [=])/g;p;x;p;x' <<_ASBOX
+$1
+_ASBOX])
+
+
# AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
# -----------------------------------------------------
# If EXPRESSION has shell indirections ($var or `expr`), expand
# over files, the full test suite cleans up both before and after test groups.
if $1 --version | grep "$at_package.*$at_version" >/dev/null; then
- at_banner="Testing suite for $at_package, version $at_version"
- at_dashes=`echo $at_banner | sed s/./=/g`
- echo "$at_dashes"
- echo "$at_banner"
- echo "$at_dashes"
+ AS_BOX([Testing suite for $at_package, version $at_version])
else
- echo '======================================================='
- echo 'ERROR: Not using the proper version, no tests performed'
- echo '======================================================='
+ AS_BOX([ERROR: Not using the proper version, no tests performed])
exit 1
fi
at_banner="ERROR: Suite unsuccessful, $at_fail_count of $at_test_count tests failed"
fi
fi
-at_dashes=`echo $at_banner | sed s/./=/g`
-echo
-echo "$at_dashes"
-echo "$at_banner"
-echo "$at_dashes"
+AS_BOX($at_banner)
if test $at_debug = false && test -n "$at_failed_list"; then
echo