xref: /aosp_15_r20/external/pytorch/torchgen/_autoheuristic/test_utils.py (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1import subprocess
2
3
4def read_file_to_string(file_path: str) -> str:
5    with open(file_path) as file:
6        return file.read()
7
8
9def run_bash(bash_script_path: str) -> None:
10    try:
11        print("Executing: ", bash_script_path)
12        result = subprocess.run(
13            ["bash", bash_script_path], capture_output=True, text=True, check=True
14        )
15        # Print the output
16        print(f"Output of {bash_script_path}: {result.stdout}")
17    except subprocess.CalledProcessError as e:
18        print(f"An error occurred executing {bash_script_path}: {e}")
19        print("Error output:", e.stderr)
20