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

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"

_test_test_fail:
	false; ${expect_fail}

_test_help:
	./svn-retry --help

_test_version:
	./svn-retry --version

_test_ls_1:
	./svn-retry ls ${I279_URL}

_test_ls_2:
	./svn-retry ls "bogus url"; ${expect_fail}

./test-2080:
	./svn-retry checkout ${I279_URL}/2080 "${@}"

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

# A update which should work
_test_update_ok_1: | ./test-2080
	cd ./test-2080 && \
	  ../svn-retry 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_file:=svn-retry-${zip_date}.zip

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

_zip_copy_to_www:
	scp ../${zip_file} \
	  whitemud:/nfs/www/files-hbaspecto-com/public
