Properly parse '--extern-private' with name and path

This commit is contained in:
Aaron Hill 2019-03-20 23:27:08 -04:00
parent ee621f4232
commit 21491dc701
No known key found for this signature in database
GPG key ID: B4087E510E98B164
10 changed files with 113 additions and 22 deletions

View file

@ -286,6 +286,9 @@ pub struct TestProps {
// directory as the test, but for backwards compatibility reasons
// we also check the auxiliary directory)
pub aux_builds: Vec<String>,
// A list of crates to pass '--extern-private name:PATH' flags for
// This should be a subset of 'aux_build'
pub extern_private: Vec<String>,
// Environment settings to use for compiling
pub rustc_env: Vec<(String, String)>,
// Environment settings to use during execution
@ -353,6 +356,7 @@ impl TestProps {
run_flags: None,
pp_exact: None,
aux_builds: vec![],
extern_private: vec![],
revisions: vec![],
rustc_env: vec![],
exec_env: vec![],
@ -469,6 +473,10 @@ impl TestProps {
self.aux_builds.push(ab);
}
if let Some(ep) = config.parse_extern_private(ln) {
self.extern_private.push(ep);
}
if let Some(ee) = config.parse_env(ln, "exec-env") {
self.exec_env.push(ee);
}
@ -610,6 +618,10 @@ impl Config {
.map(|r| r.trim().to_string())
}
fn parse_extern_private(&self, line: &str) -> Option<String> {
self.parse_name_value_directive(line, "extern-private")
}
fn parse_compile_flags(&self, line: &str) -> Option<String> {
self.parse_name_value_directive(line, "compile-flags")
}

View file

@ -74,6 +74,17 @@ pub fn dylib_env_var() -> &'static str {
}
}
/// The platform-specific library file extension
pub fn lib_extension() -> &'static str {
if cfg!(windows) {
".dll"
} else if cfg!(target_os = "macos") {
".dylib"
} else {
".so"
}
}
#[derive(Debug, PartialEq)]
pub enum DiffLine {
Context(String),
@ -1585,6 +1596,13 @@ impl<'test> TestCx<'test> {
create_dir_all(&aux_dir).unwrap();
}
for priv_dep in &self.props.extern_private {
let lib_name = format!("lib{}{}", priv_dep, lib_extension());
rustc
.arg("--extern-private")
.arg(format!("{}={}", priv_dep, aux_dir.join(lib_name).to_str().unwrap()));
}
for rel_ab in &self.props.aux_builds {
let aux_testpaths = self.compute_aux_test_paths(rel_ab);
let aux_props =