Skip to content

Commit a688e0e

Browse files
Merge branch 'topic/log_files' into 'master'
Improve the replay.py script See merge request eng/ide/ada_language_server!1418
2 parents c317f66 + b39d2e0 commit a688e0e

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ formatting might no succeed on incomplete/illegal code.
144144

145145
You can use the VS Code `Issue Reporter` to report issues. Just click on the `Help -> Report Issue` menu, select `An extension` for the `File on` entry and `Language Support for Ada` for the extension name. Put as many information you can in the description, like steps to reproduce, stacktraces or system information (VS Code automatically includes it by default). This will create a GitHub issue in the [Ada Language Server](https://github.com/AdaCore/ada_language_server/) repository.
146146

147+
ALS log files can be found under the `~/.als` directory (`%USERPROFILE%/.als` on Windows). Feel free to attach them on the issues, it helps a lot for further investigation, specially when the `ALS.IN` and `ALS.OUT` traces are enabled (more info about traces configuration can be found [here](doc/traces.md).)
148+
147149

148150
### Getting started
149151

scripts/replay.py

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,44 @@
11
#!/usr/bin/env python
22

3-
""" Development utility to replay the most recent trace file, and output it
4-
as protocol strings. This assumes that the trace file is in ~/.als/in.txt
5-
6-
To use this, do
7-
8-
replay.py > log
9-
10-
then you can replay at will with
3+
"""
4+
Development utility to replay an ALS session based on a log file containing
5+
the ALS.IN and ALS.OUT traces, and output it as protocol strings.
116
12-
ada_language_server < log
7+
Usage: replay.py --log-file <path_to_log_file> --output-file <output_file>
138
"""
149

15-
import os
10+
import argparse
1611
from json_transformations import python_to_protocol_string, traces_to_test
1712

18-
als_dir = os.path.join(os.path.expanduser('~'), '.als')
19-
inout_file = os.path.join(als_dir, 'inout.txt')
13+
14+
argParser = argparse.ArgumentParser()
15+
argParser.add_argument(
16+
"-l",
17+
"--log-file",
18+
help="Path to the log file containing ALS.IN and ALS.OUT traces.",
19+
required=True,
20+
)
21+
argParser.add_argument(
22+
"-o",
23+
"--output-file",
24+
help="Path to the output file containing all the ALS requests retrieved "
25+
+ "from the log file. Then you can replay a session like this: "
26+
+ "ada_language_server < <output_file>",
27+
required=False,
28+
)
29+
args = argParser.parse_args()
30+
31+
inout_file = args.log_file
32+
output_file = args.output_file
2033
test = traces_to_test(inout_file, None, True)
2134
result = ""
2235
for x in test:
2336
if "send" in x:
2437
result += python_to_protocol_string([x["send"]["request"]])
25-
print(result + "\r")
38+
39+
# Print on stdout if no output file has been specified
40+
if output_file:
41+
with open(output_file, "w") as file:
42+
file.write(result + "\r")
43+
else:
44+
print(result + "\r")

0 commit comments

Comments
 (0)