test: Run core tests only once
... under nosetests or manually with run_core_tests_manual.py Add missing PYTHONPATH env to manual test_core invocation - nose figures it out automagically. Signed-off-by: Tushar Gohad <tushar.gohad@intel.com>
This commit is contained in:
parent
e611b03b52
commit
e1ef879d96
@ -23,21 +23,18 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
|
||||||
|
|
||||||
run_under_valgrind = False
|
run_under_valgrind = False
|
||||||
test_cmd_prefix = ""
|
test_cmd_prefix = ""
|
||||||
log_filename_prefix = ""
|
log_filename_prefix = ""
|
||||||
|
|
||||||
|
|
||||||
class TestCore(unittest.TestCase):
|
class CoreTests():
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
self.pyeclib_core_test = "test_pyeclib_c.py"
|
self.pyeclib_core_test = "test_pyeclib_c.py"
|
||||||
self.pyeclib_iface_test = "test_pyeclib_api.py"
|
self.pyeclib_iface_test = "test_pyeclib_api.py"
|
||||||
|
|
||||||
unittest.TestCase.__init__(self, *args)
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# Determine which directory we're in
|
# Determine which directory we're in
|
||||||
dirs = os.getcwd().split('/')
|
dirs = os.getcwd().split('/')
|
||||||
@ -55,8 +52,7 @@ class TestCore(unittest.TestCase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_core(self):
|
def invoke_core_tests(self):
|
||||||
self.assertTrue(True)
|
|
||||||
cur_dir = os.getcwd()
|
cur_dir = os.getcwd()
|
||||||
print("\n")
|
print("\n")
|
||||||
for (dir, test) in self.py_test_dirs:
|
for (dir, test) in self.py_test_dirs:
|
||||||
@ -64,17 +60,18 @@ class TestCore(unittest.TestCase):
|
|||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
os.chdir(dir)
|
os.chdir(dir)
|
||||||
if os.path.isfile(test):
|
if os.path.isfile(test):
|
||||||
|
pythonpath = "PYTHONPATH=%s:%s" % \
|
||||||
|
(cur_dir, os.path.dirname(cur_dir))
|
||||||
ret = os.system(
|
ret = os.system(
|
||||||
"%s python %s >%s/%s.%s.out 2>&1" %
|
"%s %s python %s >%s/%s.%s.out 2>&1" %
|
||||||
(test_cmd_prefix, test, cur_dir,
|
(pythonpath, test_cmd_prefix, test, cur_dir,
|
||||||
log_filename_prefix, test))
|
log_filename_prefix, test))
|
||||||
|
|
||||||
self.assertEqual(0, ret)
|
assert(0 == ret)
|
||||||
os.system("rm -f *.pyc")
|
os.system("rm -f *.pyc")
|
||||||
os.chdir(cur_dir)
|
os.chdir(cur_dir)
|
||||||
print('ok')
|
print('ok')
|
||||||
else:
|
else:
|
||||||
self.assertTrue(False)
|
|
||||||
print('failed')
|
print('failed')
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +86,7 @@ if __name__ == "__main__":
|
|||||||
run_under_valgrind = True
|
run_under_valgrind = True
|
||||||
test_cmd_prefix = "valgrind --leak-check=full "
|
test_cmd_prefix = "valgrind --leak-check=full "
|
||||||
log_filename_prefix = "valgrind"
|
log_filename_prefix = "valgrind"
|
||||||
if sys.version_info<(2,7,0):
|
coretests = CoreTests()
|
||||||
unittest.main()
|
coretests.setUp()
|
||||||
else:
|
coretests.invoke_core_tests()
|
||||||
unittest.main(verbosity=2)
|
coretests.tearDown()
|
1
test/run_core_tests_manual_valgrind.py
Symbolic link
1
test/run_core_tests_manual_valgrind.py
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
run_core_tests_manual.py
|
@ -1 +0,0 @@
|
|||||||
test_core.py
|
|
Loading…
x
Reference in New Issue
Block a user