aboutsummaryrefslogtreecommitdiff
path: root/src/test/test.py
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-27 18:41:02 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-27 18:41:02 +0200
commit6382d2b7c1910f29556b740513421b57da9c5a97 (patch)
tree4e79e4b13226cd1b288486e2819368c767e55259 /src/test/test.py
parent51857521f770caae7b36e3a36a30d5b6986e66d1 (diff)
downloadphilosophers_test-6382d2b7c1910f29556b740513421b57da9c5a97.tar.gz
philosophers_test-6382d2b7c1910f29556b740513421b57da9c5a97.tar.bz2
philosophers_test-6382d2b7c1910f29556b740513421b57da9c5a97.zip
Added custom Exception with more descriptive error message
Diffstat (limited to 'src/test/test.py')
-rw-r--r--src/test/test.py41
1 files changed, 5 insertions, 36 deletions
diff --git a/src/test/test.py b/src/test/test.py
index 1aa9f0a..83e2718 100644
--- a/src/test/test.py
+++ b/src/test/test.py
@@ -6,32 +6,25 @@
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/27 11:36:32 by charles #+# #+# #
-# Updated: 2020/09/27 17:51:44 by charles ### ########.fr #
+# Updated: 2020/09/27 18:40:33 by charles ### ########.fr #
# #
# ############################################################################ #
-import re
-import time
import subprocess
-# import threading
+import config
import test.philo as philo
-
-class Test: #(threading.Thread):
+class Test:
_tests = []
_exec_path = None
- # _stdout_lock = threading.Lock()
@classmethod
def run_all(cls, exec_path: str):
cls._exec_path = exec_path
for t in cls._tests:
t.run()
- # threads = [test.start() for test in cls._tests]
- # for thread in threads:
- # thread.join()
def __init__(
self,
@@ -48,7 +41,6 @@ class Test: #(threading.Thread):
self._timeout_sleep = timeout_sleep
self._meal_num = meal_num
Test._tests.append(self)
- # threading.Thread.__init__(self)
def run(self):
argv = [
@@ -60,40 +52,17 @@ class Test: #(threading.Thread):
]
if self._meal_num is not None:
argv.append(str(self._meal_num))
- # try:
process = subprocess.Popen(
argv,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
- # output = process_result.stdout.decode()
- # print(output)
- # timeout=1,
- # except subprocess.TimeoutExpered as err:
- # return Result(err)
- # except subprocess.CalledProcessError as err:
- # return Result(err)
-
self._check_output(process.stdout)
- process.wait()
+ process.wait(timeout=config.TIMEOUT)
def _check_output(self, stream):
table = philo.Table(self._philo_num, self._timeout_eat)
-
for line in stream:
line = line.decode()[:-1]
- # print(">", line)
- l = philo.Log(line, self._philo_num)
- print(l)
- table.add_log(l)
+ table.add_log(philo.Log(line, self._philo_num))
table.check()
-
- # print(timestamp, id_, event)
-
-
- # philo_states.append(Philo)
-
- # def _print(self, *args):
- # Test._stdout_lock.aquire()
- # print(*args)
- # Test._stdout_lock.release()