siso: Fix flag print handling

The siso ninja command is printed unintentionally because log collection
flags are appended. This CL also fixes the wrong expectations in the
tests.

Change-Id: I3d893234c7388e026f7888d40633620287207ebc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7742783
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Auto-Submit: Junji Watanabe <jwata@google.com>
Commit-Queue: Junji Watanabe <jwata@google.com>
changes/83/7742783/6
Junji Watanabe 2 weeks ago committed by infra-scoped@luci-project-accounts.iam.gserviceaccount.com
parent de15c6313c
commit bac00505a8

@ -552,6 +552,9 @@ def main(args: list[str],
return 1
global_flags, subcmd_flags = load_sisorc(
os.path.join(base_path, 'build', 'config', 'siso', '.sisorc'))
should_print_flags = False
if global_flags:
should_print_flags = True
siso_paths = [
siso_override_path,
os.path.join(base_path, 'third_party', 'siso', 'cipd',
@ -573,7 +576,10 @@ def main(args: list[str],
if subcmd:
# Apply subcommand-specific flags from .sisorc
subcmd_args = subcmd_flags.get(subcmd, []) + subcmd_args
sub_flags = subcmd_flags.get(subcmd, [])
if sub_flags:
should_print_flags = True
subcmd_args = sub_flags + subcmd_args
# fast_nop, fast_local, fast_last_failure, fast_exit are set
# to false when stdout is not a TTY (see
@ -607,7 +613,7 @@ def main(args: list[str],
else:
new_args = pre_args
if args[1:] != new_args:
if should_print_flags:
print('depot_tools/siso.py: %s' % shlex.join(new_args),
file=sys.stderr)
check_outdir(out_dir)

@ -702,11 +702,7 @@ def test_handle_collector_remove_socket_file_fails(siso_test_fixture: Any,
f"type=developer,tool=siso,host_os={siso._SYSTEM_DICT.get(sys.platform, sys.platform)}",
"--namespace=developer",
],
"depot_tools/siso.py: %s\n" % shlex.join([
"ninja", "-C", "out/Default", "--metrics_labels",
f"type=developer,tool=siso,host_os={siso._SYSTEM_DICT.get(sys.platform, sys.platform)}",
"--namespace=developer"
]),
"",
id="ninja_with_logs_no_project",
),
pytest.param(
@ -729,14 +725,7 @@ def test_handle_collector_remove_socket_file_fails(siso_test_fixture: Any,
"--enable_cloud_logging",
"--metrics_project=test-project",
],
"depot_tools/siso.py: %s\n" % shlex.join([
"ninja", "-C", "out/Default", "--project=test-project",
"--metrics_labels",
f"type=developer,tool=siso,host_os={siso._SYSTEM_DICT.get(sys.platform, sys.platform)}",
"--namespace=developer", "--enable_cloud_monitoring",
"--enable_cloud_profiler", "--enable_cloud_trace",
"--enable_cloud_logging", "--metrics_project=test-project"
]),
"",
id="ninja_with_logs_with_project_in_args",
),
pytest.param(
@ -758,13 +747,7 @@ def test_handle_collector_remove_socket_file_fails(siso_test_fixture: Any,
"--enable_cloud_logging",
"--metrics_project=test-project",
],
"depot_tools/siso.py: %s\n" % shlex.join([
"ninja", "-C", "out/Default", "--metrics_labels",
f"type=developer,tool=siso,host_os={siso._SYSTEM_DICT.get(sys.platform, sys.platform)}",
"--namespace=developer", "--enable_cloud_monitoring",
"--enable_cloud_profiler", "--enable_cloud_trace",
"--enable_cloud_logging", "--metrics_project=test-project"
]),
"",
id="ninja_with_logs_with_project_in_env",
),
pytest.param(

Loading…
Cancel
Save