From a7948068eef020d26bac682899ea568c6e4067af Mon Sep 17 00:00:00 2001 From: Jeff Hung Date: Wed, 13 Nov 2019 19:20:56 +0800 Subject: [PATCH 1/8] Enhance the steps to prepare-shunit2. --- tests/GNUmakefile | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/GNUmakefile b/tests/GNUmakefile index fabb7ec..aeb35d1 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -27,14 +27,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; From 63305f179f8e50e70d610e713009ae5b8814cd70 Mon Sep 17 00:00:00 2001 From: Jeff Hung Date: Wed, 13 Nov 2019 19:21:38 +0800 Subject: [PATCH 2/8] Set PYTHON_CACHE_DIR to avoid multiple downloads. --- tests/GNUmakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/GNUmakefile b/tests/GNUmakefile index aeb35d1..8d19f55 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -16,6 +16,7 @@ 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 From 8062dd626dbb562b99b68367a9aca2aa8128ed3d Mon Sep 17 00:00:00 2001 From: Jeff Hung Date: Wed, 13 Nov 2019 19:22:03 +0800 Subject: [PATCH 3/8] Use shunit2/test_runner to run multiple test scripts. --- tests/GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/GNUmakefile b/tests/GNUmakefile index 8d19f55..e5c846b 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -18,7 +18,7 @@ distclean: clean .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 # --------------------------------------------------------------------------- From 3a1493fdaf59433a19b511718a5741e991e9ac44 Mon Sep 17 00:00:00 2001 From: Jeff Hung Date: Wed, 13 Nov 2019 19:22:23 +0800 Subject: [PATCH 4/8] Add pip_test.sh. --- tests/pip_test.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 tests/pip_test.sh diff --git a/tests/pip_test.sh b/tests/pip_test.sh new file mode 100755 index 0000000..ac09c94 --- /dev/null +++ b/tests/pip_test.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +test_pip_search_ralc_not_target() { + workdir=`mktemp -d tmp.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.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.XXX`; # $workdir will be available globally + cp ../python.make $workdir/; + echo " +ralc: + touch $@ + +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 + From ff634475b7f4072e2eddb6544089dd42124607be Mon Sep 17 00:00:00 2001 From: Jeff Hung Date: Wed, 13 Nov 2019 19:34:06 +0800 Subject: [PATCH 5/8] Fix pip test cases. --- tests/pip_test.sh | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/pip_test.sh b/tests/pip_test.sh index ac09c94..5756b6b 100755 --- a/tests/pip_test.sh +++ b/tests/pip_test.sh @@ -1,11 +1,9 @@ #!/bin/bash test_pip_search_ralc_not_target() { - workdir=`mktemp -d tmp.XXX`; # $workdir will be available globally + workdir=`mktemp -d tmp.${FUNCNAME[0]}.XX`; # $workdir will be available globally cp ../python.make $workdir/; - echo " -include python.make -" > $workdir/GNUmakefile; + echo "include python.make" > $workdir/GNUmakefile; pushd $workdir; make python-runtime @@ -17,11 +15,11 @@ include python.make } test_pip_search_ralc_is_target() { - workdir=`mktemp -d tmp.XXX`; # $workdir will be available globally + workdir=`mktemp -d tmp.${FUNCNAME[0]}.XX`; # $workdir will be available globally cp ../python.make $workdir/; echo " ralc: - touch $@ + touch \$@ include python.make " > $workdir/GNUmakefile; @@ -36,14 +34,9 @@ include python.make } test_pip_search_ralc_is_file() { - workdir=`mktemp -d tmp.XXX`; # $workdir will be available globally + workdir=`mktemp -d tmp.${FUNCNAME[0]}.XX`; # $workdir will be available globally cp ../python.make $workdir/; - echo " -ralc: - touch $@ - -include python.make -" > $workdir/GNUmakefile; + echo "include python.make" > $workdir/GNUmakefile; touch $workdir/ralc pushd $workdir; From c2c75169b132b812d23b664b5a5946ea6ccc6c5f Mon Sep 17 00:00:00 2001 From: Jeff Hung Date: Wed, 13 Nov 2019 19:34:25 +0800 Subject: [PATCH 6/8] Avoid trigger existing target in python-pip. --- python.make | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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)) From 7b05b9a419de53869eb8f798f01d38687d917939 Mon Sep 17 00:00:00 2001 From: Jeff Hung Date: Wed, 13 Nov 2019 19:37:26 +0800 Subject: [PATCH 7/8] Fix: mktemp: too few X's in template --- tests/pip_test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/pip_test.sh b/tests/pip_test.sh index 5756b6b..2f1d563 100755 --- a/tests/pip_test.sh +++ b/tests/pip_test.sh @@ -1,7 +1,7 @@ #!/bin/bash test_pip_search_ralc_not_target() { - workdir=`mktemp -d tmp.${FUNCNAME[0]}.XX`; # $workdir will be available globally + workdir=`mktemp -d tmp.${FUNCNAME[0]}.XXX`; # $workdir will be available globally cp ../python.make $workdir/; echo "include python.make" > $workdir/GNUmakefile; pushd $workdir; @@ -15,7 +15,7 @@ test_pip_search_ralc_not_target() { } test_pip_search_ralc_is_target() { - workdir=`mktemp -d tmp.${FUNCNAME[0]}.XX`; # $workdir will be available globally + workdir=`mktemp -d tmp.${FUNCNAME[0]}.XXX`; # $workdir will be available globally cp ../python.make $workdir/; echo " ralc: @@ -34,7 +34,7 @@ include python.make } test_pip_search_ralc_is_file() { - workdir=`mktemp -d tmp.${FUNCNAME[0]}.XX`; # $workdir will be available globally + 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 From 9c55e47824171276ed0e9492fb2f6976aaacfdc5 Mon Sep 17 00:00:00 2001 From: Jeff Hung Date: Wed, 13 Nov 2019 19:39:26 +0800 Subject: [PATCH 8/8] Fix: $(dir) in makefile ends with /. --- tests/GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/GNUmakefile b/tests/GNUmakefile index e5c846b..c8f4cef 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -16,7 +16,7 @@ distclean: clean rm -rf shunit2-$(SHUNIT2_VERSION).zip; .PHONY: test -test: export PYTHON_CACHE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/.cache +test: export PYTHON_CACHE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))).cache test: prepare-shunit2 LIB_DIR=shunit2/lib shunit2/test_runner -s /bin/bash