Files
carbon-lang/explorer/autoupdate_trace_testdata.py
T
Prabhat Sachdeva 45c185ebf7 Add -trace_phase option that takes list of allowed phases (#2962)
## Description
For filtering the trace output, we currently pass flags like
`-trace_type_checking`, `-trace_execution` etc individually and these
can be passed in a combination.
This PR introduces `-trace_phase` flag that takes a list of the
following options:
- `name_resolution`: Include trace output for the name resolution phase.
-   `control_flow_resolution`: Include trace output for the control flow
    resolution phase.
-   `type_checking`: Include trace output for the type checking phase.
- `unformed_variables_resolution`: Include trace output for the unformed
    variables resolution phase.
-   `declarations`: Include trace output for printing declarations.
-   `execution`: Include trace output for program execution.
- `timing`: Include timing logs indicating the time taken by each phase.
-   `all`: Include trace output for all phases. 

### Example usage:
```
bazel run //explorer -- <program_location> --trace_file=... -trace_phase=type_checking,execution,declarations
```
2023-06-29 20:30:45 +00:00

36 lines
957 B
Python
Executable File

#!/usr/bin/env python3
"""Updates the CHECK: lines in tests with an AUTOUPDATE line."""
__copyright__ = """
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
Exceptions. See /LICENSE for license information.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""
import subprocess
import sys
from pathlib import Path
def main() -> None:
# Subprocess to the main script in order to avoid Python import behaviors.
this_py = Path(__file__).resolve()
autoupdate_py = this_py.parent.parent.joinpath(
"testing", "scripts", "autoupdate_testdata_base.py"
)
args = [
str(autoupdate_py),
# Flags to configure for explorer testing.
"--tool=explorer",
"--testdata=explorer/trace_testdata",
"--autoupdate_arg=--trace_file=-",
"--autoupdate_arg=-trace_phase=all",
] + sys.argv[1:]
exit(subprocess.call(args))
if __name__ == "__main__":
main()