Index: lit/TestRunner.py =================================================================== --- lit/TestRunner.py +++ lit/TestRunner.py @@ -205,7 +205,20 @@ # env FOO=1 llc < %s | env BAR=2 llvm-mc | FileCheck %s cmd_shenv = ShellEnvironment(shenv.cwd, shenv.env) arg_idx = 1 + unset_next_env_var = False for arg_idx, arg in enumerate(j.args[1:]): + # Support for the -u flag (unsetting) for env command + # e.g., env -u FOO -u BAR will remove both FOO and BAR + # from the environment. + if arg == '-u': + unset_next_env_var = True + continue + if unset_next_env_var: + unset_next_env_var = False + if arg in cmd_shenv.env: + del cmd_shenv.env[arg] + continue + # Partition the string into KEY=VALUE. key, eq, val = arg.partition('=') # Stop if there was no equals.