aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/result.py10
-rw-r--r--src/test/test.py28
2 files changed, 21 insertions, 17 deletions
diff --git a/src/test/result.py b/src/test/result.py
index c64f20a..5e7c2e9 100644
--- a/src/test/result.py
+++ b/src/test/result.py
@@ -6,7 +6,7 @@
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/11 12:17:34 by charles #+# #+# #
-# Updated: 2020/09/11 22:20:03 by charles ### ########.fr #
+# Updated: 2020/10/06 16:56:30 by cacharle ### ########.fr #
# #
# ############################################################################ #
@@ -80,10 +80,10 @@ class Result:
return self.green('.') if self.passed else self.red('!')
elif config.VERBOSE_LEVEL == 1:
printed = self.escaped_cmd[:]
- if len(printed) > 70:
- printed = printed[:67] + "..."
- fmt = self.green("{:74} [PASS]") if self.passed else self.red("{:74} [FAIL]")
- return fmt.format(printed)
+ if len(printed) > config.TERM_COLS - 7:
+ printed = printed[:config.TERM_COLS - 10] + "..."
+ fmt = self.green("{:{width}} [PASS]") if self.passed else self.red("{:{width}} [FAIL]")
+ return fmt.format(printed, width=config.TERM_COLS - 7)
elif config.VERBOSE_LEVEL == 2:
return self.full_diff()
else:
diff --git a/src/test/test.py b/src/test/test.py
index c37a865..da013d1 100644
--- a/src/test/test.py
+++ b/src/test/test.py
@@ -6,7 +6,7 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/06/16 21:48:50 by charles #+# #+# #
-# Updated: 2020/09/17 11:05:46 by charles ### ########.fr #
+# Updated: 2020/10/06 15:54:12 by cacharle ### ########.fr #
# #
# ############################################################################ #
@@ -29,15 +29,17 @@ class Test:
exports: {str: str} = {},
timeout: float = config.TIMEOUT,
signal=None,
- hook=[]):
- """Test class
- cmd: command to execute
- setup: command to execute before tested command
- files: files to watch (check content after test)
- exports: exported variables
- timeout: maximum amount of time taken by the test
- signal: signal to send to the test
- hook: function to execute on the output of the test
+ hook=[],
+ hook_status=[]):
+ """ Test class
+ cmd: command to execute
+ setup: command to execute before tested command
+ files: files to watch (check content after test)
+ exports: exported variables
+ timeout: maximum amount of time taken by the test
+ signal: signal to send to the test
+ hook: function to execute on the output of the test
+ hook_status: function to execute on status code
"""
self.cmd = cmd
self.setup = setup
@@ -47,11 +49,12 @@ class Test:
self.timeout = timeout
self.signal = signal
self.hook = hook
+ self.hook_status = hook_status
if type(self.hook) is not list:
self.hook = [self.hook]
def run(self):
- """Run the test for minishell and the reference shell and print the result out"""
+ """ Run the test for minishell and the reference shell and print the result out """
expected = self._run_sandboxed(config.REFERENCE_PATH, config.REFERENCE_ARGS + ["-c"])
actual = self._run_sandboxed(config.MINISHELL_PATH, ["-c"])
s = self.cmd
@@ -130,5 +133,6 @@ class Test:
# sandbox.remove()
for h in self.hook:
output = h(output)
-
+ for h in self.hook_status:
+ process.returncode = h(process.returncode)
return Captured(output, process.returncode, files_content)