20
20
# Current versions can be found at www.libavg.de
24
Runner for libavg unit tests
26
On autotools-based systems, tests are performed on a local libavg package.
27
This package is created by symlinking all the relevant files in a local, temporary
28
directory, letting python find it as first instance.
29
On windows, instead, tests are always carried on after distutils installs the package.
28
g_TempPackageDir = None
38
if os.path.isdir(folder):
39
print 'Wiping out directory: %s' % folder
31
42
def symtree(src, dest):
37
48
(os.path.isfile(fpath) and os.path.splitext(f)[1] == '.py'))):
38
49
os.symlink(os.path.join(os.pardir, src, f), os.path.join(dest, f))
41
52
if sys.platform != 'win32':
42
g_TempPackageDir = os.path.join(os.getcwd(), 'libavg')
43
if os.getenv('srcdir') in ('.', None):
53
tempPackageDir = os.path.join(os.getcwd(), 'libavg')
54
# Possible values for srcdir:
57
# dir name: make distcheck
58
srcDir = os.getenv("srcdir",".")
60
# Running make check or ./Test.py
44
61
if os.path.basename(os.getcwd()) != 'test':
45
62
raise RuntimeError('Manual tests must be performed inside directory "test"')
47
if os.path.isdir(g_TempPackageDir):
48
print 'Cleaning up old test package'
49
shutil.rmtree(g_TempPackageDir)
64
cleanup(tempPackageDir)
52
# We're running make check / manual tests
53
67
symtree('../python', 'libavg')
54
# os.system('cp -r ../python libavg')
55
os.symlink('../../wrapper/__init__.py', 'libavg/__init__.py')
71
# Running make distcheck
60
72
symtree('../../../../src/python', 'libavg')
61
os.symlink('../../../../../src/wrapper/__init__.py', 'libavg/__init__.py')
62
sys.path.insert(0, os.getcwd())
74
# distcheck doesn't want leftovers (.pyc files)
75
atexit.register(lambda tempPackageDir=tempPackageDir: cleanup(tempPackageDir))
64
os.symlink('../../wrapper/.libs/avg.so', 'libavg/avg.so')
77
if os.path.exists('../wrapper/.libs/avg.so'):
78
# Normal case: use the local version (not the installed one)
79
os.symlink('../../wrapper/.libs/avg.so', 'libavg/avg.so')
80
elif os.path.exists('../../avg.so'):
81
# Mac version after installer dmg
84
raise RuntimeError('Compile libavg before running tests or use "make check"')
66
# The following lines help to prevent the test to be run
86
# The following line prevents the test to be run
67
87
# with an unknown version of libavg, which can be hiding somewhere
89
sys.path.insert(0, os.getcwd())
91
# Meaningful only for distcheck
70
95
libavg.avg.Logger.get().trace(libavg.avg.Logger.APP, "Using libavg from: "+
71
96
os.path.dirname(libavg.__file__))
73
cpfx = os.path.commonprefix((libavg.__file__, os.getcwd()))
75
# if cpfx != os.getcwd():
77
# 'Tests would be performed with a non-local libavg package (%s)'
80
srcDir = os.getenv("srcdir",".")
112
128
app.registerSuiteFactory('python', PythonTest.pythonTestSuite)
113
129
app.registerSuiteFactory('anim', AnimTest.animTestSuite)
114
130
app.registerSuiteFactory('event', EventTest.eventTestSuite)
120
if g_TempPackageDir is not None:
122
shutil.rmtree(g_TempPackageDir)
124
print 'ERROR: Cannot clean up test package directory'
131
app.registerSuiteFactory('inputdevice', InputDeviceTest.inputDeviceTestSuite)
132
app.registerSuiteFactory('ui', UITest.uiTestSuite)
133
app.registerSuiteFactory('avgapp', AVGAppTest.avgAppTestSuite)
126
137
sys.exit(app.exitCode())