From: Matthew Fernandez Date: Sat, 17 Dec 2022 19:34:18 +0000 (-0800) Subject: add a variant of #2272 test case X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e6593da70fe2397ee15072794bcbc7d6fac173da;p=graphviz add a variant of #2272 test case While working on Small String Optimization, it became clear that a variant of this test case which just passes an invalid string through the Graphviz binary provokes some non-trivial behavior which is worth testing. Gitlab: #2272 --- diff --git a/tests/test_regression.py b/tests/test_regression.py index faa79a365..1d69e9f3d 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -1973,6 +1973,21 @@ def test_2272(): # run the test run_c(c_src, link=["cgraph", "gvc"]) +def test_2272_2(): + """ + An unterminated string in the source should not crash Graphviz. Variant of + `test_2272`. + """ + + # a graph with an open string + graph = 'graph { a[label="abc' + + # process it with Graphviz, which should not crash + p = subprocess.run(["dot", "-o", os.devnull], input=graph, + universal_newlines=True) + assert p.returncode != 0, "dot accepted invalid input" + assert p.returncode == 1, "dot crashed" + def test_2282(): """ using the `fdp` layout with JSON output should result in valid JSON