#-----------------------------------------------------------------------------#
# vim: ts=8 sw=8 noexpandtab ft=make
#-----------------------------------------------------------------------------#

TESTS_DIR = ..
THIS_DIR = invalid_make_int
# One test, sub_c, uses nested submodules, which requires -j1.
# The loss of parallelism has a performance impact, but due to the
# small number of test cases in this directory, this impact is small.
MAYBE_J1 = -j1

# Note: multi-module tests are listed separately from single-module tests
# because we need to make dependencies, and make .int3 files for the
# other modules, only for multi-module tests.
#
# Multi-module tests should use *separate* modules, not *nested* modules.

SINGLE_MODULE_PROGS = \
	bad_detism_category \
	bad_end_module \
	bad_existential_data_type \
	bad_finalise_decl_int \
	bad_foreign_type_int \
	bad_in_interface \
	bad_initialise_decl_int \
	bad_instance \
	bad_mutable_int \
	bad_tscp \
	bad_type_class_constraint_intermodule \
	bug17 \
	bug499 \
	bug521 \
	builtin_int \
	instance_no_type \
	missing_initial_section \
	missing_interface_import \
	pragma_export_int \
	redundant_import \
	test_type_spec_int \
	type_arity \
	type_vars_int \
	unbalanced \
	unbound_type_vars_int \
	undef_inst \
	undef_mode \
	undef_type_int \
	undef_type_mod_qual \
	unicode_1 \
	unicode_2

MULTI_MODULE_PROGS = \
	int_impl_imports \
	missing_interface_import_test_2 \
	sub_c \
	test_nested \
	transitive_import

# While the following tests were in ../invalid, they were included among
# the modules listed in the definition of the REDIRECT_OPT_ERROR_MODULES
# make variable. However, they seem to be working just fine when moved
# to this directory, which has no such list.
#
# 	bad_type_class_constraint_intermodule
# 	bug521_sub
#	int_impl_imports

#-----------------------------------------------------------------------------#

PROGS = $(SINGLE_MODULE_PROGS) $(MULTI_MODULE_PROGS)
# Note that the "-nodepend" part is a bit of a lie for the MULTI_MODULE_PROGS
# part of PROGS, because the rule for the .int_err files of MULTI_MODULE_PROGS
# *does* make the dependencies, though in a more controlled manner.
TESTS = $(sort $(PROGS:%=%-nodepend))
include ../Mmake.common

# Module-specific options should go in Mercury.options so they can be found
# by `mmc --make'.
include Mercury.options

MCFLAGS += --color-diagnostics

%.runtest: %.int_err_res ;

#-----------------------------------------------------------------------------#

$(SINGLE_MODULE_PROGS:%=%.int_err): %.int_err: %.m
	if $(MC) --make-interface $(ALL_GRADEFLAGS) $(ALL_MCFLAGS) $* \
		> $*.int_err 2>&1; \
	then false; \
	else true; \
	fi

$(MULTI_MODULE_PROGS:%=%.int_err): %.int_err: %.m
	+mmake $*.depend
	+mmake $*.all_int3s
	if MERCURY_NO_PATHS_IN_CANNOT_FIND_MSG=true \
		$(MC) --make-interface $(ALL_GRADEFLAGS) $(ALL_MCFLAGS) $* \
		> $*.int_err 2>&1; \
	then false; \
	else true; \
	fi

clean_local: clean_invalid

clean_invalid:
	rm -f *.dep_err *.err *.int3 *.int2 *.int *.int_err *.int_err_res*

#-----------------------------------------------------------------------------#
