1 |
Import('*') |
2 |
local_env=env.Copy() |
3 |
src_dir = local_env.Dir('.').srcnode().abspath |
4 |
import os |
5 |
filenames = os.listdir(src_dir) |
6 |
# |
7 |
# files defining tests but are not running by itself: |
8 |
# |
9 |
testfiles = [x for x in filenames if x.startswith('test_') and os.path.splitext(x)[1] in ['.py'] ] |
10 |
# |
11 |
# directories defining test data |
12 |
# |
13 |
testdata_dir = [x for x in filenames if x.startswith('data_') ] |
14 |
# |
15 |
# files defining test runs (passing in a release) |
16 |
# |
17 |
testruns = [x for x in filenames if x.startswith('run_') and os.path.splitext(x)[1] in ['.py'] ] |
18 |
# |
19 |
# files defining tests run locally (not as part of a release) |
20 |
# |
21 |
localtestruns = [x for x in filenames if not x.startswith('run_') and os.path.splitext(x)[1] in ['.py']] |
22 |
# |
23 |
# all test |
24 |
# |
25 |
alltestruns = testruns + localtestruns |
26 |
# |
27 |
# test files are just compiled: |
28 |
# |
29 |
test_pyc = env.PyCompile(testfiles) |
30 |
env.Alias('build_py_tests', test_pyc) |
31 |
|
32 |
|
33 |
# get all the python files in the release tar file |
34 |
release_pyfiles = [ env.File("SConscript"), ] |
35 |
release_datafiles=[] # FIXIT: is there a better way? |
36 |
for d in testdata_dir: |
37 |
release_datafiles+=[ d+"/"+x for x in os.listdir(local_env.Dir(d).srcnode().abspath) if not x.startswith('.')] |
38 |
release_testfiles = [ env.File(x) for x in testfiles + testruns ] + [ env.File(x) for x in release_datafiles ] |
39 |
env.Zip(src_zipfile, release_pyfiles) |
40 |
env.Zip(test_zipfile, release_testfiles) |
41 |
try: |
42 |
env.Tar(test_tarfile, release_testfiles) |
43 |
env.Tar(src_tarfile, release_pyfiles) |
44 |
except AttributeError: |
45 |
pass |
46 |
# |
47 |
# run all tests: |
48 |
# |
49 |
try: |
50 |
import vtk |
51 |
VTK_AVAILABLE = True |
52 |
except ImportError: |
53 |
VTK_AVAILABLE =False |
54 |
print "Warning: vtk is not installed on your system. pyvisi tests are skipped." |
55 |
|
56 |
|
57 |
#Add Unit Test to target alias |
58 |
local_env.PrependENVPath('PYTHONPATH',str(env.Dir('#/build/$PLATFORM/pyvisi/test/python'))) |
59 |
local_env['ENV']['PYVISI_TEST_DATA_ROOT']=env.Dir('#/pyvisi/test/python').srcnode().abspath |
60 |
local_env['ENV']['PYVISI_WORKDIR']=env.Dir('#/build/$PLATFORM/pyvisi/test/python').srcnode().abspath |
61 |
|
62 |
if VTK_AVAILABLE: |
63 |
env.Alias('local_py_tests',[os.path.splitext(x)[0]+'.passed' for x in alltestruns]) |
64 |
env.Alias('py_tests', [os.path.splitext(x)[0]+'.passed' for x in testruns ]) |
65 |
program = local_env.RunPyUnitTest(alltestruns) |
66 |
|
67 |
Depends(program, pyinstall) |
68 |
# Depends(program, dep_lib) |
69 |
Depends(program, 'build_py_tests') |