@@ -10,6 +10,21 @@ PYTHON=${PYTHON:-"python3.7"}
1010
1111TEMP_DIRS=()
1212
13+ function run_plugin_examples() {
14+ cd " ${SRC_ROOT} /${PLUGIN} /examples"
15+ if [ -f " requirements.txt" ]; then
16+ " ${PYTHON} " -m pip install -r requirements.txt
17+ fi
18+ # Run example tests in top level examples directory
19+ for dir in $( find . -type d) ; do
20+ # Run example tests in examples subdirectories
21+ cd " ${SRC_ROOT} /${PLUGIN} /examples"
22+ cd " ${dir} "
23+ " ${PYTHON} " -m unittest discover -v
24+ done
25+ cd " ${SRC_ROOT} /${PLUGIN} "
26+ }
27+
1328function run_plugin() {
1429 # Create a virtualenv
1530 venv_dir=" $( mktemp -d) "
@@ -18,20 +33,28 @@ function run_plugin() {
1833 source " ${venv_dir} /bin/activate"
1934 " ${PYTHON} " -m pip install -U pip twine
2035
21- " ${PYTHON} " -m pip install -U " ${SRC_ROOT} "
36+ " ${PYTHON} " -m pip install -U -e " ${SRC_ROOT} "
2237
2338 if [ " x${PLUGIN} " = " xmodel/tensorflow_hub" ]; then
24- " ${PYTHON} " -m pip install -U " ${SRC_ROOT} /model/tensorflow"
39+ " ${PYTHON} " -m pip install -U -e " ${SRC_ROOT} /model/tensorflow"
2540 fi
2641
2742 cd " ${PLUGIN} "
2843 PACKAGE_NAME=$( dffml service dev setuppy kwarg name setup.py)
44+ # Install
2945 " ${PYTHON} " -m pip install -e .
46+ # Run the tests
3047 " ${PYTHON} " setup.py test
48+ # Run examples if they exist and we aren't at the root
49+ if [ -d " examples" ] && [ " x${PLUGIN} " != " x." ]; then
50+ run_plugin_examples
51+ fi
52+ # Uninstall
3153 " ${PYTHON} " -m pip uninstall -y " ${PACKAGE_NAME} "
32- cd -
54+ cd " ${SRC_ROOT} "
3355
3456 if [ " x${PLUGIN} " = " x." ]; then
57+ exit 0
3558 # Try running create command
3659 plugin_creation_dir=" $( mktemp -d) "
3760 TEMP_DIRS+=(" ${plugin_creation_dir} " )
@@ -56,10 +79,7 @@ function run_plugin() {
5679 " ${PYTHON} " -m dffml service dev install
5780
5881 # Run the examples
59- cd " ${SRC_ROOT} /examples"
60- " ${PYTHON} " -m pip install -r requirements.txt
61- " ${PYTHON} " -m unittest discover
62- cd " ${SRC_ROOT} "
82+ run_plugin_examples
6383
6484 # Deactivate venv
6585 deactivate
0 commit comments