mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-29 02:52:11 +00:00
Merge pull request #19005 from duncanawoods/18955---fix-running-tests-for-packages-with-multiple-targets
fix testing packages with multiple targets
This commit is contained in:
commit
0c1b4838ce
9 changed files with 186 additions and 143 deletions
|
|
@ -226,6 +226,7 @@ pub enum TargetKind {
|
|||
Example,
|
||||
Test,
|
||||
Bench,
|
||||
/// Cargo calls this kind `custom-build`
|
||||
BuildScript,
|
||||
Other,
|
||||
}
|
||||
|
|
@ -254,6 +255,22 @@ impl TargetKind {
|
|||
pub fn is_proc_macro(self) -> bool {
|
||||
matches!(self, TargetKind::Lib { is_proc_macro: true })
|
||||
}
|
||||
|
||||
/// If this is a valid cargo target, returns the name cargo uses in command line arguments
|
||||
/// and output, otherwise None.
|
||||
/// https://docs.rs/cargo_metadata/latest/cargo_metadata/enum.TargetKind.html
|
||||
pub fn as_cargo_target(self) -> Option<&'static str> {
|
||||
match self {
|
||||
TargetKind::Bin => Some("bin"),
|
||||
TargetKind::Lib { is_proc_macro: true } => Some("proc-macro"),
|
||||
TargetKind::Lib { is_proc_macro: false } => Some("lib"),
|
||||
TargetKind::Example => Some("example"),
|
||||
TargetKind::Test => Some("test"),
|
||||
TargetKind::Bench => Some("bench"),
|
||||
TargetKind::BuildScript => Some("custom-build"),
|
||||
TargetKind::Other => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, PartialEq, Eq)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue