diff --git a/scripts/codemap.py b/scripts/codemap.py index f0d997aa..9b85fdf8 100755 --- a/scripts/codemap.py +++ b/scripts/codemap.py @@ -1247,6 +1247,10 @@ def main_(f, paths, *, line = canvas.draw(row) f.writeln(line) + if (args.get('error_on_recursion') + and mt.isinf(totals.get('stack', 0))): + sys.exit(2) + def main(paths, *, height=None, @@ -1496,6 +1500,10 @@ if __name__ == "__main__": '--no-label', action='store_true', help="Don't render any labels.") + parser.add_argument( + '-e', '--error-on-recursion', + action='store_true', + help="Error if any functions are recursive.") parser.add_argument( '--code-path', type=lambda x: x.split(), diff --git a/scripts/codemapd3.py b/scripts/codemapd3.py index 3640f49a..7240d6fb 100755 --- a/scripts/codemapd3.py +++ b/scripts/codemapd3.py @@ -1990,6 +1990,10 @@ def main(paths, output, *, totals.get('stack', 0)), totals.get('ctx', 0))) + if (args.get('error_on_recursion') + and mt.isinf(totals.get('stack', 0))): + sys.exit(2) + if __name__ == "__main__": import argparse @@ -2218,6 +2222,10 @@ if __name__ == "__main__": '--background', help="Background color to use. Note #00000000 can make the " "background transparent.") + parser.add_argument( + '-e', '--error-on-recursion', + action='store_true', + help="Error if any functions are recursive.") parser.add_argument( '--code-path', type=lambda x: x.split(),