[m-rev.] for review: Add test case for Mantis bug #489.

Peter Wang novalazy at gmail.com
Tue Jan 14 13:31:37 AEDT 2020


tests/mmc_make/Mmakefile:
tests/mmc_make/bug489.exp:
tests/mmc_make/bug489.m:
tests/mmc_make/bug489.other.m:
tests/mmc_make/lexer.m:
    Add test where a separate sub-module is stored in a source file
    with a name that could be confused for a standard library module.

diff --git a/tests/mmc_make/Mmakefile b/tests/mmc_make/Mmakefile
index 2c7ed5bd9..bc5ef5ab4 100644
--- a/tests/mmc_make/Mmakefile
+++ b/tests/mmc_make/Mmakefile
@@ -11,8 +11,8 @@ MAYBE_J1 =
 
 MMAKE_USE_MMC_MAKE=yes
 
-# Any program added here should also be added to the `.cvsignore' file.
 PROGS =	\
+	bug489 \
 	complex_test \
 	hello \
 	include_file \
@@ -32,6 +32,11 @@ include $(TESTS_DIR)/Mmake.common
 
 %.runtest: %.res ;
 
+Mercury.modules: lexer.m
+	$(MC) -f $^
+
+bug489.log: Mercury.modules
+
 complex_test.log: install_libs
 
 # Check that included files are identified as dependencies of the target code.
@@ -80,5 +85,6 @@ realclean_mmc_make: TESTS_FLAGS
 	# ./TESTS_FLAGS is expected by the following line.
 	cd lib; $(MCM) complex_numbers.realclean linkage_test2.realclean
 	rm -f TESTS_FLAGS
+	rm -f Mercury.modules
 
 #-----------------------------------------------------------------------------#
diff --git a/tests/mmc_make/bug489.exp b/tests/mmc_make/bug489.exp
new file mode 100644
index 000000000..b689819a0
--- /dev/null
+++ b/tests/mmc_make/bug489.exp
@@ -0,0 +1 @@
+tok1
diff --git a/tests/mmc_make/bug489.m b/tests/mmc_make/bug489.m
new file mode 100644
index 000000000..50cf43ef6
--- /dev/null
+++ b/tests/mmc_make/bug489.m
@@ -0,0 +1,24 @@
+%---------------------------------------------------------------------------%
+% vim: ts=4 sw=4 et ft=mercury
+%---------------------------------------------------------------------------%
+%
+% Test that mmc --make can handle a module kept in a source file
+% that could be confused for a standard library module
+% (or other module that whose source file is not available).
+
+:- module bug489.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- include_module lexer.
+:- include_module other.
+:- import_module bug489.lexer.
+
+main(!IO) :-
+    io.write(tok1, !IO),
+    io.nl(!IO).
diff --git a/tests/mmc_make/bug489.other.m b/tests/mmc_make/bug489.other.m
new file mode 100644
index 000000000..7dd498164
--- /dev/null
+++ b/tests/mmc_make/bug489.other.m
@@ -0,0 +1,5 @@
+%---------------------------------------------------------------------------%
+% vim: ts=4 sw=4 et ft=mercury
+%---------------------------------------------------------------------------%
+
+:- module bug489.other.
diff --git a/tests/mmc_make/lexer.m b/tests/mmc_make/lexer.m
new file mode 100644
index 000000000..f55b45316
--- /dev/null
+++ b/tests/mmc_make/lexer.m
@@ -0,0 +1,17 @@
+%---------------------------------------------------------------------------%
+% vim: ts=4 sw=4 et ft=mercury
+%---------------------------------------------------------------------------%
+%
+% This file is deliberately named to potentially be confused for
+% a standard library module.
+
+:- module bug489.lexer.
+:- interface.
+
+:- type token
+    --->    tok1
+    ;       tok2.
+
+:- implementation.
+
+:- import_module bug489.other.
-- 
2.24.1



More information about the reviews mailing list