Skip to content

Commit

Permalink
Merge pull request #23 from jserv/python-sanity-check
Browse files Browse the repository at this point in the history
Perform sanity checks on python-based test cases
  • Loading branch information
WEI, CHEN committed Mar 19, 2018
2 parents 6e0197b + e5c4fb5 commit 1bdb2c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,10 @@ $(OUT)/libdcurl.so: $(OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -shared -o $@ $^ $(LDFLAGS)

# FIXME: script "tests/test-multi_pow.py" depends on PyIOTA package, and we
# have to check in advance, otherwise python3 would complain as following:
# ModuleNotFoundError: No module named 'iota'
$(OUT)/test-multi_pow_%: tests/test-multi_pow_%.py $(OUT)/libdcurl.so
@echo "#!/usr/bin/env python3" > $@
@cat $< >> $@
@chmod +x $@
$(Q)echo "#!$(PYTHON)" > $@
$(call py_prepare_cmd)
$(Q)chmod +x $@

$(OUT)/test-%.done: $(OUT)/test-%
$(Q)$(PRINTF) "*** Validating $< ***\n"
Expand All @@ -97,4 +94,5 @@ distclean: clean
$(RM) local.mk

include mk/common.mk
include mk/python.mk
-include $(deps)
14 changes: 14 additions & 0 deletions mk/python.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
PYTHON = python3
PYTHON := $(shell which $(PYTHON))
ifndef PYTHON
$(error "python3 is required.")
endif

# check "iota" module in Python installation
PY_CHECK_MOD_IOTA := $(shell $(PYTHON) -c "import iota" 2>/dev/null && \
echo 1 || echo 0)
ifeq ("$(PY_CHECK_MOD_IOTA)","1")
py_prepare_cmd = $(Q)cat $< >> $@
else
py_prepare_cmd = $(warning "skip $@ because PyIOTA is not installed.")
endif

0 comments on commit 1bdb2c8

Please sign in to comment.