aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hooks.py7
-rwxr-xr-xsrc/main.py5
-rw-r--r--src/test/test.py23
3 files changed, 24 insertions, 11 deletions
diff --git a/src/hooks.py b/src/hooks.py
index 2d55bbb..5ec2dde 100644
--- a/src/hooks.py
+++ b/src/hooks.py
@@ -6,12 +6,13 @@
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/11 16:10:20 by charles #+# #+# #
-# Updated: 2020/10/07 15:18:13 by cacharle ### ########.fr #
+# Updated: 2020/10/08 11:43:54 by cacharle ### ########.fr #
# #
# ############################################################################ #
import re
import sys
+import os
import config
@@ -23,6 +24,10 @@ def sort_lines(output):
def error_line0(output):
"""Replace "/bin/bash: -c: line 0:" by "minishell:" and delete the second line"""
+ error_message = os.environ.get("MINISHELL_TEST_DONT_CHECK_ERROR_MESSAGE")
+ if error_message is not None and error_message == "yes":
+ return "DISCARDED BY TEST"
+
lines = output.split('\n')
if len(lines) != 3:
return output
diff --git a/src/main.py b/src/main.py
index 2b70393..05e9158 100755
--- a/src/main.py
+++ b/src/main.py
@@ -66,7 +66,7 @@ def main():
config.CHECK_LEAKS = args.check_leaks
config.RANGE = args.range
config.SHOW_RANGE = args.show_range
- if config.RANGE is not None:
+ if config.RANGE is not None or config.CHECK_LEAKS:
config.SHOW_RANGE = True
Suite.setup(args.suites)
@@ -78,6 +78,9 @@ def main():
Suite.summarize()
Suite.save_log()
print("See", config.LOG_PATH, "for more information")
+ if config.CHECK_LEAKS:
+ print("HELP: Valgrind is really slow the -x and --range options could be useful"
+ " (./run -h for more details)")
if args.pager:
subprocess.run([config.PAGER, config.LOG_PATH])
diff --git a/src/test/test.py b/src/test/test.py
index 542a9d8..6668573 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/10/08 08:45:34 by cacharle ### ########.fr #
+# Updated: 2020/10/08 10:05:39 by cacharle ### ########.fr #
# #
# ############################################################################ #
@@ -62,19 +62,13 @@ class Test:
self.hook = []
self.hook_status = []
captured = self._run_sandboxed([*config.VALGRIND_CMD, "-c"])
- self.result = Result.leak(self.cmd, captured.output)
+ self.result = Result.leak(self.full_cmd, captured.output)
self.result.put(index)
return
expected = self._run_sandboxed([config.REFERENCE_PATH, *config.REFERENCE_ARGS, "-c"])
actual = self._run_sandboxed([config.MINISHELL_PATH, "-c"])
- s = self.cmd
- if self.setup != "":
- s = "[SETUP {}] {}".format(self.setup, s)
- if len(self.exports) != 0:
- s = "[EXPORTS {}] {}".format(
- ' '.join(["{}='{:.20}'".format(k, v) for k, v in self.exports.items()]), s)
- self.result = Result(s, self.files, expected, actual)
+ self.result = Result(self.full_cmd, self.files, expected, actual)
self.result.put(index)
def _run_sandboxed(self, shell_cmd: [str]) -> Captured:
@@ -146,3 +140,14 @@ class Test:
for h in self.hook_status:
process.returncode = h(process.returncode)
return Captured(output, process.returncode, files_content)
+
+ @property
+ def full_cmd(self):
+ """ Return the command prefixed by the setup and exports """
+ s = self.cmd
+ if self.setup != "":
+ s = "[SETUP {}] {}".format(self.setup, s)
+ if len(self.exports) != 0:
+ s = "[EXPORTS {}] {}".format(
+ ' '.join(["{}='{:.20}'".format(k, v) for k, v in self.exports.items()]), s)
+ return s