Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions python.make
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
15 changes: 5 additions & 10 deletions tests/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

# ---------------------------------------------------------------------------

Expand All @@ -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;

53 changes: 53 additions & 0 deletions tests/pip_test.sh
Original file line number Diff line number Diff line change
@@ -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