#
# mrsgui/scripts/mrsgui-svn-retry/Makefile ---
#

SHELL:=/bin/bash
.SUFFIXES:

_default: _test

#####

# We make a copy, as we dont want to replace it on our systems.
/usr/bin/svn-exe:
	sudo cp /usr/bin/svn ${@}

/usr/bin/svn-original:
	sudo cp /usr/bin/svn ${@}

_svn_exe: /usr/bin/svn-exe /usr/bin/svn-original

#####

# return an error if the prior command worked.
expect_fail:=if [[ "$$?" = "0" ]] ; then exit 1 ; else exit 0 ; fi

I279_URL:="https://svn.hbaspecto.com/svn/pecas/PECASAlberta/Scenarios/I279"

svn_retry_cmd:=${PWD}/mrsgui-svn-retry

_test_test_fail:
	false; ${expect_fail}

_test_help:
	${svn_retry_cmd} --help

_test_version:
	${svn_retry_cmd} --version

_test_ls_1:
	${svn_retry_cmd} ls ${I279_URL}

_test_ls_2:
	${svn_retry_cmd} ls "http://bogus url:9999/"; ${expect_fail}

./test-I279-2080:
	${svn_retry_cmd} checkout ${I279_URL}/2080 "${@}"

# Tell it to use "false" which will fail
_test_update_fail_1: ./test-I279-2080
	(cd ./test-I279-2080 && \
	  SVN_RETRY_SVN_EXE=/bin/false ${svn_retry_cmd} update) ; ${expect_fail}

# A update which should work
_test_update_ok_1: | ./test-2080
	cd ./test-2080 && \
	  ${svn_retry_cmd} update

#####

_test+=_test_test_fail
#
_test+=_test_help
_test+=_test_version
_test+=_test_ls_1
_test+=_test_ls_2
#
_test+=_test_update_fail_1
_test+=_test_update_ok_1

_test: ${_test}


#####

zip_date:=$(shell date +%Y%m%d)
zip_base:=mrsgui-svn-retry-${zip_date}

_zip_make:
	cd .. && \
	  rm -f ${zip_base} ${zip_base}.zip && \
	  ln -s mrsgui-svn-retry ${zip_base} && \
	  zip ${zip_base}.zip \
	    ${zip_base}/{README.rst,Makefile,hba-setup.env,mrsgui-svn-retry} && \
	  rm ${zip_base} && \
	  zipinfo ${zip_base}.zip

_zip_copy_to_www:
	scp ../${zip_base}.zip \
	  root@whitemud:/nfs/www/files-hbaspecto-com/public
