Skip to content

Commit f93bf4d

Browse files
authored
Do not pluralize "file" in progress message if there is only one (#3746)
1 parent da4de3b commit f93bf4d

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

rust/private/rustc.bzl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,11 +1424,12 @@ def rustc_compile_action(
14241424
env = env,
14251425
arguments = args.all,
14261426
mnemonic = "Rustc",
1427-
progress_message = "Compiling Rust {} {}{} ({} files)".format(
1427+
progress_message = "Compiling Rust {} {}{} ({} file{})".format(
14281428
crate_info.type,
14291429
ctx.label.name,
14301430
formatted_version,
14311431
len(srcs),
1432+
"" if len(srcs) == 1 else "s",
14321433
),
14331434
toolchain = "@rules_rust//rust:toolchain_type",
14341435
resource_set = get_rustc_resource_set(toolchain),
@@ -1441,11 +1442,12 @@ def rustc_compile_action(
14411442
env = env,
14421443
arguments = args_metadata.all,
14431444
mnemonic = "RustcMetadata",
1444-
progress_message = "Compiling Rust metadata {} {}{} ({} files)".format(
1445+
progress_message = "Compiling Rust metadata {} {}{} ({} file{})".format(
14451446
crate_info.type,
14461447
ctx.label.name,
14471448
formatted_version,
14481449
len(srcs),
1450+
"" if len(srcs) == 1 else "s",
14491451
),
14501452
toolchain = "@rules_rust//rust:toolchain_type",
14511453
)
@@ -1460,11 +1462,12 @@ def rustc_compile_action(
14601462
env = env,
14611463
arguments = [args.rustc_path, args.rustc_flags],
14621464
mnemonic = "Rustc",
1463-
progress_message = "Compiling Rust (without process_wrapper) {} {}{} ({} files)".format(
1465+
progress_message = "Compiling Rust (without process_wrapper) {} {}{} ({} file{})".format(
14641466
crate_info.type,
14651467
ctx.label.name,
14661468
formatted_version,
14671469
len(srcs),
1470+
"" if len(srcs) == 1 else "s",
14681471
),
14691472
toolchain = "@rules_rust//rust:toolchain_type",
14701473
resource_set = get_rustc_resource_set(toolchain),

test/unit/is_proc_macro_dep/is_proc_macro_dep_test.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ is_proc_macro_dep_is_not_in_env_for_top_level_action_test = analysistest.make(_i
6565
def _is_proc_macro_dep_is_false_for_proc_macro(ctx):
6666
env = analysistest.begin(ctx)
6767
tut = analysistest.target_under_test(env)
68-
proc_macro_dep_action = [a for a in tut[DepActionsInfo].actions if str(a) == "action 'Compiling Rust proc-macro proc_macro_crate (1 files)'"][0]
68+
proc_macro_dep_action = [a for a in tut[DepActionsInfo].actions if str(a) == "action 'Compiling Rust proc-macro proc_macro_crate (1 file)'"][0]
6969
asserts.equals(env, proc_macro_dep_action.env["BAZEL_RULES_RUST_IS_PROC_MACRO_DEP"], "0")
7070
return analysistest.end(env)
7171

@@ -74,7 +74,7 @@ is_proc_macro_dep_is_false_for_proc_macro_test = analysistest.make(_is_proc_macr
7474
def _is_proc_macro_dep_is_false_for_top_level_library(ctx):
7575
env = analysistest.begin(ctx)
7676
tut = analysistest.target_under_test(env)
77-
top_level_library_action = [a for a in tut[DepActionsInfo].actions if str(a) == "action 'Compiling Rust rlib top_level_library (1 files)'"][0]
77+
top_level_library_action = [a for a in tut[DepActionsInfo].actions if str(a) == "action 'Compiling Rust rlib top_level_library (1 file)'"][0]
7878
asserts.equals(env, top_level_library_action.env["BAZEL_RULES_RUST_IS_PROC_MACRO_DEP"], "0")
7979
return analysistest.end(env)
8080

@@ -83,7 +83,7 @@ is_proc_macro_dep_is_false_for_top_level_library_test = analysistest.make(_is_pr
8383
def _is_proc_macro_dep_is_true_for_proc_macro_dep(ctx):
8484
env = analysistest.begin(ctx)
8585
tut = analysistest.target_under_test(env)
86-
proc_macro_dep_action = [a for a in tut[DepActionsInfo].actions if str(a) == "action 'Compiling Rust rlib proc_macro_dep (1 files)'"][0]
86+
proc_macro_dep_action = [a for a in tut[DepActionsInfo].actions if str(a) == "action 'Compiling Rust rlib proc_macro_dep (1 file)'"][0]
8787
asserts.equals(env, proc_macro_dep_action.env["BAZEL_RULES_RUST_IS_PROC_MACRO_DEP"], "1")
8888
return analysistest.end(env)
8989

@@ -92,7 +92,7 @@ is_proc_macro_dep_is_true_for_proc_macro_dep_test = analysistest.make(_is_proc_m
9292
def _is_proc_macro_dep_is_not_in_env_for_proc_macro_dep(ctx):
9393
env = analysistest.begin(ctx)
9494
tut = analysistest.target_under_test(env)
95-
proc_macro_dep_action = [a for a in tut[DepActionsInfo].actions if str(a) == "action 'Compiling Rust rlib proc_macro_dep (1 files)'"][0]
95+
proc_macro_dep_action = [a for a in tut[DepActionsInfo].actions if str(a) == "action 'Compiling Rust rlib proc_macro_dep (1 file)'"][0]
9696
asserts.true(env, "BAZEL_RULES_RUST_IS_PROC_MACRO_DEP" not in proc_macro_dep_action.env)
9797
return analysistest.end(env)
9898

0 commit comments

Comments
 (0)