+2000-11-23 Akim Demaille <akim@epita.fr>
+
+ * m4sugar.m4 (m4_divert, m4_undivert): Support named diversions.
+ * tests/atgeneral.m4 (_m4_divert(SUITE_PRO), _m4_divert(TESTS))
+ (_m4_divert(SUITE_EPI), _m4_divert(TEST)): New diversions.
+ Push the first two diversions.
+ (AT_INIT): Don't.
+ (AT_INIT, AT_SETUP, AT_CLEANUP): Adjust to use the named
+ diversions.
+
2000-11-23 Akim Demaille <akim@epita.fr>
* tests/atgeneral.m4 (AT_CLEANUP): Factor the computation of
# Use of diversions:
-# 0 - overall initialization; for each test group: skipping and cleanups;
-# 2 - for each test group: proper code, to reinsert between cleanups;
-# 3 - overall wrap up: generation of debugging scripts and statistics.
+#
+# - SUITE_PRO
+# overall initialization
+# - TESTS
+# The core of the test suite, the ``normal'' diversion.
+# - SUITE_EPI
+# tail of the core for;case, overall wrap up, generation of debugging
+# scripts and statistics.
+#
+# - TEST
+# for each test group: proper code, to reinsert between cleanups;
+# undiverted into TESTS once at_data_files diverted.
+
+m4_define([_m4_divert(SUITE_PRO)], 0)
+m4_define([_m4_divert(TESTS)], 10)
+m4_define([_m4_divert(SUITE_EPI)], 20)
+
+m4_define([_m4_divert(TEST)], 100)
+
+m4_divert_push([TESTS])
+m4_divert_push([KILL])
# AT_LINE
# Begin testing suite, using PROGRAM to check version. The search path
# should be already preset so the proper executable will be selected.
AT_DEFINE([AT_INIT],
-[m4_divert_push(0)dnl
+[m4_divert_push([SUITE_PRO])dnl
AT_DEFINE([AT_ordinal], 0)
. ./atconfig
# -e sets to true
at_failed_list=
at_ignore_count=0
at_test_count=0
-m4_divert_push(1)dnl
+m4_divert([TESTS])dnl
: ${tests="$TESTS"}
for test in $tests
do
at_status=0;
case $test in
-m4_divert_pop[]dnl
-m4_divert_push(3)[]dnl
+m4_divert([SUITE_EPI])[]dnl
esac
at_test_count=`expr 1 + $at_test_count`
$at_verbose $at_n " $test. $srcdir/`cat at-setup-line`: $at_c"
exit 0
m4_divert_pop()dnl
-m4_divert_push(1)dnl
-m4_divert_push([KILL])dnl
-m4_wrap([m4_divert_text(0,
+m4_wrap([m4_divert_text([SUITE_PRO],
[TESTS="m4_for([i], 1, AT_ordinal, 1, [i ])"])])dnl
])# AT_INIT
AT_DEFINE([AT_SETUP],
[AT_DEFINE([AT_ordinal], m4_eval(AT_ordinal + 1))
m4_pushdef([AT_data_files], [stdout stderr ])
-m4_divert_pop()dnl
+m4_divert_push([TESTS])dnl
AT_ordinal )
dnl Here will be inserted the definition of at_data_files.
-m4_divert(2)[]dnl
+m4_divert([TEST])[]dnl
rm -rf $at_data_files
echo AT_LINE > at-setup-line
$at_verbose 'testing $1'
)
at_status=$?
;;
-m4_divert(1)[]dnl
+m4_divert([TESTS])[]dnl
at_data_files="AT_data_files"
-m4_undivert(2)[]dnl
+m4_undivert([TEST])[]dnl
m4_popdef([AT_data_files])dnl
-m4_divert_push([KILL])dnl
+m4_divert_pop()dnl
])# AT_CLEANUP
m4_rename_m4([debugfile])
m4_rename_m4([debugmode])
m4_rename_m4([decr])
-m4_rename_m4([divert])
+m4_undefine([divert])
m4_rename_m4([dumpdef])
m4_rename_m4([eval])
m4_rename_m4([format])
m4_rename_m4([traceoff])
m4_rename_m4([traceon])
m4_rename_m4([translit])
-m4_rename_m4([undivert])
+m4_undefine([undivert])
## ------------------- ##
m4_define([_m4_divert(KILL)], -1)
+# m4_divert(DIVERSION-NAME)
+# -------------------------
+# Change the diversion stream to DIVERSION-NAME.
+m4_define([m4_divert],
+[m4_builtin([divert], _m4_divert([$1]))dnl
+])
+
+
+# m4_undivert(DIVERSION-NAME)
+# ---------------------------
+# Undivert DIVERSION-NAME.
+m4_define([m4_undivert],
+[m4_builtin([undivert], _m4_divert([$1]))dnl
+])
+
+
# m4_divert_push(DIVERSION-NAME)
# ------------------------------
# Change the diversion stream to DIVERSION-NAME, while stacking old values.
m4_rename_m4([debugfile])
m4_rename_m4([debugmode])
m4_rename_m4([decr])
-m4_rename_m4([divert])
+m4_undefine([divert])
m4_rename_m4([dumpdef])
m4_rename_m4([eval])
m4_rename_m4([format])
m4_rename_m4([traceoff])
m4_rename_m4([traceon])
m4_rename_m4([translit])
-m4_rename_m4([undivert])
+m4_undefine([undivert])
## ------------------- ##
m4_define([_m4_divert(KILL)], -1)
+# m4_divert(DIVERSION-NAME)
+# -------------------------
+# Change the diversion stream to DIVERSION-NAME.
+m4_define([m4_divert],
+[m4_builtin([divert], _m4_divert([$1]))dnl
+])
+
+
+# m4_undivert(DIVERSION-NAME)
+# ---------------------------
+# Undivert DIVERSION-NAME.
+m4_define([m4_undivert],
+[m4_builtin([undivert], _m4_divert([$1]))dnl
+])
+
+
# m4_divert_push(DIVERSION-NAME)
# ------------------------------
# Change the diversion stream to DIVERSION-NAME, while stacking old values.
# Use of diversions:
-# 0 - overall initialization; for each test group: skipping and cleanups;
-# 2 - for each test group: proper code, to reinsert between cleanups;
-# 3 - overall wrap up: generation of debugging scripts and statistics.
+#
+# - SUITE_PRO
+# overall initialization
+# - TESTS
+# The core of the test suite, the ``normal'' diversion.
+# - SUITE_EPI
+# tail of the core for;case, overall wrap up, generation of debugging
+# scripts and statistics.
+#
+# - TEST
+# for each test group: proper code, to reinsert between cleanups;
+# undiverted into TESTS once at_data_files diverted.
+
+m4_define([_m4_divert(SUITE_PRO)], 0)
+m4_define([_m4_divert(TESTS)], 10)
+m4_define([_m4_divert(SUITE_EPI)], 20)
+
+m4_define([_m4_divert(TEST)], 100)
+
+m4_divert_push([TESTS])
+m4_divert_push([KILL])
# AT_LINE
# Begin testing suite, using PROGRAM to check version. The search path
# should be already preset so the proper executable will be selected.
AT_DEFINE([AT_INIT],
-[m4_divert_push(0)dnl
+[m4_divert_push([SUITE_PRO])dnl
AT_DEFINE([AT_ordinal], 0)
. ./atconfig
# -e sets to true
at_failed_list=
at_ignore_count=0
at_test_count=0
-m4_divert_push(1)dnl
+m4_divert([TESTS])dnl
: ${tests="$TESTS"}
for test in $tests
do
at_status=0;
case $test in
-m4_divert_pop[]dnl
-m4_divert_push(3)[]dnl
+m4_divert([SUITE_EPI])[]dnl
esac
at_test_count=`expr 1 + $at_test_count`
$at_verbose $at_n " $test. $srcdir/`cat at-setup-line`: $at_c"
exit 0
m4_divert_pop()dnl
-m4_divert_push(1)dnl
-m4_divert_push([KILL])dnl
-m4_wrap([m4_divert_text(0,
+m4_wrap([m4_divert_text([SUITE_PRO],
[TESTS="m4_for([i], 1, AT_ordinal, 1, [i ])"])])dnl
])# AT_INIT
AT_DEFINE([AT_SETUP],
[AT_DEFINE([AT_ordinal], m4_eval(AT_ordinal + 1))
m4_pushdef([AT_data_files], [stdout stderr ])
-m4_divert_pop()dnl
+m4_divert_push([TESTS])dnl
AT_ordinal )
dnl Here will be inserted the definition of at_data_files.
-m4_divert(2)[]dnl
+m4_divert([TEST])[]dnl
rm -rf $at_data_files
echo AT_LINE > at-setup-line
$at_verbose 'testing $1'
)
at_status=$?
;;
-m4_divert(1)[]dnl
+m4_divert([TESTS])[]dnl
at_data_files="AT_data_files"
-m4_undivert(2)[]dnl
+m4_undivert([TEST])[]dnl
m4_popdef([AT_data_files])dnl
-m4_divert_push([KILL])dnl
+m4_divert_pop()dnl
])# AT_CLEANUP