From 0cf5f137f886bd4e80868dcf2cf74b3f3b2c28d3 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 27 Feb 2021 15:43:07 +0100 Subject: Fixing #10 - bash error line with number 0 or 1 --- minishell_test/test/captured.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'minishell_test/test/captured.py') diff --git a/minishell_test/test/captured.py b/minishell_test/test/captured.py index a6141e8..e1ef29a 100644 --- a/minishell_test/test/captured.py +++ b/minishell_test/test/captured.py @@ -6,13 +6,14 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:16:25 by charles #+# #+# # -# Updated: 2021/02/27 12:20:00 by cacharle ### ########.fr # +# Updated: 2021/02/27 15:25:58 by cacharle ### ########.fr # # # # ############################################################################ # +import re from typing import List, Optional -# from minishell_test import config +from minishell_test import config class Captured: @@ -30,14 +31,12 @@ class Captured: is_timeout: the command has timed out """ - # lines = output.split('\n') - # for i, l in enumerate(lines): - # if l.find(config.REFERENCE_ERROR_BEGIN) == 0: - # 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 = output # '\n'.join(lines) + lines = output.split('\n') + for i, _ in enumerate(lines): + lines[i] = line = re.sub(f"line [01]: ", "", lines[i], 1) + if line.startswith(config.SHELL_REFERENCE_PREFIX): + lines[i] = config.MINISHELL_PREFIX + line[len(config.SHELL_REFERENCE_PREFIX):] + self.output = '\n'.join(lines) self.status = status self.files_content = files_content -- cgit