|
|
@@ -2,9 +2,7 @@ import time
|
|
|
import logging
|
|
|
|
|
|
class TestRunner:
|
|
|
- def __init__(self, directory, stdout):
|
|
|
- self.dir = directory
|
|
|
- self.stdout = stdout
|
|
|
+ iAmTestRunnerClass = True
|
|
|
|
|
|
def sh(self, command, **kwargs):
|
|
|
kwargs.setdefault('cwd', self.dir)
|
|
|
@@ -18,6 +16,10 @@ class TestRunner:
|
|
|
self.stdout.write("No Output")
|
|
|
except subprocess.CalledProcessError:
|
|
|
self.stdout.write("Process Returned non-zero exit code")
|
|
|
+ def __init__(self, test, target, logger):
|
|
|
+ self.test = test
|
|
|
+ self.target = target
|
|
|
+ self.logger = logger
|
|
|
|
|
|
def sh_async(self, command, initial_logs=True, **kwargs):
|
|
|
kwargs.setdefault('cwd', self.dir)
|
|
|
@@ -42,7 +44,14 @@ class TestRunner:
|
|
|
self.stdout.write("Initial Error Logs")
|
|
|
for line in err:
|
|
|
self.stdout.write(line.rstrip('\n'))
|
|
|
+ # Create convenience variables to decouple the
|
|
|
+ # setup.py scripts from the internals of TFB
|
|
|
+ self.benchmarker = test.benchmarker
|
|
|
+ self.database_host = self.benchmarker.database_host
|
|
|
+ self.dir = test.directory
|
|
|
|
|
|
+ def start(self):
|
|
|
+ raise NotImplementedError()
|
|
|
|
|
|
from threading import Thread
|
|
|
from Queue import Queue, Empty
|
|
|
@@ -58,6 +67,8 @@ class NonBlockingStreamReader:
|
|
|
def __init__(self, stream):
|
|
|
self._s = stream
|
|
|
self._q = Queue()
|
|
|
+ def stop(self):
|
|
|
+ raise NotImplementedError()
|
|
|
|
|
|
def _populateQueue(stream, queue):
|
|
|
for line in iter(stream.readline, b''):
|
|
|
@@ -70,6 +81,9 @@ class NonBlockingStreamReader:
|
|
|
|
|
|
# TODO - This is only returning one line, if it is available.
|
|
|
def readline(self, timeout = None):
|
|
|
+ @staticmethod
|
|
|
+ def is_parent_of(target_class):
|
|
|
+ ''' Checks if provided class object is a subclass of TestRunner '''
|
|
|
try:
|
|
|
return self._q.get(block = timeout is not None,
|
|
|
timeout = timeout)
|
|
|
@@ -83,3 +97,20 @@ class NonBlockingStreamReader:
|
|
|
if not line:
|
|
|
return lines
|
|
|
lines.append(line)
|
|
|
+ # issubclass will not work, as setup_module is loaded in different
|
|
|
+ # global context and therefore has a different copy of the module
|
|
|
+ # test_runner. A cheap trick is just to check for this attribute
|
|
|
+ str(target_class.iAmTestRunnerClass)
|
|
|
+
|
|
|
+ # target_class seems to be an instance of TestRunner. Before returning,
|
|
|
+ # ensure they have not created an __init__ method, as they cannot
|
|
|
+ # call super.__init__(), and therefore the subclass is doomed to error
|
|
|
+ try:
|
|
|
+ target_class()
|
|
|
+ raise Exception("Subclasses of TestRunner should not define __init__")
|
|
|
+ except TypeError:
|
|
|
+ # Good, there is no init method defined
|
|
|
+ return True
|
|
|
+
|
|
|
+ except AttributeError:
|
|
|
+ return False
|