Simplify the setup of mdbrc for tests.

We used to set up *two* mdbrc files for use by test cases:
scripts/test_mdbrc, and tests/mdbrc. Tools/bootcheck said
the tests should use the former, while tests/Mmake.common
said they should use the latter. This diff deletes the latter,
and uniformly uses the former.

The setup code was also scattered, with parts being done by
the configure script, and part being done by tools/bootcheck.
Move it all to scripts/Mmakefile, since that is the natural
place to put code to build scripts/test_mdbrc.

Mmakefile:
    Fix the action for cleaning up the tests directory.
    This started out as the reason for this whole change.
    As it happens, a *working* action for cleaning up the tests
    broke things, because it deleted an autoconfigured file
    (tests/mdbrc) that there was no rule for rebuilding.
    This issue is what required the rest of this diff.

    When doing "mmake clean/realclean", clean the extras as well.

configure.ac:
    Delete the code creating tests/mdbrc.in.

scripts/Mmakefile:
    Add a rule to build test_mdbrc, as mentioned above.

tests/Mmake.common:
    Switch to using scripts/test_mdbrc in test cases
    run under mdb.

    Mark the rules that clean up mdbrc and mdbrc.in
    as obsolete, since we will now stop creating those files.

tools/bootcheck:
    Delete the code that used to build tests/mdbrc. Instead,
    rebuild scripts/test_mdbrc (in case the workspace was moved),
    and use that.

tests/Mmakefile:
    When cleaning the tests directory, clean its subdirectories
    (since the top level directory does not have much clean).
This commit is contained in:
Zoltan Somogyi
2020-10-04 23:00:29 +11:00
parent 0d59d6faef
commit be3f9443b1
6 changed files with 76 additions and 61 deletions

View File

@@ -53,7 +53,7 @@ SUBDIRS = \
MMAKEFLAGS =
# We include ../../mfilterjavac in this path because $SUBDIR_MMAKE is used
# We include ../../mfilterjavac in this path because $(SUBDIR_MMAKE) is used
# from the grade install directories, and we need mfilterjavac in our path
# when executing in install_grade_dir.java/library and others.
SUBDIR_MMAKE = \
@@ -612,7 +612,7 @@ tar2: $(GENERATED_DOCS)
chmod -R a+r *
# Our invoker should have passed to us in ${SRCDIST_NAME}
# the name of the current directory in its parent directory.
# This name should have the form mercury-srcdist-$VERSION,
# This name should have the form mercury-srcdist-$(VERSION),
# which matters, because it will also be the name of the directory
# that the tar file we are creating here will unpack into.
#
@@ -929,7 +929,7 @@ bindist: WORK_IN_PROGRESS TODO
#-----------------------------------------------------------------------------#
clean: clean_tests clean_subdirs
clean: clean_tests clean_subdirs clean_extras
.PHONY: clean_subdirs
clean_subdirs:
@@ -941,14 +941,20 @@ clean_subdirs:
.PHONY: clean_tests
clean_tests:
+if test -d tests; then \
(cd tests; $(SUBDIR_MMAKE) clean) \
(cd tests; $(MMAKE) $(MMAKEFLAGS) clean) \
fi
realclean: realclean_tests realclean_subdirs realclean_local
+cd scripts; $(SUBDIR_MMAKE) realclean
.PHONY: clean_extras
clean_extras:
+if test -d extras; then \
(cd extras; $(MMAKE) $(MMAKEFLAGS) clean) \
fi
.PHONY: realclean_local
realclean_local: realclean_config realclean_docs
realclean_local: realclean_config realclean_docs realclean_extras
.PHONY: realclean_subdirs
realclean_subdirs: clean_subdirs
@@ -970,7 +976,13 @@ realclean_config:
.PHONY: realclean_tests
realclean_tests:
+if test -d tests; then \
(cd tests; $(SUBDIR_MMAKE) realclean) \
(cd tests; $(MMAKE) $(MMAKEFLAGS) realclean) \
fi
.PHONY: realclean_extras
realclean_extras:
+if test -d extras; then \
(cd extras; $(MMAKE) $(MMAKEFLAGS) realclean) \
fi
#-----------------------------------------------------------------------------#

View File

@@ -5677,17 +5677,6 @@ AC_SUBST(CSHPATH)
#-----------------------------------------------------------------------------#
# When running the debugger tests we want to use the local mdbrc file,
# not the installed one, so that we can test changes to this file
# without having to install first. We therefore create a copy of the mdbrc.in
# for use with the test suite.
test_mdbrc=tests/mdbrc
cat "`pwd`"/scripts/mdbrc.in | sed \
-e 's/DEFAULT_MERCURY_DEBUGGER_INIT_DIR/TESTS_MDB_INIT_DIR/g' \
-e 's/DEFAULT_MERCURY_DEBUGGER_DOC/TESTS_MDB_DOC/g' > $test_mdbrc.in
TESTS_MDB_INIT_DIR="`pwd`"/scripts
TESTS_MDB_DOC="`pwd`"/doc/mdb_doc
AC_SUBST(TESTS_MDB_INIT_DIR)
@@ -5774,7 +5763,6 @@ output_files="$nonexecutable_output_files $executable_output_files"
# scripts/mercury_config.in.
AC_OUTPUT($output_files
"$test_mdbrc"
,
[
# Only do this when compiling the source, not when reconfiguring

View File

@@ -51,7 +51,8 @@ CONF_FILES = \
CONF_DEBUG_SCRIPTS = \
mdbrc
DEBUGGER_SCRIPTS = $(CONF_DEBUG_SCRIPTS) \
DEBUGGER_SCRIPTS = \
$(CONF_DEBUG_SCRIPTS) \
xul_tree.xsl \
mdb_open \
mdb_grep \
@@ -78,7 +79,7 @@ CSHARP_WRAPPER_SCRIPTS = \
# .SUFFIXES: .in
# we test membership of CONF_SCRIPTS and CONF_FILES, because testing $(@D)
# We test membership of CONF_SCRIPTS and CONF_FILES, because testing $(@D)
# (the directory part of $*) does the wrong thing for Mercury.config.
# Not testing anything would make this rule apply even to ../Mmake.common.
# The grep is there to ensure that there were no mispelt autoconf variable
@@ -105,10 +106,30 @@ CSHARP_WRAPPER_SCRIPTS = \
fi \
done
# To allow a change to the debugger and/or to its documentation to be
# matched by changes in the expected output files in the debugger and
# declarative_debugger test directories, we must give the tests in those
# directories access to mdb_doc and mdbrc files in the current workspace,
# *not* in the installed system.
test_mdbrc: mdbrc.in mdbrc
ABS_MERCURY_DIR=`(cd $(MERCURY_DIR); /bin/pwd)` ; \
sed \
-e "s:@DEFAULT_MERCURY_DEBUGGER_DOC@:$${ABS_MERCURY_DIR}/doc/mdb_doc:" \
-e "s:@DEFAULT_MERCURY_DEBUGGER_INIT_DIR@:$${ABS_MERCURY_DIR}/scripts:" \
-e '/^xml_/d' \
-e '/^web_/d' \
< mdbrc.in > test_mdbrc
egrep '^xml_' < mdbrc >> test_mdbrc
egrep '^web_' < mdbrc >> test_mdbrc
@if grep '@' test_mdbrc; then \
echo "unhandled configuration variable in test_mdbrc"; \
exit 1; \
fi
#-----------------------------------------------------------------------------#
.PHONY: all
all: $(CONF_FILES) $(SCRIPTS) $(DEBUGGER_SCRIPTS) $(EMACS_SCRIPTS)
all: $(CONF_FILES) $(SCRIPTS) $(DEBUGGER_SCRIPTS) $(EMACS_SCRIPTS) test_mdbrc
#-----------------------------------------------------------------------------#
@@ -171,11 +192,9 @@ install_config: Mercury.config install_dirs
.PHONY: install_debugger_scripts
install_debugger_scripts: $(DEBUGGER_SCRIPTS) install_dirs
# Reportedly old versions of Mercury
# used to install mdbrc as read-only.
# If that is the case, then we need to make sure
# that it gets made writable before we install the
# new version.
# Reportedly old versions of Mercury used to install mdbrc
# as read-only. If that is the case, then we need to make sure
# that it gets made writable before we install the new version.
-chmod u+w $(INSTALL_LIBDIR)/mdb/*
cp $(DEBUGGER_SCRIPTS) $(INSTALL_LIBDIR)/mdb

View File

@@ -82,7 +82,7 @@ JAVA=java
# the source of irrelevant difference between the actual and expected outputs.
MDB = HOME=/nonexistent MERCURY_SUPPRESS_MDB_BANNER=yes \
MERCURY_DEBUGGER_INIT=$(TESTS_DIR)/mdbrc mdb
MERCURY_DEBUGGER_INIT=$(WORKSPACE)/scripts/test_mdbrc mdb
MDB_NOINIT = HOME=/nonexistent MERCURY_SUPPRESS_MDB_BANNER=yes \
MERCURY_DEBUGGER_INIT="" mdb
@@ -274,6 +274,10 @@ realclean_local: clean_logs clean_errors clean_mdbrc
clean_local: clean_out clean_res clean_trace_counts clean_mdbrc_in
# XXX As of 2020 oct 4, mdbrc and mdbrc.in are no longer created
# in this directory. After a few weeks, after all workspaces can be
# expected to be cleaned up, we should delete these two now-redundant
# targets, and the references to them.
clean_mdbrc:
-rm -f mdbrc

View File

@@ -91,6 +91,10 @@ $(RUNTESTS_IN_SUBDIRS): runtests_in_%:
echo Could not run tests in directory $* >> NOMAKE_DIRS ; \
fi
#-----------------------------------------------------------------------------#
realclean: realclean_subdirs
realclean_subdirs:
+succeeded=true; \
for dir in $(SUBDIRS); do \
@@ -102,6 +106,8 @@ realclean_subdirs:
;; \
esac
clean: clean_subdirs
clean_subdirs:
+succeeded=true; \
for dir in $(SUBDIRS); do \
@@ -112,3 +118,5 @@ clean_subdirs:
exit 1 \
;; \
esac
#-----------------------------------------------------------------------------#

View File

@@ -1912,30 +1912,14 @@ if ${runtests}
then
echo "starting the test suite at `date`"
# We need to give tests/debugger access to the mdbrc and mdb_doc
# files in the doc and scripts directories, without hardcoding their
# pathnames. We must also compensate for scripts/mdbrc having hardcoded
# within it the *installed* pathname of mdb_doc and not its current
# pathname.
cat ${root}/doc/mdb_doc > ${root}/scripts/test_mdbrc
sed -e '/^source/d' ${root}/scripts/mdbrc >> ${root}/scripts/test_mdbrc
# If the workspace has been moved since ${root}/scripts/test_mdbrc
# was last built, that file will refer to the OLD location of
# the workspace, which may not exist anymore. We therefore rebuild
# the file.
(cd =${root}/scripts; /bin/rm test_mdbrc; mmake test_mdbrc)
MERCURY_DEBUGGER_INIT=${root}/scripts/test_mdbrc
export MERCURY_DEBUGGER_INIT
# If the workspace has been copied or moved since ${root}/tests/mdbrc
# has been created by an invocation of ${root}/configure, the
# ${root}/tests/mdbrc file will refer to the mdb_doc file in the OLD
# location of the workspace, which may not exist anymore.
# Override the settings in tests/mdbrc that refer to the current
# directory; keep the xml settings, which do not do so.
sed \
-e "s:@TESTS_MDB_DOC@:${root}/doc/mdb_doc:" \
-e "s:@TESTS_MDB_INIT_DIR@:${root}/scripts:" \
-e "/^xml_/d" \
< "${root}/tests/mdbrc.in" > "${root}/tests/mdbrc.tmp"
grep '^xml_' < "${root}/tests/mdbrc" >> "${root}/tests/mdbrc.tmp"
mv "${root}/tests/mdbrc.tmp" "${root}/tests/mdbrc"
MERCURY_SUPPRESS_STACK_TRACE=yes
export MERCURY_SUPPRESS_STACK_TRACE