# $Id: Makefile.am 6745 2015-11-01 19:18:52Z gavin $
# Makefile.am for texinfo/tp/tests.
# Copyright 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# autogenerated list of scripts that only run one test, and lists of 
# tests-parser.txt files specifying the tests to run.
include $(srcdir)/Makefile.onetst

$(srcdir)/Makefile.onetst: \
  ../maintain/regenerate_cmd_tests.sh $(test_driving_files_generated_list)
	cd $(srcdir) \
	&& $(SHELL) ../maintain/regenerate_cmd_tests.sh "$@" . \
	  -base '$(base_tests)' \
	  -long '$(long_tests)' \
	  -tex_html '$(tex_html_tests)'

base_tests = formatting 
long_tests = sectioning coverage indices nested_formats contents layout
tex_html_tests = tex_html

test_subdirs = htmlxref htmlxref-only_mono htmlxref-only_split

DIST_SUBDIRS = many_input_files $(test_subdirs) $(base_tests) $(long_tests) $(tex_html_tests)
SUBDIRS = . many_input_files $(test_subdirs)

copy-tests: copy-base copy-long
	cd many_input_files && $(MAKE) copy-tests
	for dir in $(test_subdirs); do (cd $$dir && $(MAKE) copy-tests); done

copy-base:
	$(srcdir)/parser_tests.sh -copy $(base_tests)

copy-long:
	$(srcdir)/parser_tests.sh -copy $(long_tests)

copy-tex-html:
	$(srcdir)/parser_tests.sh -copy $(tex_html_tests)
	cd many_input_files && $(MAKE) copy-tex-html

clean-tests:
	$(srcdir)/parser_tests.sh -clean $(base_tests) $(long_tests) $(tex_html_tests)

other_tests = \
	t/stdout.sh \
	t/stdout_split.sh

TESTS = $(one_test_files_generated_list) $(other_tests)

AM_TESTS_ENVIRONMENT = srcdir="$(srcdir)"; export srcdir; top_srcdir="$(top_srcdir)"; export top_srcdir; builddir="$(builddir)"; export buildir; top_builddir="$(top_builddir)"; export top_builddir;

long-checks long-check: all
	$(MAKE) $(AM_MAKEFLAGS) check LONG_TESTS=yes

all-checks all-check: all
	$(MAKE) $(AM_MAKEFLAGS) check ALL_TESTS=yes

tex-html-checks tex-html-check: all
	$(MAKE) $(AM_MAKEFLAGS) check TEX_HTML_TESTS=yes LONG_TESTS=yes

# this is in order to have the htmlxref.cnf files in the build dir.
# This is done in this directory to be sure that the files are there
# when check is done in this directory.
# Some files are in 2 directories in order to get the same result
# in both test run locations.
all-local: htmlxref/htmlxref.cnf htmlxref-only_mono/htmlxref.cnf \
 htmlxref-only_split/htmlxref.cnf htmlxref-only_split/.texinfo/htmlxref.cnf \
 equivalent_nodes-noderename.cnf sectioning/equivalent_nodes-noderename.cnf \
 unknown_nodes_renamed-noderename.cnf \
 formatting/unknown_nodes_renamed-noderename.cnf coverage_macro-cr.texi

htmlxref/htmlxref.cnf: htmlxref/htmlxref.cnf-ref
	${INSTALL_DATA} $(srcdir)/htmlxref/htmlxref.cnf-ref $@

htmlxref-only_mono/htmlxref.cnf: htmlxref-only_mono/htmlxref.cnf-ref
	${INSTALL_DATA} $(srcdir)/htmlxref-only_mono/htmlxref.cnf-ref $@

htmlxref-only_split/htmlxref.cnf: htmlxref-only_split/htmlxref.cnf-ref
	${INSTALL_DATA} $(srcdir)/htmlxref-only_split/htmlxref.cnf-ref $@

htmlxref-only_split/.texinfo/htmlxref.cnf: \
 htmlxref-only_split/htmlxref.cnf-texinfo htmlxref-only_split/.texinfo
	${INSTALL_DATA} $(srcdir)/htmlxref-only_split/htmlxref.cnf-texinfo $@

htmlxref-only_split/.texinfo:
	$(MKDIR_P) $@

sectioning/equivalent_nodes-noderename.cnf: sectioning/renamednodes.cnf-ref
	${INSTALL_DATA} $(srcdir)/sectioning/renamednodes.cnf-ref $@

equivalent_nodes-noderename.cnf: sectioning/renamednodes.cnf-ref
	${INSTALL_DATA} $(srcdir)/sectioning/renamednodes.cnf-ref $@

formatting/unknown_nodes_renamed-noderename.cnf: formatting/unknown_nodes_renamed-noderename.cnf-ref
	${INSTALL_DATA} $(srcdir)/formatting/unknown_nodes_renamed-noderename.cnf-ref $@

unknown_nodes_renamed-noderename.cnf: formatting/unknown_nodes_renamed-noderename.cnf-ref
	${INSTALL_DATA} $(srcdir)/formatting/unknown_nodes_renamed-noderename.cnf-ref $@

coverage_macro-cr.texi: coverage_macro.texi
	sed 's/$$/\r/' $(srcdir)/coverage_macro.texi > $@

old_test_scripts = parser_base_tests long_tests.sh tex_html_tests.sh
EXTRA_DIST = run_parser_all.sh parser_tests.sh \
 $(old_test_scripts) $(one_test_files_generated_list) coverage_macro.texi \
 coverage_macro-cr.texi $(other_tests) reference

DISTCLEANFILES = unknown_nodes_renamed-noderename.cnf \
 equivalent_nodes-noderename.cnf

dist-hook:
	rm -rf `find $(distdir)/reference -name .svn`
