Commit 886177ca authored by Julien Muchembled's avatar Julien Muchembled

run_tests_suite: suite name can contain dots, to specify a class in a submodule

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41863 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4b29fcf0
...@@ -70,6 +70,7 @@ class SubprocessError(EnvironmentError): ...@@ -70,6 +70,7 @@ class SubprocessError(EnvironmentError):
class Updater(object): class Updater(object):
_git_svn_cache = {}
realtime_output = True realtime_output = True
stdin = file(os.devnull) stdin = file(os.devnull)
...@@ -111,10 +112,21 @@ class Updater(object): ...@@ -111,10 +112,21 @@ class Updater(object):
def _git(self, *args, **kw): def _git(self, *args, **kw):
return self.spawn('git', *args, **kw)['stdout'].strip() return self.spawn('git', *args, **kw)['stdout'].strip()
def _git_find_rev(self, ref):
try:
return self._git_svn_cache[ref]
except KeyError:
r = self._git('svn', 'find-rev', ref)
assert r
ref2 = ref[0] != 'r' and 'r%u' % int(r) or r
self._git_svn_cache[ref] = ref2
self._git_svn_cache[ref2] = ref
return r
def getRevision(self): def getRevision(self):
if os.path.isdir('.git'): if os.path.isdir('.git'):
h = self._git('log', '-1', '--format=%H', *self._path_list) h = self._git('log', '-1', '--format=%H', '--', *self._path_list)
return str(int(self._git('svn', 'find-rev', h))) return self._git_find_rev(h)
if os.path.isdir('.svn'): if os.path.isdir('.svn'):
stdout = self.spawn('svn', 'info', *self._path_list)['stdout'] stdout = self.spawn('svn', 'info', *self._path_list)['stdout']
return str(max(map(int, SVN_CHANGED_REV.findall(stdout)))) return str(max(map(int, SVN_CHANGED_REV.findall(stdout))))
...@@ -125,8 +137,7 @@ class Updater(object): ...@@ -125,8 +137,7 @@ class Updater(object):
if os.path.isdir('.git'): if os.path.isdir('.git'):
# edit .git/info/sparse-checkout if you want sparse checkout # edit .git/info/sparse-checkout if you want sparse checkout
if revision: if revision:
h = self._git('svn', 'find-rev', 'r%s' % revision) h = self._git_find_rev('r' + revision)
assert h
if h != self._git('rev-parse', 'HEAD'): if h != self._git('rev-parse', 'HEAD'):
self.deletePycFiles('.') self.deletePycFiles('.')
self._git('reset', '--merge', h) self._git('reset', '--merge', h)
...@@ -199,7 +210,9 @@ class TestSuite(Updater): ...@@ -199,7 +210,9 @@ class TestSuite(Updater):
on_stop(status_dict) on_stop(status_dict)
self._pool.append(self.running.pop(test)) self._pool.append(self.running.pop(test))
self.release() self.release()
threading.Thread(target=run).start() thread = threading.Thread(target=run)
thread.setDaemon(True)
thread.start()
def update(self): def update(self):
self.checkout() # by default, update everything self.checkout() # by default, update everything
...@@ -341,10 +354,14 @@ def main(): ...@@ -341,10 +354,14 @@ def main():
def makeSuite(revision=None): def makeSuite(revision=None):
updater = Updater(revision) updater = Updater(revision)
updater.checkout('tests') updater.checkout('tests')
tests = imp.load_module('tests', *imp.find_module('tests', ['.'])) for k in sys.modules.keys():
if k == 'tests' or k.startswith('tests.'):
del sys.modules[k]
module_name, class_name = ('tests.' + name).rsplit('.', 1)
try: try:
suite_class = getattr(tests, name) suite_class = getattr(__import__(module_name, None, None, [class_name]),
except AttributeError: class_name)
except (AttributeError, ImportError):
parser.error("unknown test suite") parser.error("unknown test suite")
if len(db_list) < suite_class.mysql_db_count: if len(db_list) < suite_class.mysql_db_count:
parser.error("%r suite needs %u DB (only %u given)" % parser.error("%r suite needs %u DB (only %u given)" %
...@@ -387,6 +404,7 @@ def main(): ...@@ -387,6 +404,7 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
sys.path[0] = ''
if not os.isatty(0): if not os.isatty(0):
killallIfParentDies() killallIfParentDies()
sys.exit(main()) sys.exit(main())
...@@ -26,7 +26,7 @@ class _ERP5(ERP5TypeTestSuite): ...@@ -26,7 +26,7 @@ class _ERP5(ERP5TypeTestSuite):
os.symlink(os.path.join('..', 'products', product), os.symlink(os.path.join('..', 'products', product),
os.path.join('Products', product)) os.path.join('Products', product))
def update(self, working_copy_list=None): def update(self):
self.checkout('products', 'bt5') self.checkout('products', 'bt5')
self.enableProducts() self.enableProducts()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment