-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow compiletest to pass down --extern
flags
#54020
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3ed8b02
extract helper fn
qmx f9e988c
try to make this testable
qmx 945577f
add negative test
qmx 7f4f0a4
add name-kv parser
qmx 920f259
expose aux_crate through Config
qmx d735cfb
extract helper
qmx 1beca83
expose fields
qmx bd0280a
compile aux_crates before compiling the test
qmx 4b0cbef
pass down desired crate name to rustc
qmx e552319
add tests
qmx b982ecf
tidy up
qmx 99e5699
port extern-prelude test to aux-crate
qmx 7dd0e38
tidy up
qmx 90132e0
try to make this cross-platform safe
qmx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
src/test/run-make-fulldeps/use-suggestions-rust-2018/Makefile
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// aux-crate:myfoo=baz.rs | ||
// edition:2018 | ||
|
||
|
||
use myfoo::Yellow; | ||
|
||
fn main() { | ||
let x = Yellow{}; | ||
} | ||
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 |
---|---|---|
|
@@ -12,6 +12,6 @@ | |
|
||
pub mod foo { | ||
pub mod bar { | ||
pub struct Baz; | ||
pub struct Bazz; | ||
} | ||
} |
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,17 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// edition:2018 | ||
// aux-crate:netted=ep-nested-lib.rs | ||
|
||
fn main() { | ||
let _x = Bazz{}; | ||
//~^ ERROR cannot find struct, variant or union type `Bazz` in this scope | ||
} |
13 changes: 13 additions & 0 deletions
13
src/test/ui/rust-2018/use-suggestions-extern-prelude.stderr
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,13 @@ | ||
error[E0422]: cannot find struct, variant or union type `Bazz` in this scope | ||
--> $DIR/use-suggestions-extern-prelude.rs:15:14 | ||
| | ||
LL | let _x = Bazz{}; | ||
| ^^^^ not found in this scope | ||
help: possible candidate is found in another module, you can import it into scope | ||
| | ||
LL | use netted::foo::bar::Bazz; | ||
| | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0422`. |
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 |
---|---|---|
|
@@ -77,6 +77,7 @@ pub struct EarlyProps { | |
pub ignore: Ignore, | ||
pub should_fail: bool, | ||
pub aux: Vec<String>, | ||
pub aux_crate: Vec<KeyValue>, | ||
pub revisions: Vec<String>, | ||
} | ||
|
||
|
@@ -86,6 +87,7 @@ impl EarlyProps { | |
ignore: Ignore::Run, | ||
should_fail: false, | ||
aux: Vec::new(), | ||
aux_crate: Vec::new(), | ||
revisions: vec![], | ||
}; | ||
|
||
|
@@ -137,6 +139,10 @@ impl EarlyProps { | |
props.aux.push(s); | ||
} | ||
|
||
if let Some(s) = config.parse_aux_crate(ln) { | ||
props.aux_crate.push(s); | ||
} | ||
|
||
if let Some(r) = config.parse_revisions(ln) { | ||
props.revisions.extend(r); | ||
} | ||
|
@@ -268,6 +274,8 @@ pub struct TestProps { | |
// directory as the test, but for backwards compatibility reasons | ||
// we also check the auxiliary directory) | ||
pub aux_builds: Vec<String>, | ||
// crates that should be compiled and exposed as the given alias | ||
pub aux_crates: Vec<KeyValue>, | ||
// Environment settings to use for compiling | ||
pub rustc_env: Vec<(String, String)>, | ||
// Environment settings to use during execution | ||
|
@@ -327,6 +335,7 @@ impl TestProps { | |
run_flags: None, | ||
pp_exact: None, | ||
aux_builds: vec![], | ||
aux_crates: vec![], | ||
revisions: vec![], | ||
rustc_env: vec![], | ||
exec_env: vec![], | ||
|
@@ -442,6 +451,10 @@ impl TestProps { | |
self.aux_builds.push(ab); | ||
} | ||
|
||
if let Some(ab) = config.parse_aux_crate(ln) { | ||
self.aux_crates.push(ab); | ||
} | ||
|
||
if let Some(ee) = config.parse_env(ln, "exec-env") { | ||
self.exec_env.push(ee); | ||
} | ||
|
@@ -576,6 +589,10 @@ impl Config { | |
self.parse_name_value_directive(line, "aux-build") | ||
} | ||
|
||
fn parse_aux_crate(&self, line: &str) -> Option<KeyValue> { | ||
self.parse_name_kv_directive(line, "aux-crate") | ||
} | ||
|
||
fn parse_compile_flags(&self, line: &str) -> Option<String> { | ||
self.parse_name_value_directive(line, "compile-flags") | ||
} | ||
|
@@ -772,14 +789,11 @@ impl Config { | |
} | ||
|
||
pub fn parse_name_value_directive(&self, line: &str, directive: &str) -> Option<String> { | ||
let colon = directive.len(); | ||
if line.starts_with(directive) && line.as_bytes().get(colon) == Some(&b':') { | ||
let value = line[(colon + 1)..].to_owned(); | ||
debug!("{}: {}", directive, value); | ||
Some(expand_variables(value, self)) | ||
} else { | ||
None | ||
} | ||
internal_parse_name_value_directive(line, directive).map(|v| expand_variables(v, self)) | ||
} | ||
|
||
pub fn parse_name_kv_directive(&self, line: &str, directive: &str) -> Option<KeyValue> { | ||
internal_parse_name_kv_directive(line, directive) | ||
} | ||
|
||
pub fn find_rust_src_root(&self) -> Option<PathBuf> { | ||
|
@@ -816,6 +830,47 @@ pub fn lldb_version_to_int(version_string: &str) -> isize { | |
version_string.parse().expect(&error_string) | ||
} | ||
|
||
#[test] | ||
fn test_parse_name_value_directive() { | ||
assert_eq!(Some("foo.rs".to_owned()), | ||
internal_parse_name_value_directive("aux-build:foo.rs", "aux-build")); | ||
assert_eq!(None, internal_parse_name_value_directive("faux-build:foo.rs", "aux-build")); | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct KeyValue { | ||
pub key: String, | ||
pub value: String, | ||
} | ||
|
||
#[test] | ||
fn test_parse_name_kv_directive() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. woah tests. Totally not idiomatic for compiletest. 😛 |
||
let value = internal_parse_name_kv_directive("crate-aux-build:baz=foo.rs", "crate-aux-build"); | ||
assert_eq!(Some(KeyValue{key:"baz".to_owned(), value:"foo.rs".to_owned()}), value); | ||
} | ||
|
||
fn internal_parse_name_kv_directive(line: &str, directive: &str) -> Option<KeyValue> { | ||
if let Some(value) = internal_parse_name_value_directive(line, directive) { | ||
let parts = value.split("=").collect::<Vec<&str>>(); | ||
if parts.len() == 2 { | ||
let (k,v) = (parts[0], parts[1]); | ||
return Some(KeyValue{key:k.to_string(),value:v.to_string()}); | ||
} | ||
} | ||
None | ||
} | ||
|
||
fn internal_parse_name_value_directive(line: &str, directive: &str) -> Option<String> { | ||
let colon = directive.len(); | ||
if line.starts_with(directive) && line.as_bytes().get(colon) == Some(&b':') { | ||
let value = line[(colon + 1)..].to_owned(); | ||
debug!("{}: {}", directive, value); | ||
Some(value) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
fn expand_variables(mut value: String, config: &Config) -> String { | ||
const CWD: &'static str = "{{cwd}}"; | ||
const SRC_BASE: &'static str = "{{src-base}}"; | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we port the extern prelude test to use this?
What about your existing tests for suggestions?