aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/py/test_repo.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-06-30 01:02:12 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-06-30 01:03:08 +0200
commitbf32d05ac1d91c6ffe626917edb54f07bb7918e4 (patch)
tree93735995ce79c06019ba21add98f78150be37ade /test/py/test_repo.py
parenttest: shuffle files a bit (diff)
downloadcimple-bf32d05ac1d91c6ffe626917edb54f07bb7918e4.tar.gz
cimple-bf32d05ac1d91c6ffe626917edb54f07bb7918e4.zip
test: split tests into different files
Diffstat (limited to 'test/py/test_repo.py')
-rw-r--r--test/py/test_repo.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/py/test_repo.py b/test/py/test_repo.py
new file mode 100644
index 0000000..f3a10d7
--- /dev/null
+++ b/test/py/test_repo.py
@@ -0,0 +1,47 @@
+# Copyright (c) 2023 Egor Tensin <Egor.Tensin@gmail.com>
+# This file is part of the "cimple" project.
+# For details, see https://github.com/egor-tensin/cimple.
+# Distributed under the MIT License.
+
+from lib.process import LoggingEvent
+
+
+class LoggingEventRunComplete(LoggingEvent):
+ def __init__(self, target):
+ self.counter = 0
+ self.target = target
+ super().__init__(timeout=60)
+
+ def log_line_matches(self, line):
+ return 'Received a "run complete" message from worker' in line
+
+ def set(self):
+ self.counter += 1
+ if self.counter == self.target:
+ super().set()
+
+
+def _test_repo_internal(server_and_workers, test_repo, client, numof_runs):
+ server, workers = server_and_workers
+
+ event = LoggingEventRunComplete(numof_runs)
+ # Count the number of times the server receives the "run complete" message.
+ server.logger.add_event(event)
+
+ for i in range(numof_runs):
+ client.run('run', test_repo.path, 'HEAD')
+
+ event.wait()
+ assert numof_runs == test_repo.count_ci_output_files()
+
+
+def test_repo(server_and_workers, test_repo, client):
+ _test_repo_internal(server_and_workers, test_repo, client, 1)
+
+
+def test_repo_2(server_and_workers, test_repo, client):
+ _test_repo_internal(server_and_workers, test_repo, client, 2)
+
+
+def test_repo_10(server_and_workers, test_repo, client):
+ _test_repo_internal(server_and_workers, test_repo, client, 10)