forked from minrk/distarray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (75 loc) · 3.05 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#----------------------------------------------------------------------------
# Copyright (C) 2008-2014, IPython Development Team and Enthought, Inc.
# Distributed under the terms of the BSD License. See COPYING.rst.
#----------------------------------------------------------------------------
PYTHON := python
PYTHON_VERSION := $(shell ${PYTHON} --version 2>&1 | cut -f 2 -d ' ')
COVERAGE := coverage
MPIEXEC := mpiexec
NPROCS := 12
PARALLEL_OUT_DIR := .parallel_out
PARALLEL_UNITTEST_ARGS := -m unittest discover -s distarray/local/tests -p 'paralleltest*.py'
PARALLEL_TEST_REGULAR := ${PYTHON} ${PARALLEL_UNITTEST_ARGS}
PARALLEL_TEST_COVERAGE := ${COVERAGE} run -p ${PARALLEL_UNITTEST_ARGS}
MPI_OUT_BASE := unittest.out
MPI_OUT_PREFIX := ${PARALLEL_OUT_DIR}/${PYTHON_VERSION}-${MPI_OUT_BASE}
MPIEXEC_ARGS := --output-filename ${MPI_OUT_PREFIX} -n ${NPROCS}
# Inside MPI_EXEC_CMD, PARALLEL_TEST is meant to be substituted with either
# PARALLEL_TEST_REGULAR or PARALLEL_TEST_COVERAGE from above. See the
# `test_engines` and `test_engines_with_coverage` targets.
MPI_EXEC_CMD = (${MPIEXEC} ${MPIEXEC_ARGS} ${PARALLEL_TEST} ; OUT=$$? ; \
for f in ${MPI_OUT_PREFIX}* ; do echo "====> " $$f ; cat $$f ; done ; \
exit $$OUT)
# default number of engines to use.
NENGINES := 4
# ----------------------------------------------------------------------------
# Installation targets.
# ----------------------------------------------------------------------------
develop:
${PYTHON} setup.py develop
.PHONY: develop
install:
${PYTHON} setup.py install
.PHONY: install
# ----------------------------------------------------------------------------
# Testing-related targets.
# ----------------------------------------------------------------------------
test_client:
${PYTHON} -m unittest discover
.PHONY: test_client
test_client_with_coverage:
${COVERAGE} run -pm unittest discover -v
.PHONY: test_client_with_coverage
${PARALLEL_OUT_DIR} :
mkdir ${PARALLEL_OUT_DIR}
test_engines: ${PARALLEL_OUT_DIR}
@-${RM} ${MPI_OUT_PREFIX}*
$(eval PARALLEL_TEST := ${PARALLEL_TEST_REGULAR})
@echo "Running '${PARALLEL_TEST}' on each engine..."
@${MPI_EXEC_CMD}
.PHONY: test_engines
test_engines_with_coverage: ${PARALLEL_OUT_DIR}
@-${RM} ${MPI_OUT_PREFIX}*
$(eval PARALLEL_TEST := ${PARALLEL_TEST_COVERAGE})
@echo "Running '${PARALLEL_TEST}' on each engine..."
@${MPI_EXEC_CMD}
.PHONY: test_engines_with_coverage
test: test_client test_engines
.PHONY: test
test_with_coverage: test_client_with_coverage test_engines_with_coverage
.PHONY: test_with_coverage
coverage_report:
${COVERAGE} combine
${COVERAGE} html
.PHONY: coverage_report
# ----------------------------------------------------------------------------
# Cleanup.
# ----------------------------------------------------------------------------
clean:
-${PYTHON} setup.py clean --all
-find . \( -iname '*.py[co]' -or -iname '*.so' -or -iname '__pycache__' \) -exec ${RM} -r '{}' +
-${RM} -r ${PARALLEL_OUT_DIR} build coverage_report
.PHONY: clean
cleanall: clean
-${RM} -r MANIFEST dist distarray.egg-info
.PHONY: cleanall