aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-05-07 22:24:07 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-05-07 22:26:52 +0200
commit1960f95872502334f505926dab8e48e8a1ae5c39 (patch)
tree2f3f84da2bc4f6011f88c2d32ac388c1039854ce /test
parenttest: rename CMake tests (diff)
downloadcimple-1960f95872502334f505926dab8e48e8a1ae5c39.tar.gz
cimple-1960f95872502334f505926dab8e48e8a1ae5c39.zip
test: refactoring
Diffstat (limited to '')
-rw-r--r--test/conftest.py4
-rw-r--r--test/lib/process.py13
2 files changed, 9 insertions, 8 deletions
diff --git a/test/conftest.py b/test/conftest.py
index fa5f36b..80ffef5 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -121,12 +121,12 @@ def sqlite_path(tmp_path):
class CmdLineServer(CmdLine):
- def log_line_means_launched(self, line):
+ def log_line_means_ready(self, line):
return line.endswith('Waiting for new connections')
class CmdLineWorker(CmdLine):
- def log_line_means_launched(self, line):
+ def log_line_means_ready(self, line):
return line.endswith('Waiting for a new command')
diff --git a/test/lib/process.py b/test/lib/process.py
index 428cead..38c9c1a 100644
--- a/test/lib/process.py
+++ b/test/lib/process.py
@@ -22,7 +22,7 @@ _COMMON_ARGS = {
class LoggingThread(Thread):
def __init__(self, process):
self.process = process
- self.launched_event = Event()
+ self.ready_event = Event()
target = lambda pipe: self.consume(pipe)
super().__init__(target=target, args=[process.stdout])
@@ -30,12 +30,13 @@ class LoggingThread(Thread):
for line in pipe:
line = line.removesuffix('\n')
logging.info('%s: %s', self.process.log_id, line)
- if self.process.cmd_line.log_line_means_launched(line):
- self.launched_event.set()
+ if self.process.cmd_line.log_line_means_ready(line):
+ logging.info('Process %s is ready', self.process.log_id)
+ self.ready_event.set()
def __enter__(self):
self.start()
- self.launched_event.wait()
+ self.ready_event.wait()
return self
def __exit__(self, *args):
@@ -65,7 +66,7 @@ class CmdLine:
name = os.path.basename(binary)
self.process_name = name
- def log_line_means_launched(self, line):
+ def log_line_means_ready(self, line):
return True
@classmethod
@@ -87,7 +88,7 @@ class Process(subprocess.Popen):
self.name = cmd_line.process_name
super().__init__(cmd_line.argv, **_COMMON_ARGS)
- logging.info('Process %s launched', self.log_id)
+ logging.info('Process %s has started', self.log_id)
@property
def log_id(self):