aboutsummaryrefslogtreecommitdiff
path: root/prettier.py
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-11-04 21:01:21 +0100
committerCharles <sircharlesaze@gmail.com>2019-11-05 03:08:14 +0100
commita3ea830c6ecebcfe85356d10fb5263f45ea01956 (patch)
tree9fca944b27d2aefe0d0ef1b2b589576a063d5b2f /prettier.py
parent6ebaad27d92a5bb47fdf9618df12d3b4120f664e (diff)
downloadft_printf_test-a3ea830c6ecebcfe85356d10fb5263f45ea01956.tar.gz
ft_printf_test-a3ea830c6ecebcfe85356d10fb5263f45ea01956.tar.bz2
ft_printf_test-a3ea830c6ecebcfe85356d10fb5263f45ea01956.zip
Added iteractive mode and check with gcc -Wformat the generated test
before creating it
Diffstat (limited to 'prettier.py')
-rw-r--r--prettier.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/prettier.py b/prettier.py
index c58327d..439369c 100644
--- a/prettier.py
+++ b/prettier.py
@@ -21,11 +21,21 @@ def parse_args():
parser.add_argument("-l", "--no-log",
help="disable result log", action="store_true")
parser.add_argument("-c", "--no-clear", help="disable terminal clear before output")
+ parser.add_argument("-i", "--interactive", help="print fail as them come",
+ action="store_true")
parser.add_argument("-f", "--output-file", help="output file name")
return vars(parser.parse_args(sys.argv[1:]))
-def parse():
+def print_log_ko(ko, options):
+ print(f"- [{red(ko['type'])}] ft_printf({ko['args']})")
+ if options["verbose"]:
+ print(" expected: ", ko["expected"])
+ print(" actual: ", ko["actual"])
+ print()
+
+
+def parse(options):
logs = {
"ok": 0,
"ko": 0,
@@ -50,7 +60,11 @@ def parse():
"expected": m.group(3),
"actual": m.group(4),
})
- print(red("!"), end="")
+ if options["interactive"]:
+ print()
+ print_log_ko(logs["ko_info"][-1], options)
+ else:
+ print(red("!"), end="")
return logs
@@ -77,11 +91,7 @@ def print_logs(logs, options):
infos = logs["ko_info"][:20] if options["quiet"] else logs["ko_info"]
for ko in infos:
- print(f"- [{red(ko['type'])}] ft_printf({ko['args']})")
- if options["verbose"]:
- print(" expected: ", ko["expected"])
- print(" actual: ", ko["actual"])
- print()
+ print_log_ko(ko, options)
if options["quiet"] and logs["ko"] > 20:
print("...")
print("\nSee result.log for more information\n")
@@ -92,7 +102,7 @@ if __name__ == "__main__":
options = parse_args()
if not options["no_clear"]:
os.system("clear")
- logs = parse()
+ logs = parse(options)
print_logs(logs, options)
if not options["no_log"]:
write_logs(logs, options)