input = "graph {subgraph cluster_a {}; cluster_a -- b}"
# fdp should be able to process this
- p = subprocess.Popen(["fdp", "-o", os.devnull], stdin=subprocess.PIPE,
+ subprocess.run(["fdp", "-o", os.devnull], input=input, check=True,
universal_newlines=True)
- p.communicate(input)
- assert p.returncode == 0
def test_1880():
"""
input = "digraph { a -> b; }"
# ask gv2gml what it thinks of this
- p = subprocess.Popen(["gv2gml"], stdin=subprocess.PIPE,
- universal_newlines=True)
- p.communicate(input)
-
- assert p.returncode == 0, "gv2gml rejected a basic graph"
+ try:
+ subprocess.run(["gv2gml"], input=input, check=True,
+ universal_newlines=True)
+ except subprocess.CalledProcessError as e:
+ raise RuntimeError("gv2gml rejected a basic graph") from e
@pytest.mark.skipif(shutil.which("gvpr") is None,
reason="gvpr not available")
'}'
# pass this through gvmap
- p = subprocess.Popen(["gvmap"], stdin=subprocess.PIPE)
- p.communicate(input.encode("utf-8"))
-
- assert p.returncode == 0
+ subprocess.run(["gvmap"], input=input.encode("utf-8"), check=True)
# run edgepaint on this
args = ["edgepaint"] + arg.split(" ")
- p = subprocess.Popen(args, stdin=subprocess.PIPE, universal_newlines=True)
- p.communicate(input)
-
- assert p.returncode == 0, f"edgepaint rejected command line option '{arg}'"
+ try:
+ subprocess.run(args, input=input, check=True, universal_newlines=True)
+ except subprocess.CalledProcessError as e:
+ raise RuntimeError(f"edgepaint rejected command line option '{arg}'") from e
"""
from pathlib import Path
-from subprocess import Popen, PIPE
+import subprocess
import sys
# Import helper function to compare graphs from tests/regressions_tests
Path("output").mkdir(parents=True)
output_file = Path("output") / f"{shape}.{output_type}"
- process = Popen(["dot", "-T" + output_type, "-o", output_file], stdin=PIPE)
-
input_graph = f'graph G {{ a [label="" shape={shape}] }}'
- process.communicate(input = input_graph.encode("utf_8"))
-
- if process.wait() != 0:
+ try:
+ subprocess.run(["dot", f"-T{output_type}", "-o", output_file],
+ input=input_graph.encode("utf_8"), check=True)
+ except subprocess.CalledProcessError:
print(f"An error occurred while generating: {output_file}")
sys.exit(1)
import os.path
from pathlib import Path
-from subprocess import Popen, PIPE
+import subprocess
import sys
import pytest
Path("output").mkdir(parents=True)
output_file = Path("output") / f"{shape}.{output_type}"
- process = Popen(["dot", "-T" + output_type, "-o", output_file], stdin=PIPE)
-
input_graph = f'graph G {{ a [label="" shape={shape}] }}'
- process.communicate(input = input_graph.encode("utf_8"))
-
- if process.wait() != 0:
+ try:
+ subprocess.run(["dot", f"-T{output_type}", "-o", output_file],
+ input=input_graph.encode("utf_8"), check=True)
+ except subprocess.CalledProcessError:
print(f"An error occurred while generating: {output_file}")
sys.exit(1)
FIXME: this should probably be integrated into ../../../rtest/test_regression.py
"""
-from subprocess import Popen, PIPE
+import subprocess
import sys
from pathlib import Path
output_file = Path("output") / f"{vulnfile}.{output_type[0]}"
input_file = Path("input") / f"{vulnfile}.dot"
- process = Popen(["dot", "-T" + output_type[1], "-o", output_file, input_file], stdin=PIPE)
-
- if process.wait() < 0:
+ try:
+ subprocess.check_call(["dot", f"-T{output_type[1]}", "-o", output_file,
+ input_file])
+ except subprocess.CalledProcessError:
print(f"An error occurred while generating: {output_file}")
sys.exit(1)