################################################################################
#
# src_test.cygpart - cygport source testing functions
#
# Copyright (C) 2006-2020 Cygport authors
# Provided by the Cygwin project <https://cygwin.com/>
#
# cygport is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cygport is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cygport.  If not, see <https://www.gnu.org/licenses/>.
#
################################################################################

#****** Chapter 9/Testing
#****

#****T* Testing/cygtest
#  SYNOPSIS
#  cd $B
#  cygtest
#  DESCRIPTION
#  Runs the package testsuite with 'make check' or 'make test'.
#****
cygtest() {
	if [ -e Makefile -o -e GNUmakefile -o -e makefile ]
	then
		if make -n check &> /dev/null
		then
			make -k check
		elif make -n test &> /dev/null
		then
			make -k test
		else
			inform "No testsuite detected.";
		fi
	else
		inform "No testsuite detected.";
	fi
}

#****T* Testing/src_test
#  DESCRIPTION
#  This function is to be defined in the .cygport file, listing all steps
#  necessary to run the package's test suite, if any.
#
#  The default src_test function is shown below. A few cygclasses provide
#  their own src_test overrides.
#  DEFINITION
src_test() {
	cd ${B}
	cygtest
}
#****

readonly -f cygtest
