Skip to content

Commit

Permalink
Add "setup.py test".
Browse files Browse the repository at this point in the history
  • Loading branch information
skrah committed Jul 24, 2018
1 parent 4a4cda1 commit 1189249
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 8 deletions.
2 changes: 2 additions & 0 deletions INSTALL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ Install all Python modules into $PWD/python
===========================================

python3 setup.py develop
python3 setup.py test


Install all Python modules into site-packages
=============================================

python3 setup.py install
python3 setup.py test
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ install: libndtypes_install libxnd_install libgumath_install


clean: FORCE
cd ndtypes && $(MAKE) clean
cd xnd && $(MAKE) clean
cd gumath && $(MAKE) clean
- cd ndtypes && $(MAKE) clean
- cd xnd && $(MAKE) clean
- cd gumath && $(MAKE) clean

distclean: FORCE
cd ndtypes && $(MAKE) distclean
cd xnd && $(MAKE) distclean
cd gumath && $(MAKE) distclean
rm -rf config.log build
- cd ndtypes && $(MAKE) distclean
- cd xnd && $(MAKE) distclean
- cd gumath && $(MAKE) distclean
- cd python && rm -rf ndtypes xnd gumath __pycache__ *.egg-info
- cd python/test && rm -rf *.py __pycache__ *.egg-info
- rm -rf config.log build

FORCE:
2 changes: 2 additions & 0 deletions python/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Directory for the development install of all Python modules.
4 changes: 4 additions & 0 deletions python/test/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Directory for copies of Python test files.

NOTE: "make distclean" clears this directory!
37 changes: 36 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,24 @@

import sys
import os
import subprocess
from shutil import copy2
from glob import glob

def err_exit():
sys.stderr.write(
"error: valid required arguments are \"install\" or \"develop\"\n\n")
"setup.py: usage: python3 setup.py [install, develop, test]\n\n")
sys.exit(1)

def copy_tests():
for lib in "ndtypes", "xnd", "gumath":
pattern = os.path.join(lib, "python", "*.py")
files = glob(pattern)
dest = os.path.join("python", "test")
for f in files:
copy2(f, dest)


if len(sys.argv) != 2:
err_exit()

Expand All @@ -48,12 +60,35 @@ def err_exit():
os.system("'%s' setup.py install" % sys.executable)
os.chdir("..")

copy_tests()

elif sys.argv[1] == "develop":
INSTALLDIR = os.path.join(os.getcwd(), "python")
for lib in "ndtypes", "xnd", "gumath":
os.chdir(lib)
os.system("'%s' setup.py install --local=%s" % (sys.executable, INSTALLDIR))
os.chdir("..")

copy_tests()

elif sys.argv[1] == "test":
os.chdir("python")
python_path = os.getenv('PYTHONPATH')
cwd = os.getcwd()
path = cwd + ':' + python_path if python_path else cwd
env = os.environ.copy()
env['PYTHONPATH'] = path

ret = subprocess.call([sys.executable, "test/test_ndtypes.py", "--long"], env=env)
if ret != 0:
sys.exit(ret)

ret = subprocess.call([sys.executable, "test/test_xnd.py", "--long"], env=env)
if ret != 0:
sys.exit(ret)

ret = subprocess.call([sys.executable, "test/test_gumath.py"], env=env)
sys.exit(ret)

else:
err_exit()

0 comments on commit 1189249

Please sign in to comment.