diff options
Diffstat (limited to 'llvm/utils/UpdateTestChecks/common.py')
-rw-r--r-- | llvm/utils/UpdateTestChecks/common.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 4598475..449ccb0 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -2,6 +2,7 @@ from __future__ import print_function import copy import glob +import os import re import subprocess import sys @@ -141,11 +142,23 @@ def should_add_line_to_output(input_line, prefix_set, skip_global_checks = False return True # Invoke the tool that is being tested. -def invoke_tool(exe, cmd_args, ir): +def invoke_tool(exe, cmd_args, ir, preprocess_cmd=None, verbose=False): with open(ir) as ir_file: # TODO Remove the str form which is used by update_test_checks.py and # update_llc_test_checks.py # The safer list form is used by update_cc_test_checks.py + if preprocess_cmd: + # Allow pre-processing the IR file (e.g. using sed): + assert isinstance(preprocess_cmd, str) # TODO: use a list instead of using shell + preprocess_cmd = preprocess_cmd.replace('%s', ir).strip() + if verbose: + print('Pre-processing input file: ', ir, " with command '", + preprocess_cmd, "'", sep="", file=sys.stderr) + # Python 2.7 doesn't have subprocess.DEVNULL: + with open(os.devnull, 'w') as devnull: + pp = subprocess.Popen(preprocess_cmd, shell=True, stdin=devnull, + stdout=subprocess.PIPE) + ir_file = pp.stdout if isinstance(cmd_args, list): stdout = subprocess.check_output([exe] + cmd_args, stdin=ir_file) else: |