Use named struct arguments instead of comment named args
This commit is contained in:
parent
607497d57c
commit
006c94cfa1
2 changed files with 74 additions and 67 deletions
|
@ -14,36 +14,42 @@ use std::iter::FromIterator;
|
||||||
|
|
||||||
use run_make_support::{rustc, tmp_dir};
|
use run_make_support::{rustc, tmp_dir};
|
||||||
|
|
||||||
fn main() {
|
struct PrintCfg {
|
||||||
check(
|
target: &'static str,
|
||||||
/*target*/ "x86_64-pc-windows-gnu",
|
includes: &'static [&'static str],
|
||||||
/*includes*/ &["windows", "target_arch=\"x86_64\""],
|
disallow: &'static [&'static str],
|
||||||
/*disallow*/ &["unix"],
|
|
||||||
);
|
|
||||||
check(
|
|
||||||
/*target*/ "i686-pc-windows-msvc",
|
|
||||||
/*includes*/ &["windows", "target_env=\"msvc\""],
|
|
||||||
/*disallow*/ &["unix"],
|
|
||||||
);
|
|
||||||
check(
|
|
||||||
/*target*/ "i686-apple-darwin",
|
|
||||||
/*includes*/ &["unix", "target_os=\"macos\"", "target_vendor=\"apple\""],
|
|
||||||
/*disallow*/ &["windows"],
|
|
||||||
);
|
|
||||||
check(
|
|
||||||
/*target*/ "i686-unknown-linux-gnu",
|
|
||||||
/*includes*/ &["unix", "target_env=\"gnu\""],
|
|
||||||
/*disallow*/ &["windows"],
|
|
||||||
);
|
|
||||||
check(
|
|
||||||
/*target*/ "arm-unknown-linux-gnueabihf",
|
|
||||||
/*includes*/ &["unix", "target_abi=\"eabihf\""],
|
|
||||||
/*disallow*/ &["windows"],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check(target: &str, includes: &[&str], disallow: &[&str]) {
|
fn main() {
|
||||||
fn _inner(output: &str, includes: &[&str], disallow: &[&str]) {
|
check(PrintCfg {
|
||||||
|
target: "x86_64-pc-windows-gnu",
|
||||||
|
includes: &["windows", "target_arch=\"x86_64\""],
|
||||||
|
disallow: &["unix"],
|
||||||
|
});
|
||||||
|
check(PrintCfg {
|
||||||
|
target: "i686-pc-windows-msvc",
|
||||||
|
includes: &["windows", "target_env=\"msvc\""],
|
||||||
|
disallow: &["unix"],
|
||||||
|
});
|
||||||
|
check(PrintCfg {
|
||||||
|
target: "i686-apple-darwin",
|
||||||
|
includes: &["unix", "target_os=\"macos\"", "target_vendor=\"apple\""],
|
||||||
|
disallow: &["windows"],
|
||||||
|
});
|
||||||
|
check(PrintCfg {
|
||||||
|
target: "i686-unknown-linux-gnu",
|
||||||
|
includes: &["unix", "target_env=\"gnu\""],
|
||||||
|
disallow: &["windows"],
|
||||||
|
});
|
||||||
|
check(PrintCfg {
|
||||||
|
target: "arm-unknown-linux-gnueabihf",
|
||||||
|
includes: &["unix", "target_abi=\"eabihf\""],
|
||||||
|
disallow: &["windows"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check(PrintCfg { target, includes, disallow }: PrintCfg) {
|
||||||
|
fn check_(output: &str, includes: &[&str], disallow: &[&str]) {
|
||||||
let mut found = HashSet::<String>::new();
|
let mut found = HashSet::<String>::new();
|
||||||
let mut recorded = HashSet::<String>::new();
|
let mut recorded = HashSet::<String>::new();
|
||||||
|
|
||||||
|
@ -82,7 +88,7 @@ fn check(target: &str, includes: &[&str], disallow: &[&str]) {
|
||||||
|
|
||||||
let stdout = String::from_utf8(output.stdout).unwrap();
|
let stdout = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
_inner(&stdout, includes, disallow);
|
check_(&stdout, includes, disallow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --print=cfg=PATH
|
// --print=cfg=PATH
|
||||||
|
@ -95,6 +101,6 @@ fn check(target: &str, includes: &[&str], disallow: &[&str]) {
|
||||||
|
|
||||||
let output = std::fs::read_to_string(&tmp_path).unwrap();
|
let output = std::fs::read_to_string(&tmp_path).unwrap();
|
||||||
|
|
||||||
_inner(&output, includes, disallow);
|
check_(&output, includes, disallow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,31 +7,37 @@ use std::ffi::OsString;
|
||||||
|
|
||||||
use run_make_support::{rustc, target, tmp_dir};
|
use run_make_support::{rustc, target, tmp_dir};
|
||||||
|
|
||||||
fn main() {
|
struct Option<'a> {
|
||||||
// Printed from CodegenBackend trait impl in rustc_codegen_llvm/src/lib.rs
|
target: &'a str,
|
||||||
check(
|
option: &'static str,
|
||||||
/*target*/ &target(),
|
includes: &'static [&'static str],
|
||||||
/*option*/ "relocation-models",
|
|
||||||
/*includes*/ &["dynamic-no-pic"],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs
|
|
||||||
check(
|
|
||||||
/*target*/ "wasm32-unknown-unknown",
|
|
||||||
/*option*/ "target-features",
|
|
||||||
/*includes*/ &["reference-types"],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Printed by C++ code in rustc_llvm/llvm-wrapper/PassWrapper.cpp
|
|
||||||
check(
|
|
||||||
/*target*/ "wasm32-unknown-unknown",
|
|
||||||
/*option*/ "target-cpus",
|
|
||||||
/*includes*/ &["generic"],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check(target: &str, option: &str, includes: &[&str]) {
|
fn main() {
|
||||||
fn _inner(output: &str, includes: &[&str]) {
|
// Printed from CodegenBackend trait impl in rustc_codegen_llvm/src/lib.rs
|
||||||
|
check(Option {
|
||||||
|
target: &target(),
|
||||||
|
option: "relocation-models",
|
||||||
|
includes: &["dynamic-no-pic"],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs
|
||||||
|
check(Option {
|
||||||
|
target: "wasm32-unknown-unknown",
|
||||||
|
option: "target-features",
|
||||||
|
includes: &["reference-types"],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Printed by C++ code in rustc_llvm/llvm-wrapper/PassWrapper.cpp
|
||||||
|
check(Option {
|
||||||
|
target: "wasm32-unknown-unknown",
|
||||||
|
option: "target-cpus",
|
||||||
|
includes: &["generic"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check(args: Option) {
|
||||||
|
fn check_(output: &str, includes: &[&str]) {
|
||||||
for i in includes {
|
for i in includes {
|
||||||
assert!(output.contains(i), "output doesn't contains: {}", i);
|
assert!(output.contains(i), "output doesn't contains: {}", i);
|
||||||
}
|
}
|
||||||
|
@ -39,29 +45,24 @@ fn check(target: &str, option: &str, includes: &[&str]) {
|
||||||
|
|
||||||
// --print={option}
|
// --print={option}
|
||||||
let stdout = {
|
let stdout = {
|
||||||
let output = rustc().target(target).print(option).run();
|
let output = rustc().target(args.target).print(args.option).run();
|
||||||
|
|
||||||
let stdout = String::from_utf8(output.stdout).unwrap();
|
String::from_utf8(output.stdout).unwrap()
|
||||||
|
|
||||||
_inner(&stdout, includes);
|
|
||||||
|
|
||||||
stdout
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// --print={option}=PATH
|
// --print={option}=PATH
|
||||||
let output = {
|
let output = {
|
||||||
let tmp_path = tmp_dir().join(format!("{option}.txt"));
|
let tmp_path = tmp_dir().join(format!("{}.txt", args.option));
|
||||||
let mut print_arg = OsString::from(format!("--print={option}="));
|
let mut print_arg = OsString::from(format!("--print={}=", args.option));
|
||||||
print_arg.push(tmp_path.as_os_str());
|
print_arg.push(tmp_path.as_os_str());
|
||||||
|
|
||||||
let _output = rustc().target(target).arg(print_arg).run();
|
let _output = rustc().target(args.target).arg(print_arg).run();
|
||||||
|
|
||||||
let output = std::fs::read_to_string(&tmp_path).unwrap();
|
std::fs::read_to_string(&tmp_path).unwrap()
|
||||||
|
|
||||||
_inner(&output, includes);
|
|
||||||
|
|
||||||
output
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
check_(&stdout, args.includes);
|
||||||
|
check_(&output, args.includes);
|
||||||
|
|
||||||
assert_eq!(&stdout, &output);
|
assert_eq!(&stdout, &output);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue