Commit 8e41eb66 authored by Jérome Perrin's avatar Jérome Perrin

LiveTest: prevent running tests twice

parent cbfc5283
...@@ -48,6 +48,7 @@ from DateTime import DateTime ...@@ -48,6 +48,7 @@ from DateTime import DateTime
DEFAULT_TEST_TEMPLATE_COPYRIGHT = "Copyright (c) 2002-%s Nexedi SA and " \ DEFAULT_TEST_TEMPLATE_COPYRIGHT = "Copyright (c) 2002-%s Nexedi SA and " \
"Contributors. All Rights Reserved." % DateTime().year() "Contributors. All Rights Reserved." % DateTime().year()
live_test_running = False
last_sync = -1 last_sync = -1
class ComponentTool(BaseTool): class ComponentTool(BaseTool):
""" """
...@@ -277,6 +278,12 @@ class Test(ERP5TypeTestCase): ...@@ -277,6 +278,12 @@ class Test(ERP5TypeTestCase):
""" """
from StringIO import StringIO from StringIO import StringIO
global global_stream global global_stream
global live_test_running
self.serialize()
if live_test_running:
LOG('ComponentTool', INFO, 'Live test already running')
return ''
global_stream = StringIO() global_stream = StringIO()
test_list = self._getCommaSeparatedParameterList(test_list) test_list = self._getCommaSeparatedParameterList(test_list)
if not test_list: if not test_list:
...@@ -289,18 +296,22 @@ class Test(ERP5TypeTestCase): ...@@ -289,18 +296,22 @@ class Test(ERP5TypeTestCase):
run_only = self._getCommaSeparatedParameterList(run_only) run_only = self._getCommaSeparatedParameterList(run_only)
verbosity = verbose and 2 or 1 verbosity = verbose and 2 or 1
from Products.ERP5Type.tests.ERP5TypeLiveTestCase import runLiveTest
try: try:
result = runLiveTest(test_list, live_test_running = True
run_only=run_only, from Products.ERP5Type.tests.ERP5TypeLiveTestCase import runLiveTest
debug=debug, try:
stream=global_stream, result = runLiveTest(test_list,
verbosity=verbosity) run_only=run_only,
except ImportError: debug=debug,
import traceback stream=global_stream,
traceback.print_exc(file=global_stream) verbosity=verbosity)
global_stream.seek(0) except ImportError:
return global_stream.read() import traceback
traceback.print_exc(file=global_stream)
global_stream.seek(0)
return global_stream.read()
finally:
live_test_running = False
security.declareProtected(Permissions.ManagePortal, 'readTestOutput') security.declareProtected(Permissions.ManagePortal, 'readTestOutput')
def readTestOutput(self, position=0): def readTestOutput(self, position=0):
......
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