[m-rev.] for post-commit review: Fix writing .module_dep files.

Peter Wang novalazy at gmail.com
Mon Mar 1 12:34:22 AEDT 2021


Aside: I still have problems getting the tests/mmc_make/complex_test and
tests/mmc_make/linkage_test tests working under bootcheck.
That whole directory is terrible.

----

compiler/make.module_dep_file.m:
    Write foreign included file names to the .module_dep stream
    instead of the implicit output stream. The bug was introduced in
    commit 5f50259d16c12286261d070f04d66f2ab19ced92.

tests/mmc_make/Mmakefile:
    mmc --make does not set a non-zero exit status even if there were
    problems reading a .module_dep file. Explicitly grep for "error" in
    the mmc --make output in the include_file test that should have
    caught the preceding bug (assuming the workspace is built with
    --use-subdirs).

    grep for "error" in another test case.

diff --git a/compiler/make.module_dep_file.m b/compiler/make.module_dep_file.m
index acb23184e..3e4696f5d 100644
--- a/compiler/make.module_dep_file.m
+++ b/compiler/make.module_dep_file.m
@@ -449,7 +449,7 @@ write_foreign_include_file_info(ForeignInclude, Stream, !IO) :-
     ForeignInclude = foreign_include_file_info(Lang, FileName),
     mercury_output_foreign_language_string(Lang, Stream, !IO),
     io.write_string(Stream, " - ", !IO),
-    term_io.quote_string(FileName, !IO).
+    term_io.quote_string(Stream, FileName, !IO).
 
 :- pred contains_foreign_export_to_string(contains_foreign_export, string).
 :- mode contains_foreign_export_to_string(in, out) is det.
diff --git a/tests/mmc_make/Mmakefile b/tests/mmc_make/Mmakefile
index 56a79ad9a..2d18369e0 100644
--- a/tests/mmc_make/Mmakefile
+++ b/tests/mmc_make/Mmakefile
@@ -43,7 +43,8 @@ complex_test.log: install_libs
 include_file2.runtest: include_file
 	sleep 1 && touch inc/code.c inc/code.java inc/code.cs
 	$(MCM) --verbose-make include_file > include_file2.err 2>&1
-	grep '^Making Mercury/.*/include_file[.]' include_file2.err
+	! grep -qi 'error' include_file2.err && \
+		grep '^Making Mercury/.*/include_file[.]' include_file2.err
 
 linkage_test.log: install_libs_linkage_test2
 
@@ -51,7 +52,8 @@ linkage_test.log: install_libs_linkage_test2
 rebuild.runtest:
 	$(MCM) --rebuild rebuild
 	$(MCM) --rebuild --verbose-make rebuild > rebuild.err2 2>&1
-	grep '^Making rebuild\($$\|\.\)' rebuild.err2
+	! grep -qi 'error' rebuild.err2 && \
+		grep '^Making rebuild\($$\|\.\)' rebuild.err2
 
 # The compiler used to fail when invoked as `mmc --make build_object.o'.
 build_object.runtest: build_object.o
-- 
2.30.0



More information about the reviews mailing list