From 260b1ffc2cc6e2b83c68e6357417022db262f511 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Mon, 8 Dec 2025 09:37:11 +0800 Subject: [PATCH 1/3] compiletest: require `host`/`target` flags specified Instead of allowing them to be missing and using some placeholder "(none)" value instead. --- src/tools/compiletest/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index f3bd467db3e41..625d839dece1a 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -255,7 +255,9 @@ fn parse_config(args: Vec) -> Config { } } - let target = opt_str2(matches.opt_str("target")); + let host = matches.opt_str("host").expect("`--host` must be unconditionally specified"); + let target = matches.opt_str("target").expect("`--target` must be unconditionally specified"); + let android_cross_path = matches.opt_str("android-cross-path").map(Utf8PathBuf::from); // FIXME: `cdb_version` is *derived* from cdb, but it's *not* technically a config! let cdb = debuggers::discover_cdb(matches.opt_str("cdb"), &target); @@ -433,7 +435,7 @@ fn parse_config(args: Vec) -> Config { optimize_tests: matches.opt_present("optimize-tests"), rust_randomized_layout: matches.opt_present("rust-randomized-layout"), target, - host: opt_str2(matches.opt_str("host")), + host, cdb, cdb_version, gdb, From a7ad2142e35a1aa7e51b052b9ffad83e653e6340 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Mon, 8 Dec 2025 09:38:31 +0800 Subject: [PATCH 2/3] compiletest: make presence/absence of adb-related options clear Instead of possibly falling back to "(none)" when they are not specified. --- src/tools/compiletest/src/lib.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 625d839dece1a..cd875d78f2313 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -259,6 +259,13 @@ fn parse_config(args: Vec) -> Config { let target = matches.opt_str("target").expect("`--target` must be unconditionally specified"); let android_cross_path = matches.opt_str("android-cross-path").map(Utf8PathBuf::from); + + // FIXME: `adb_path` should be an `Option`... + let adb_path = matches.opt_str("adb-path").map(Utf8PathBuf::from).unwrap_or_default(); + // FIXME: `adb_test_dir` should be an `Option`... + let adb_test_dir = matches.opt_str("adb-test-dir").map(Utf8PathBuf::from).unwrap_or_default(); + let adb_device_status = target.contains("android") && !adb_test_dir.as_str().is_empty(); + // FIXME: `cdb_version` is *derived* from cdb, but it's *not* technically a config! let cdb = debuggers::discover_cdb(matches.opt_str("cdb"), &target); let cdb_version = cdb.as_deref().and_then(debuggers::query_cdb_version); @@ -445,11 +452,9 @@ fn parse_config(args: Vec) -> Config { llvm_version, system_llvm: matches.opt_present("system-llvm"), android_cross_path, - adb_path: Utf8PathBuf::from(opt_str2(matches.opt_str("adb-path"))), - adb_test_dir: Utf8PathBuf::from(opt_str2(matches.opt_str("adb-test-dir"))), - adb_device_status: opt_str2(matches.opt_str("target")).contains("android") - && "(none)" != opt_str2(matches.opt_str("adb-test-dir")) - && !opt_str2(matches.opt_str("adb-test-dir")).is_empty(), + adb_path, + adb_test_dir, + adb_device_status, verbose: matches.opt_present("verbose"), only_modified: matches.opt_present("only-modified"), color, From 72541e9a511f4844000ca42a60516eddb2bfa892 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Mon, 8 Dec 2025 09:41:46 +0800 Subject: [PATCH 3/3] compiletest: retire `opt_str2` We either have the value of a flag specified, or we don't. Use `Option<...>` to represent that -- don't invent a new "(none)" sentinel value... --- src/tools/compiletest/src/lib.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index cd875d78f2313..ff4cd81d33ff6 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -500,13 +500,6 @@ fn parse_config(args: Vec) -> Config { } } -fn opt_str2(maybestr: Option) -> String { - match maybestr { - None => "(none)".to_owned(), - Some(s) => s, - } -} - /// Called by `main` after the config has been parsed. fn run_tests(config: Arc) { debug!(?config, "run_tests");