mirror of
https://git.yoctoproject.org/poky
synced 2026-05-09 05:29:32 +00:00
oeqa/concurrencytest: Rename variables to improve the code
Each time I look at this code I get confused about what the different variables represent. Rename a few of them to better indicate what they represent. (From OE-Core rev: e39d97c0b191add9281bac463ca059685288c81a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -190,13 +190,13 @@ class ConcurrentTestSuite(unittest.TestSuite):
|
|||||||
self.removefunc = removefunc
|
self.removefunc = removefunc
|
||||||
|
|
||||||
def run(self, result):
|
def run(self, result):
|
||||||
tests, totaltests = fork_for_tests(self.processes, self)
|
testservers, totaltests = fork_for_tests(self.processes, self)
|
||||||
try:
|
try:
|
||||||
threads = {}
|
threads = {}
|
||||||
queue = Queue()
|
queue = Queue()
|
||||||
semaphore = threading.Semaphore(1)
|
semaphore = threading.Semaphore(1)
|
||||||
result.threadprogress = {}
|
result.threadprogress = {}
|
||||||
for i, (test, testnum) in enumerate(tests):
|
for i, (testserver, testnum) in enumerate(testservers):
|
||||||
result.threadprogress[i] = []
|
result.threadprogress[i] = []
|
||||||
process_result = BBThreadsafeForwardingResult(
|
process_result = BBThreadsafeForwardingResult(
|
||||||
ExtraResultsDecoderTestResult(result),
|
ExtraResultsDecoderTestResult(result),
|
||||||
@@ -210,8 +210,8 @@ class ConcurrentTestSuite(unittest.TestSuite):
|
|||||||
process_result._stdout_buffer = io.StringIO()
|
process_result._stdout_buffer = io.StringIO()
|
||||||
process_result._stdout_buffer.buffer = dummybuf(process_result._stdout_buffer)
|
process_result._stdout_buffer.buffer = dummybuf(process_result._stdout_buffer)
|
||||||
reader_thread = threading.Thread(
|
reader_thread = threading.Thread(
|
||||||
target=self._run_test, args=(test, process_result, queue))
|
target=self._run_test, args=(testserver, process_result, queue))
|
||||||
threads[test] = reader_thread, process_result
|
threads[testserver] = reader_thread, process_result
|
||||||
reader_thread.start()
|
reader_thread.start()
|
||||||
while threads:
|
while threads:
|
||||||
finished_test = queue.get()
|
finished_test = queue.get()
|
||||||
@@ -222,13 +222,13 @@ class ConcurrentTestSuite(unittest.TestSuite):
|
|||||||
process_result.stop()
|
process_result.stop()
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
for test in tests:
|
for testserver in testservers:
|
||||||
test[0]._stream.close()
|
testserver[0]._stream.close()
|
||||||
|
|
||||||
def _run_test(self, test, process_result, queue):
|
def _run_test(self, testserver, process_result, queue):
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
test.run(process_result)
|
testserver.run(process_result)
|
||||||
except Exception:
|
except Exception:
|
||||||
# The run logic itself failed
|
# The run logic itself failed
|
||||||
case = testtools.ErrorHolder(
|
case = testtools.ErrorHolder(
|
||||||
@@ -236,10 +236,10 @@ class ConcurrentTestSuite(unittest.TestSuite):
|
|||||||
error=sys.exc_info())
|
error=sys.exc_info())
|
||||||
case.run(process_result)
|
case.run(process_result)
|
||||||
finally:
|
finally:
|
||||||
queue.put(test)
|
queue.put(testserver)
|
||||||
|
|
||||||
def fork_for_tests(concurrency_num, suite):
|
def fork_for_tests(concurrency_num, suite):
|
||||||
result = []
|
testservers = []
|
||||||
if 'BUILDDIR' in os.environ:
|
if 'BUILDDIR' in os.environ:
|
||||||
selftestdir = get_test_layer()
|
selftestdir = get_test_layer()
|
||||||
|
|
||||||
@@ -306,9 +306,9 @@ def fork_for_tests(concurrency_num, suite):
|
|||||||
else:
|
else:
|
||||||
os.close(c2pwrite)
|
os.close(c2pwrite)
|
||||||
stream = os.fdopen(c2pread, 'rb', 1)
|
stream = os.fdopen(c2pread, 'rb', 1)
|
||||||
test = ProtocolTestCase(stream)
|
testserver = ProtocolTestCase(stream)
|
||||||
result.append((test, numtests))
|
testservers.append((testserver, numtests))
|
||||||
return result, totaltests
|
return testservers, totaltests
|
||||||
|
|
||||||
def partition_tests(suite, count):
|
def partition_tests(suite, count):
|
||||||
# Keep tests from the same class together but allow tests from modules
|
# Keep tests from the same class together but allow tests from modules
|
||||||
|
|||||||
Reference in New Issue
Block a user