forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#124489 - matthiaskrgr:rollup-7pa86bf, r=matth…
…iaskrgr Rollup of 2 pull requests Successful merges: - rust-lang#123734 (Inline more svg images into CSS) - rust-lang#124473 (Port `print-cfg` run-make test to Rust-based rmake.rs) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
8 changed files
with
203 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
//! This checks the output of `--print=cfg` | ||
//! | ||
//! Specifically it checks that output is correctly formatted | ||
//! (ie. no duplicated cfgs, values are between "", names are not). | ||
//! | ||
//! It also checks that some targets have the correct set cfgs. | ||
|
||
extern crate run_make_support; | ||
|
||
use std::collections::HashSet; | ||
use std::ffi::OsString; | ||
use std::io::BufRead; | ||
use std::iter::FromIterator; | ||
|
||
use run_make_support::{rustc, tmp_dir}; | ||
|
||
struct PrintCfg { | ||
target: &'static str, | ||
includes: &'static [&'static str], | ||
disallow: &'static [&'static str], | ||
} | ||
|
||
fn main() { | ||
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 recorded = HashSet::<String>::new(); | ||
|
||
for l in output.lines() { | ||
assert!(l == l.trim()); | ||
if let Some((left, right)) = l.split_once('=') { | ||
assert!(right.starts_with("\"")); | ||
assert!(right.ends_with("\"")); | ||
assert!(!left.contains("\"")); | ||
} else { | ||
assert!(!l.contains("\"")); | ||
} | ||
|
||
assert!(recorded.insert(l.to_string()), "duplicated: {}", &l); | ||
assert!(!disallow.contains(&l), "found disallowed: {}", &l); | ||
if includes.contains(&l) { | ||
assert!(found.insert(l.to_string()), "duplicated (includes): {}", &l); | ||
} | ||
} | ||
|
||
let should_found = HashSet::<String>::from_iter(includes.iter().map(|s| s.to_string())); | ||
let diff: Vec<_> = should_found.difference(&found).collect(); | ||
|
||
assert!( | ||
diff.is_empty(), | ||
"expected: {:?}, found: {:?} (~ {:?})", | ||
&should_found, | ||
&found, | ||
&diff | ||
); | ||
} | ||
|
||
// --print=cfg | ||
{ | ||
let output = rustc().target(target).print("cfg").run(); | ||
|
||
let stdout = String::from_utf8(output.stdout).unwrap(); | ||
|
||
check_(&stdout, includes, disallow); | ||
} | ||
|
||
// --print=cfg=PATH | ||
{ | ||
let tmp_path = tmp_dir().join(format!("{target}.cfg")); | ||
let mut print_arg = OsString::from("--print=cfg="); | ||
print_arg.push(tmp_path.as_os_str()); | ||
|
||
let output = rustc().target(target).arg(print_arg).run(); | ||
|
||
let output = std::fs::read_to_string(&tmp_path).unwrap(); | ||
|
||
check_(&output, includes, disallow); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//! This checks the output of some `--print` options when | ||
//! output to a file (instead of stdout) | ||
|
||
extern crate run_make_support; | ||
|
||
use std::ffi::OsString; | ||
|
||
use run_make_support::{rustc, target, tmp_dir}; | ||
|
||
struct Option<'a> { | ||
target: &'a str, | ||
option: &'static str, | ||
includes: &'static [&'static str], | ||
} | ||
|
||
fn main() { | ||
// 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 { | ||
assert!(output.contains(i), "output doesn't contains: {}", i); | ||
} | ||
} | ||
|
||
// --print={option} | ||
let stdout = { | ||
let output = rustc().target(args.target).print(args.option).run(); | ||
|
||
String::from_utf8(output.stdout).unwrap() | ||
}; | ||
|
||
// --print={option}=PATH | ||
let output = { | ||
let tmp_path = tmp_dir().join(format!("{}.txt", args.option)); | ||
let mut print_arg = OsString::from(format!("--print={}=", args.option)); | ||
print_arg.push(tmp_path.as_os_str()); | ||
|
||
let _output = rustc().target(args.target).arg(print_arg).run(); | ||
|
||
std::fs::read_to_string(&tmp_path).unwrap() | ||
}; | ||
|
||
check_(&stdout, args.includes); | ||
check_(&output, args.includes); | ||
|
||
assert_eq!(&stdout, &output); | ||
} |