diff --git a/python.make b/python.make index 50903e7..8d1afa7 100644 --- a/python.make +++ b/python.make @@ -99,15 +99,23 @@ $(PYTHON_CACHE_DIR)/virtualenv-$(VIRTUALENV_VERSION).tar.gz: mkdir -p $(PYTHON_CACHE_DIR); cd $(PYTHON_CACHE_DIR); curl -L --remote-name $(VIRTUALENV_URL); -# Eliminate the error message: "make: *** No rule to make target `..'. Stop." # Only when the first goal is python-pip or python-exec. # TODO: Maybe we can apply to all python-* goals. -# XXX: if the goal is an existing file, will show the message: "make: `existing.json' is up to date." ifneq (,$(filter $(firstword $(MAKECMDGOALS)),python-pip python-exec python-module)) +# Eliminate the error message: "make: *** No rule to make target `..'. Stop." +# XXX: if the goal is an existing file, will show the message: "make: `existing.json' is up to date." %:: @:; + +define PYTHON_DISABLE_TARGETS +.PHONY: $(1) +$(1): + @:; +endef +$(foreach t,$(filter-out python-pip,$(MAKECMDGOALS)),$(eval $(call PYTHON_DISABLE_TARGETS,$(t)))) endif + # XXX: Need to use `make python-exec -- --version` to specify options to python programs. .PHONY: python-exec python-exec: COMMAND := $(filter-out python-exec,$(MAKECMDGOALS)) diff --git a/tests/GNUmakefile b/tests/GNUmakefile index fabb7ec..c8f4cef 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -16,8 +16,9 @@ distclean: clean rm -rf shunit2-$(SHUNIT2_VERSION).zip; .PHONY: test +test: export PYTHON_CACHE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))).cache test: prepare-shunit2 - ./runtime_test.sh + LIB_DIR=shunit2/lib shunit2/test_runner -s /bin/bash # --------------------------------------------------------------------------- @@ -27,14 +28,8 @@ SHUNIT2_URL = https://github.com/kward/shunit2/archive/v$(SHUNIT2_VERSION).z .PHONY: prepare-shunit2 prepare-shunit2: shunit2 -shunit2: shunit2-$(SHUNIT2_VERSION) - ln -sf shunit2-$(SHUNIT2_VERSION) shunit2; - -shunit2-$(SHUNIT2_VERSION): shunit2-$(SHUNIT2_VERSION).zip +shunit2: + wget --content-disposition $(SHUNIT2_URL); # will download shunit2-$(SHUNIT2_VERSION).zip unzip -q shunit2-$(SHUNIT2_VERSION).zip; - -shunit2-$(SHUNIT2_VERSION).zip: - wget --content-disposition $(SHUNIT2_URL) # will download shunit2-$(SHUNIT2_VERSION).zip -# tar -xf $(TOP_3RDPARTY_DIR)/shunit2-2.1.5.tgz; -# ( cd shunit2-*; patch -p0 < $(TOP_3RDPARTY_DIR)/shunit2-xml.patch; ) + ln -sf shunit2-$(SHUNIT2_VERSION) shunit2; diff --git a/tests/pip_test.sh b/tests/pip_test.sh new file mode 100755 index 0000000..2f1d563 --- /dev/null +++ b/tests/pip_test.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +test_pip_search_ralc_not_target() { + workdir=`mktemp -d tmp.${FUNCNAME[0]}.XXX`; # $workdir will be available globally + cp ../python.make $workdir/; + echo "include python.make" > $workdir/GNUmakefile; + pushd $workdir; + + make python-runtime + make python-pip search ralc + assertTrue "ralc file shall not be created" "[ ! -f ralc ]"; + + popd + rm -rf $workdir; +} + +test_pip_search_ralc_is_target() { + workdir=`mktemp -d tmp.${FUNCNAME[0]}.XXX`; # $workdir will be available globally + cp ../python.make $workdir/; + echo " +ralc: + touch \$@ + +include python.make +" > $workdir/GNUmakefile; + pushd $workdir; + + make python-runtime + make python-pip search ralc + assertTrue "ralc file shall not be created" "[ ! -f ralc ]"; + + popd + rm -rf $workdir; +} + +test_pip_search_ralc_is_file() { + workdir=`mktemp -d tmp.${FUNCNAME[0]}.XXX`; # $workdir will be available globally + cp ../python.make $workdir/; + echo "include python.make" > $workdir/GNUmakefile; + touch $workdir/ralc + pushd $workdir; + + make python-runtime + make python-pip search ralc + assertTrue "ralc file shall not be removed" "[ -f ralc ]"; + + popd + rm -rf $workdir; +} + +# Load shUnit2. +. ./shunit2/shunit2 +