diff options
| -rw-r--r-- | src/config.py | 6 | ||||
| -rw-r--r-- | src/suite/decorator.py | 8 | ||||
| -rw-r--r-- | src/suite/suite.py | 11 | ||||
| -rw-r--r-- | src/test/captured.py | 13 | ||||
| -rw-r--r-- | src/test/test.py | 8 |
5 files changed, 27 insertions, 19 deletions
diff --git a/src/config.py b/src/config.py index 075f2be..493652c 100644 --- a/src/config.py +++ b/src/config.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:19 by charles #+# #+# # -# Updated: 2021/01/31 03:29:05 by charles ### ########.fr # +# Updated: 2021/01/31 04:41:29 by charles ### ########.fr # # # # ############################################################################ # @@ -89,8 +89,8 @@ MINISHELL_PATH = os.path.abspath( os.path.join(MINISHELL_DIR, MINISHELL_EXEC) ) -VALGRIND_CMD = [ - distutils.spawn.find_executable("valgrind"), +VALGRIND_CMD: List[str] = [ + distutils.spawn.find_executable("valgrind") or "couldn't find valgrind", # "valgrind", "--trace-children=no", "--leak-check=yes", diff --git a/src/suite/decorator.py b/src/suite/decorator.py index e9f9efa..87787de 100644 --- a/src/suite/decorator.py +++ b/src/suite/decorator.py @@ -6,16 +6,18 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:28:00 by charles #+# #+# # -# Updated: 2021/01/31 02:13:40 by charles ### ########.fr # +# Updated: 2021/01/31 04:45:08 by charles ### ########.fr # # # # ############################################################################ # +import inspect +from typing import List + from suite import Suite from test import Test -import inspect -def suite(groups: list[str] = [], bonus: bool = False): +def suite(groups: List[str] = [], bonus: bool = False): """Decorator generator for suites arguments""" def suite_wrapper(origin): diff --git a/src/suite/suite.py b/src/suite/suite.py index ef01784..f3d58b1 100644 --- a/src/suite/suite.py +++ b/src/suite/suite.py @@ -6,12 +6,12 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:29 by charles #+# #+# # -# Updated: 2021/01/31 03:31:15 by charles ### ########.fr # +# Updated: 2021/01/31 04:40:22 by charles ### ########.fr # # # # ############################################################################ # import sys -from typing import List, Tuple +from typing import List, Tuple, Optional, Callable import config from test import Test @@ -68,7 +68,8 @@ class Suite: )) cls.available.sort(key=lambda s: s.name) for s in cls.available: - s.generator_func() + if s.generator_func is not None: + s.generator_func() @classmethod def available_names(cls) -> List[str]: @@ -107,7 +108,7 @@ class Suite: self.groups = groups self.description = description self.bonus = bonus - self.generator_func = None + self.generator_func: Optional[Callable] = None self.tests: List[Test] = [] def add(self, test): @@ -133,7 +134,7 @@ class Suite: if not (config.RANGE[0] <= i <= config.RANGE[1]): continue t.run(i) - if config.EXIT_FIRST and t.result.failed: + if config.EXIT_FIRST and t.result is not None and t.result.failed: return False if config.VERBOSE_LEVEL == 0: print() diff --git a/src/test/captured.py b/src/test/captured.py index 2c33b78..4cf9184 100644 --- a/src/test/captured.py +++ b/src/test/captured.py @@ -6,17 +6,23 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:16:25 by charles #+# #+# # -# Updated: 2021/01/31 03:29:22 by charles ### ########.fr # +# Updated: 2021/01/31 04:23:03 by charles ### ########.fr # # # # ############################################################################ # -from typing import List +from typing import List, Optional import config class Captured: - def __init__(self, output: str, status: int, files_content: List[str], is_timeout: bool = False): + def __init__( + self, + output: str, + status: int, + files_content: List[Optional[str]], + is_timeout: bool = False + ): """Captured class output: captured content status: command status @@ -29,7 +35,6 @@ class Captured: lines[i] = l.replace(config.REFERENCE_ERROR_BEGIN, config.MINISHELL_ERROR_BEGIN, 1) elif l.find(config.REFERENCE_PATH + ": ") == 0: lines[i] = l.replace(config.REFERENCE_PATH + ": ", config.MINISHELL_ERROR_BEGIN, 1) - self.output = '\n'.join(lines) self.status = status diff --git a/src/test/test.py b/src/test/test.py index 6f3aad5..1f8fa82 100644 --- a/src/test/test.py +++ b/src/test/test.py @@ -6,14 +6,14 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/06/16 21:48:50 by charles #+# #+# # -# Updated: 2021/01/31 03:55:43 by charles ### ########.fr # +# Updated: 2021/01/31 04:41:43 by charles ### ########.fr # # # # ############################################################################ # import os import sys import subprocess -from typing import Optional, List, Dict +from typing import Optional, List, Dict, Union import config from test.captured import Captured @@ -45,7 +45,7 @@ class Test: self.setup = setup self.files = files self.exports = exports - self.result: Optional[Result] = None + self.result: Optional[Union[Result, LeakResult]] = None self.timeout = timeout self.signal = signal self.hook = hook @@ -129,7 +129,7 @@ class Test: output = "UNICODE ERROR: {}".format(process.stdout) # capture watched files content - files_content = [] + files_content: List[Optional[str]] = [] for file_name in self.files: try: with open(os.path.join(config.SANDBOX_PATH, file_name), "rb") as f: |
