Skip to content

Commit 1961672

Browse files
Record command executed in the stats file
1 parent e845d53 commit 1961672

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/python/pants/goal/stats_aggregator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __call__(
110110
# have an empty line between stats of different Pants invocations
111111
space = "\n\n" if Path(self.output_file).exists() else ""
112112
output_lines.append(
113-
f"{space}{timestamp} Executing goals: {','.join(context._run_tracker.goals)}"
113+
f"{space}{timestamp} Command: {context.run_tracker.run_information().get('cmd_line')}"
114114
)
115115

116116
if self.log:

src/python/pants/goal/stats_aggregator_integration_test.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,29 @@ def test_warn_if_no_histograms() -> None:
5151

5252
def test_writing_to_output_file() -> None:
5353
with setup_tmpdir({"src/py/app.py": "print(0)\n", "src/py/BUILD": "python_sources()"}):
54-
argv = [
54+
argv1 = [
5555
"--backend-packages=['pants.backend.python']",
5656
"--stats-log",
5757
"--stats-memory-summary",
5858
"--stats-output-file=stats.txt",
5959
"roots",
6060
]
61-
run_pants(argv).assert_success()
62-
argv = [
61+
run_pants(argv1).assert_success()
62+
argv2 = [
6363
"--backend-packages=['pants.backend.python']",
6464
"--stats-log",
6565
"--stats-memory-summary",
6666
"--stats-output-file=stats.txt",
6767
"list",
6868
"::",
6969
]
70-
run_pants(argv).assert_success()
70+
run_pants(argv2).assert_success()
7171
output_file_contents = Path("stats.txt").read_text()
7272
for item in ("Counters:", "Memory summary"):
7373
assert output_file_contents.count(item) == 2
7474

7575
for item in ("roots", "list"):
7676
assert item in output_file_contents
77+
78+
for cmd in (argv1, argv2):
79+
assert " ".join(cmd) in output_file_contents

0 commit comments

Comments
 (0)