mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Part 2 of RFC2906 - allow inheriting from parent workspaces
This commit is contained in:
parent
035cb09f05
commit
0cd55465a4
@ -26,6 +26,15 @@ pub enum EitherManifest {
|
|||||||
Virtual(VirtualManifest),
|
Virtual(VirtualManifest),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl EitherManifest {
|
||||||
|
pub(crate) fn workspace_config(&self) -> &WorkspaceConfig {
|
||||||
|
match *self {
|
||||||
|
EitherManifest::Real(ref r) => r.workspace_config(),
|
||||||
|
EitherManifest::Virtual(ref v) => v.workspace_config(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Contains all the information about a package, as loaded from a `Cargo.toml`.
|
/// Contains all the information about a package, as loaded from a `Cargo.toml`.
|
||||||
///
|
///
|
||||||
/// This is deserialized using the [`TomlManifest`] type.
|
/// This is deserialized using the [`TomlManifest`] type.
|
||||||
|
@ -11,7 +11,8 @@ pub use self::shell::{Shell, Verbosity};
|
|||||||
pub use self::source::{GitReference, Source, SourceId, SourceMap};
|
pub use self::source::{GitReference, Source, SourceId, SourceMap};
|
||||||
pub use self::summary::{FeatureMap, FeatureValue, Summary};
|
pub use self::summary::{FeatureMap, FeatureValue, Summary};
|
||||||
pub use self::workspace::{
|
pub use self::workspace::{
|
||||||
InheritableFields, MaybePackage, Workspace, WorkspaceConfig, WorkspaceRootConfig,
|
find_workspace_root, InheritableFields, MaybePackage, Workspace, WorkspaceConfig,
|
||||||
|
WorkspaceRootConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod compiler;
|
pub mod compiler;
|
||||||
|
@ -591,16 +591,6 @@ impl<'cfg> Workspace<'cfg> {
|
|||||||
/// Returns an error if `manifest_path` isn't actually a valid manifest or
|
/// Returns an error if `manifest_path` isn't actually a valid manifest or
|
||||||
/// if some other transient error happens.
|
/// if some other transient error happens.
|
||||||
fn find_root(&mut self, manifest_path: &Path) -> CargoResult<Option<PathBuf>> {
|
fn find_root(&mut self, manifest_path: &Path) -> CargoResult<Option<PathBuf>> {
|
||||||
fn read_root_pointer(member_manifest: &Path, root_link: &str) -> PathBuf {
|
|
||||||
let path = member_manifest
|
|
||||||
.parent()
|
|
||||||
.unwrap()
|
|
||||||
.join(root_link)
|
|
||||||
.join("Cargo.toml");
|
|
||||||
debug!("find_root - pointer {}", path.display());
|
|
||||||
paths::normalize_path(&path)
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
let current = self.packages.load(manifest_path)?;
|
let current = self.packages.load(manifest_path)?;
|
||||||
match *current.workspace_config() {
|
match *current.workspace_config() {
|
||||||
@ -1643,6 +1633,10 @@ impl WorkspaceRootConfig {
|
|||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn inheritable(&self) -> &InheritableFields {
|
||||||
|
&self.inheritable_fields
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A group of fields that are inheritable by members of the workspace
|
/// A group of fields that are inheritable by members of the workspace
|
||||||
@ -1832,7 +1826,53 @@ impl InheritableFields {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_root_iter<'a>(
|
fn parse_manifest(manifest_path: &Path, config: &Config) -> CargoResult<EitherManifest> {
|
||||||
|
let key = manifest_path.parent().unwrap();
|
||||||
|
let source_id = SourceId::for_path(key)?;
|
||||||
|
let (manifest, _nested_paths) = read_manifest(manifest_path, source_id, config)?;
|
||||||
|
Ok(manifest)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn find_workspace_root(manifest_path: &Path, config: &Config) -> CargoResult<Option<PathBuf>> {
|
||||||
|
find_root_iter(manifest_path, config)
|
||||||
|
.find_map(|ances_manifest_path| {
|
||||||
|
let manifest = parse_manifest(&ances_manifest_path, config);
|
||||||
|
match manifest {
|
||||||
|
Ok(manifest) => match *manifest.workspace_config() {
|
||||||
|
WorkspaceConfig::Root(ref ances_root_config) => {
|
||||||
|
debug!("find_root - found a root checking exclusion");
|
||||||
|
if !ances_root_config.is_excluded(manifest_path) {
|
||||||
|
debug!("find_root - found!");
|
||||||
|
Some(Ok(ances_manifest_path))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WorkspaceConfig::Member {
|
||||||
|
root: Some(ref path_to_root),
|
||||||
|
} => {
|
||||||
|
debug!("find_root - found pointer");
|
||||||
|
Some(Ok(read_root_pointer(&ances_manifest_path, path_to_root)))
|
||||||
|
}
|
||||||
|
WorkspaceConfig::Member { .. } => None,
|
||||||
|
},
|
||||||
|
Err(e) => Some(Err(e)),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.transpose()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_root_pointer(member_manifest: &Path, root_link: &str) -> PathBuf {
|
||||||
|
let path = member_manifest
|
||||||
|
.parent()
|
||||||
|
.unwrap()
|
||||||
|
.join(root_link)
|
||||||
|
.join("Cargo.toml");
|
||||||
|
debug!("find_root - pointer {}", path.display());
|
||||||
|
paths::normalize_path(&path)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn find_root_iter<'a>(
|
||||||
manifest_path: &'a Path,
|
manifest_path: &'a Path,
|
||||||
config: &'a Config,
|
config: &'a Config,
|
||||||
) -> impl Iterator<Item = PathBuf> + 'a {
|
) -> impl Iterator<Item = PathBuf> + 'a {
|
||||||
|
@ -20,7 +20,7 @@ use crate::core::compiler::{CompileKind, CompileTarget};
|
|||||||
use crate::core::dependency::{Artifact, ArtifactTarget, DepKind};
|
use crate::core::dependency::{Artifact, ArtifactTarget, DepKind};
|
||||||
use crate::core::manifest::{ManifestMetadata, TargetSourcePath, Warnings};
|
use crate::core::manifest::{ManifestMetadata, TargetSourcePath, Warnings};
|
||||||
use crate::core::resolver::ResolveBehavior;
|
use crate::core::resolver::ResolveBehavior;
|
||||||
use crate::core::{Dependency, Manifest, PackageId, Summary, Target};
|
use crate::core::{find_workspace_root, Dependency, Manifest, PackageId, Summary, Target};
|
||||||
use crate::core::{
|
use crate::core::{
|
||||||
Edition, EitherManifest, Feature, Features, InheritableFields, VirtualManifest, Workspace,
|
Edition, EitherManifest, Feature, Features, InheritableFields, VirtualManifest, Workspace,
|
||||||
};
|
};
|
||||||
@ -1283,13 +1283,30 @@ impl TomlManifest {
|
|||||||
package_root: &Path,
|
package_root: &Path,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
) -> CargoResult<(Manifest, Vec<PathBuf>)> {
|
) -> CargoResult<(Manifest, Vec<PathBuf>)> {
|
||||||
// This is for later when we try to find the workspace root
|
fn get_ws(
|
||||||
fn get_ws(inheritable: Option<&InheritableFields>) -> CargoResult<&InheritableFields> {
|
config: &Config,
|
||||||
match inheritable {
|
resolved_path: PathBuf,
|
||||||
Some(inheritable) => Ok(inheritable),
|
workspace_config: WorkspaceConfig,
|
||||||
None => Err(anyhow!(
|
) -> CargoResult<InheritableFields> {
|
||||||
"inheriting from a parent workspace is not implemented yet",
|
match workspace_config {
|
||||||
)),
|
WorkspaceConfig::Root(root) => Ok(root.inheritable().clone()),
|
||||||
|
WorkspaceConfig::Member {
|
||||||
|
root: Some(ref path_to_root),
|
||||||
|
} => {
|
||||||
|
let path = resolved_path
|
||||||
|
.parent()
|
||||||
|
.unwrap()
|
||||||
|
.join(path_to_root)
|
||||||
|
.join("Cargo.toml");
|
||||||
|
let root_path = paths::normalize_path(&path);
|
||||||
|
inheritable_from_path(config, root_path)
|
||||||
|
}
|
||||||
|
WorkspaceConfig::Member { root: None } => {
|
||||||
|
match find_workspace_root(&resolved_path, config)? {
|
||||||
|
Some(path_to_root) => inheritable_from_path(config, path_to_root),
|
||||||
|
None => Err(anyhow!("failed to find a workspace root")),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1343,8 +1360,6 @@ impl TomlManifest {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
let inheritable = workspace_config.inheritable();
|
|
||||||
|
|
||||||
let package_name = project.name.trim();
|
let package_name = project.name.trim();
|
||||||
if package_name.is_empty() {
|
if package_name.is_empty() {
|
||||||
bail!("package name cannot be an empty string")
|
bail!("package name cannot be an empty string")
|
||||||
@ -1352,10 +1367,11 @@ impl TomlManifest {
|
|||||||
|
|
||||||
validate_package_name(package_name, "package name", "")?;
|
validate_package_name(package_name, "package name", "")?;
|
||||||
|
|
||||||
let version = project
|
let resolved_path = package_root.join("Cargo.toml");
|
||||||
.version
|
|
||||||
.clone()
|
let version = project.version.clone().resolve(&features, "version", || {
|
||||||
.resolve(&features, "version", || get_ws(inheritable)?.version())?;
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?.version()
|
||||||
|
})?;
|
||||||
|
|
||||||
project.version = MaybeWorkspace::Defined(version.clone());
|
project.version = MaybeWorkspace::Defined(version.clone());
|
||||||
|
|
||||||
@ -1363,7 +1379,9 @@ impl TomlManifest {
|
|||||||
|
|
||||||
let edition = if let Some(edition) = project.edition.clone() {
|
let edition = if let Some(edition) = project.edition.clone() {
|
||||||
let edition: Edition = edition
|
let edition: Edition = edition
|
||||||
.resolve(&features, "edition", || get_ws(inheritable)?.edition())?
|
.resolve(&features, "edition", || {
|
||||||
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?.edition()
|
||||||
|
})?
|
||||||
.parse()
|
.parse()
|
||||||
.with_context(|| "failed to parse the `edition` key")?;
|
.with_context(|| "failed to parse the `edition` key")?;
|
||||||
project.edition = Some(MaybeWorkspace::Defined(edition.to_string()));
|
project.edition = Some(MaybeWorkspace::Defined(edition.to_string()));
|
||||||
@ -1480,7 +1498,7 @@ impl TomlManifest {
|
|||||||
cx: &mut Context<'_, '_>,
|
cx: &mut Context<'_, '_>,
|
||||||
new_deps: Option<&BTreeMap<String, TomlDependency>>,
|
new_deps: Option<&BTreeMap<String, TomlDependency>>,
|
||||||
kind: Option<DepKind>,
|
kind: Option<DepKind>,
|
||||||
inheritable: Option<&InheritableFields>,
|
workspace_config: &WorkspaceConfig,
|
||||||
) -> CargoResult<Option<BTreeMap<String, TomlDependency>>> {
|
) -> CargoResult<Option<BTreeMap<String, TomlDependency>>> {
|
||||||
let dependencies = match new_deps {
|
let dependencies = match new_deps {
|
||||||
Some(dependencies) => dependencies,
|
Some(dependencies) => dependencies,
|
||||||
@ -1488,9 +1506,14 @@ impl TomlManifest {
|
|||||||
};
|
};
|
||||||
let mut deps: BTreeMap<String, TomlDependency> = BTreeMap::new();
|
let mut deps: BTreeMap<String, TomlDependency> = BTreeMap::new();
|
||||||
for (n, v) in dependencies.iter() {
|
for (n, v) in dependencies.iter() {
|
||||||
let resolved = v
|
let resolved = v.clone().resolve(features, n, || {
|
||||||
.clone()
|
get_ws(
|
||||||
.resolve(features, n, || get_ws(inheritable)?.get_dependency(n))?;
|
cx.config,
|
||||||
|
cx.root.join("Cargo.toml"),
|
||||||
|
workspace_config.clone(),
|
||||||
|
)?
|
||||||
|
.get_dependency(n)
|
||||||
|
})?;
|
||||||
let dep = resolved.to_dependency(n, cx, kind)?;
|
let dep = resolved.to_dependency(n, cx, kind)?;
|
||||||
validate_package_name(dep.name_in_toml().as_str(), "dependency name", "")?;
|
validate_package_name(dep.name_in_toml().as_str(), "dependency name", "")?;
|
||||||
cx.deps.push(dep);
|
cx.deps.push(dep);
|
||||||
@ -1505,7 +1528,7 @@ impl TomlManifest {
|
|||||||
&mut cx,
|
&mut cx,
|
||||||
me.dependencies.as_ref(),
|
me.dependencies.as_ref(),
|
||||||
None,
|
None,
|
||||||
inheritable,
|
&workspace_config,
|
||||||
)?;
|
)?;
|
||||||
if me.dev_dependencies.is_some() && me.dev_dependencies2.is_some() {
|
if me.dev_dependencies.is_some() && me.dev_dependencies2.is_some() {
|
||||||
warn_on_deprecated("dev-dependencies", package_name, "package", cx.warnings);
|
warn_on_deprecated("dev-dependencies", package_name, "package", cx.warnings);
|
||||||
@ -1519,7 +1542,7 @@ impl TomlManifest {
|
|||||||
&mut cx,
|
&mut cx,
|
||||||
dev_deps,
|
dev_deps,
|
||||||
Some(DepKind::Development),
|
Some(DepKind::Development),
|
||||||
inheritable,
|
&workspace_config,
|
||||||
)?;
|
)?;
|
||||||
if me.build_dependencies.is_some() && me.build_dependencies2.is_some() {
|
if me.build_dependencies.is_some() && me.build_dependencies2.is_some() {
|
||||||
warn_on_deprecated("build-dependencies", package_name, "package", cx.warnings);
|
warn_on_deprecated("build-dependencies", package_name, "package", cx.warnings);
|
||||||
@ -1533,7 +1556,7 @@ impl TomlManifest {
|
|||||||
&mut cx,
|
&mut cx,
|
||||||
build_deps,
|
build_deps,
|
||||||
Some(DepKind::Build),
|
Some(DepKind::Build),
|
||||||
inheritable,
|
&workspace_config,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let mut target: BTreeMap<String, TomlPlatform> = BTreeMap::new();
|
let mut target: BTreeMap<String, TomlPlatform> = BTreeMap::new();
|
||||||
@ -1548,7 +1571,7 @@ impl TomlManifest {
|
|||||||
&mut cx,
|
&mut cx,
|
||||||
platform.dependencies.as_ref(),
|
platform.dependencies.as_ref(),
|
||||||
None,
|
None,
|
||||||
inheritable,
|
&workspace_config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if platform.build_dependencies.is_some() && platform.build_dependencies2.is_some() {
|
if platform.build_dependencies.is_some() && platform.build_dependencies2.is_some() {
|
||||||
@ -1563,7 +1586,7 @@ impl TomlManifest {
|
|||||||
&mut cx,
|
&mut cx,
|
||||||
build_deps,
|
build_deps,
|
||||||
Some(DepKind::Build),
|
Some(DepKind::Build),
|
||||||
inheritable,
|
&workspace_config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if platform.dev_dependencies.is_some() && platform.dev_dependencies2.is_some() {
|
if platform.dev_dependencies.is_some() && platform.dev_dependencies2.is_some() {
|
||||||
@ -1578,7 +1601,7 @@ impl TomlManifest {
|
|||||||
&mut cx,
|
&mut cx,
|
||||||
dev_deps,
|
dev_deps,
|
||||||
Some(DepKind::Development),
|
Some(DepKind::Development),
|
||||||
inheritable,
|
&workspace_config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
target.insert(
|
target.insert(
|
||||||
@ -1635,21 +1658,27 @@ impl TomlManifest {
|
|||||||
.clone()
|
.clone()
|
||||||
.map(|mw| {
|
.map(|mw| {
|
||||||
mw.resolve(&features, "description", || {
|
mw.resolve(&features, "description", || {
|
||||||
get_ws(inheritable)?.description()
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?
|
||||||
|
.description()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.transpose()?,
|
.transpose()?,
|
||||||
homepage: project
|
homepage: project
|
||||||
.homepage
|
.homepage
|
||||||
.clone()
|
.clone()
|
||||||
.map(|mw| mw.resolve(&features, "homepage", || get_ws(inheritable)?.homepage()))
|
.map(|mw| {
|
||||||
|
mw.resolve(&features, "homepage", || {
|
||||||
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?.homepage()
|
||||||
|
})
|
||||||
|
})
|
||||||
.transpose()?,
|
.transpose()?,
|
||||||
documentation: project
|
documentation: project
|
||||||
.documentation
|
.documentation
|
||||||
.clone()
|
.clone()
|
||||||
.map(|mw| {
|
.map(|mw| {
|
||||||
mw.resolve(&features, "documentation", || {
|
mw.resolve(&features, "documentation", || {
|
||||||
get_ws(inheritable)?.documentation()
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?
|
||||||
|
.documentation()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.transpose()?,
|
.transpose()?,
|
||||||
@ -1657,13 +1686,21 @@ impl TomlManifest {
|
|||||||
authors: project
|
authors: project
|
||||||
.authors
|
.authors
|
||||||
.clone()
|
.clone()
|
||||||
.map(|mw| mw.resolve(&features, "authors", || get_ws(inheritable)?.authors()))
|
.map(|mw| {
|
||||||
|
mw.resolve(&features, "authors", || {
|
||||||
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?.authors()
|
||||||
|
})
|
||||||
|
})
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
license: project
|
license: project
|
||||||
.license
|
.license
|
||||||
.clone()
|
.clone()
|
||||||
.map(|mw| mw.resolve(&features, "license", || get_ws(inheritable)?.license()))
|
.map(|mw| {
|
||||||
|
mw.resolve(&features, "license", || {
|
||||||
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?.license()
|
||||||
|
})
|
||||||
|
})
|
||||||
.transpose()?,
|
.transpose()?,
|
||||||
license_file: project.license_file.clone(),
|
license_file: project.license_file.clone(),
|
||||||
repository: project
|
repository: project
|
||||||
@ -1671,14 +1708,19 @@ impl TomlManifest {
|
|||||||
.clone()
|
.clone()
|
||||||
.map(|mw| {
|
.map(|mw| {
|
||||||
mw.resolve(&features, "repository", || {
|
mw.resolve(&features, "repository", || {
|
||||||
get_ws(inheritable)?.repository()
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?
|
||||||
|
.repository()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.transpose()?,
|
.transpose()?,
|
||||||
keywords: project
|
keywords: project
|
||||||
.keywords
|
.keywords
|
||||||
.clone()
|
.clone()
|
||||||
.map(|mw| mw.resolve(&features, "keywords", || get_ws(inheritable)?.keywords()))
|
.map(|mw| {
|
||||||
|
mw.resolve(&features, "keywords", || {
|
||||||
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?.keywords()
|
||||||
|
})
|
||||||
|
})
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
categories: project
|
categories: project
|
||||||
@ -1686,7 +1728,8 @@ impl TomlManifest {
|
|||||||
.clone()
|
.clone()
|
||||||
.map(|mw| {
|
.map(|mw| {
|
||||||
mw.resolve(&features, "categories", || {
|
mw.resolve(&features, "categories", || {
|
||||||
get_ws(inheritable)?.categories()
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?
|
||||||
|
.categories()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.transpose()?
|
.transpose()?
|
||||||
@ -1694,7 +1737,11 @@ impl TomlManifest {
|
|||||||
badges: me
|
badges: me
|
||||||
.badges
|
.badges
|
||||||
.clone()
|
.clone()
|
||||||
.map(|mw| mw.resolve(&features, "badges", || get_ws(inheritable)?.badges()))
|
.map(|mw| {
|
||||||
|
mw.resolve(&features, "badges", || {
|
||||||
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?.badges()
|
||||||
|
})
|
||||||
|
})
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
links: project.links.clone(),
|
links: project.links.clone(),
|
||||||
@ -1739,7 +1786,9 @@ impl TomlManifest {
|
|||||||
|
|
||||||
let publish = project.publish.clone().map(|publish| {
|
let publish = project.publish.clone().map(|publish| {
|
||||||
publish
|
publish
|
||||||
.resolve(&features, "publish", || get_ws(inheritable)?.publish())
|
.resolve(&features, "publish", || {
|
||||||
|
get_ws(config, resolved_path.clone(), workspace_config.clone())?.publish()
|
||||||
|
})
|
||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2073,6 +2122,22 @@ impl TomlManifest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn inheritable_from_path(
|
||||||
|
config: &Config,
|
||||||
|
resolved_path: PathBuf,
|
||||||
|
) -> CargoResult<InheritableFields> {
|
||||||
|
let key = resolved_path.parent().unwrap();
|
||||||
|
let source_id = SourceId::for_path(key)?;
|
||||||
|
let (man, _) = read_manifest(&resolved_path, source_id, config)?;
|
||||||
|
match man.workspace_config() {
|
||||||
|
WorkspaceConfig::Root(root) => Ok(root.inheritable().clone()),
|
||||||
|
_ => bail!(
|
||||||
|
"root of a workspace inferred but wasn't a root: {}",
|
||||||
|
resolved_path.display()
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the name of the README file for a `TomlProject`.
|
/// Returns the name of the README file for a `TomlProject`.
|
||||||
fn readme_for_project(package_root: &Path, project: &TomlProject) -> Option<String> {
|
fn readme_for_project(package_root: &Path, project: &TomlProject) -> Option<String> {
|
||||||
match &project.readme {
|
match &project.readme {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Tests for inheriting Cargo.toml fields with { workspace = true }
|
//! Tests for inheriting Cargo.toml fields with { workspace = true }
|
||||||
use cargo_test_support::registry::{Dependency, Package};
|
use cargo_test_support::registry::{Dependency, Package};
|
||||||
use cargo_test_support::{basic_lib_manifest, git, paths, project, publish, registry};
|
use cargo_test_support::{basic_lib_manifest, git, path2url, paths, project, publish, registry};
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn permit_additional_workspace_fields() {
|
fn permit_additional_workspace_fields() {
|
||||||
@ -564,7 +564,7 @@ fn inherited_dependencies_union_features() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn error_on_unimplemented_inheritance_fields() {
|
fn inherit_workspace_fields() {
|
||||||
registry::init();
|
registry::init();
|
||||||
|
|
||||||
let p = project().build();
|
let p = project().build();
|
||||||
@ -576,45 +576,403 @@ fn error_on_unimplemented_inheritance_fields() {
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["bar"]
|
members = ["bar"]
|
||||||
version = "1.2.3"
|
version = "1.2.3"
|
||||||
|
authors = ["Rustaceans"]
|
||||||
|
description = "This is a crate"
|
||||||
|
documentation = "https://www.rust-lang.org/learn"
|
||||||
|
homepage = "https://www.rust-lang.org"
|
||||||
|
repository = "https://github.com/example/example"
|
||||||
|
keywords = ["cli"]
|
||||||
|
categories = ["development-tools"]
|
||||||
|
publish = true
|
||||||
|
edition = "2018"
|
||||||
|
[workspace.badges]
|
||||||
|
gitlab = { repository = "https://gitlab.com/rust-lang/rust", branch = "master" }
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.file("src/main.rs", "fn main() {}")
|
.file("src/main.rs", "fn main() {}")
|
||||||
.file(
|
.file(
|
||||||
"bar/Cargo.toml",
|
"bar/Cargo.toml",
|
||||||
r#"
|
r#"
|
||||||
|
badges = { workspace = true }
|
||||||
cargo-features = ["workspace-inheritance"]
|
cargo-features = ["workspace-inheritance"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "bar"
|
name = "bar"
|
||||||
workspace = ".."
|
workspace = ".."
|
||||||
version = { workspace = true }
|
version = { workspace = true }
|
||||||
|
authors = { workspace = true }
|
||||||
|
description = { workspace = true }
|
||||||
|
documentation = { workspace = true }
|
||||||
|
homepage = { workspace = true }
|
||||||
|
repository = { workspace = true }
|
||||||
|
keywords = { workspace = true }
|
||||||
|
categories = { workspace = true }
|
||||||
|
publish = { workspace = true }
|
||||||
|
edition = { workspace = true }
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("bar/src/main.rs", "fn main() {}")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("publish --token sekrit")
|
||||||
|
.masquerade_as_nightly_cargo()
|
||||||
|
.cwd("bar")
|
||||||
|
.run();
|
||||||
|
publish::validate_upload_with_contents(
|
||||||
|
r#"
|
||||||
|
{
|
||||||
|
"authors": ["Rustaceans"],
|
||||||
|
"badges": {
|
||||||
|
"gitlab": { "branch": "master", "repository": "https://gitlab.com/rust-lang/rust" }
|
||||||
|
},
|
||||||
|
"categories": ["development-tools"],
|
||||||
|
"deps": [],
|
||||||
|
"description": "This is a crate",
|
||||||
|
"documentation": "https://www.rust-lang.org/learn",
|
||||||
|
"features": {},
|
||||||
|
"homepage": "https://www.rust-lang.org",
|
||||||
|
"keywords": ["cli"],
|
||||||
|
"license": null,
|
||||||
|
"license_file": null,
|
||||||
|
"links": null,
|
||||||
|
"name": "bar",
|
||||||
|
"readme": null,
|
||||||
|
"readme_file": null,
|
||||||
|
"repository": "https://github.com/example/example",
|
||||||
|
"vers": "1.2.3"
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
"bar-1.2.3.crate",
|
||||||
|
&[
|
||||||
|
"Cargo.lock",
|
||||||
|
"Cargo.toml",
|
||||||
|
"Cargo.toml.orig",
|
||||||
|
"src/main.rs",
|
||||||
|
".cargo_vcs_info.json",
|
||||||
|
],
|
||||||
|
&[(
|
||||||
|
"Cargo.toml",
|
||||||
|
&format!(
|
||||||
|
r#"{}
|
||||||
|
cargo-features = ["workspace-inheritance"]
|
||||||
|
|
||||||
|
[package]
|
||||||
|
edition = "2018"
|
||||||
|
name = "bar"
|
||||||
|
version = "1.2.3"
|
||||||
|
authors = ["Rustaceans"]
|
||||||
|
publish = true
|
||||||
|
description = "This is a crate"
|
||||||
|
homepage = "https://www.rust-lang.org"
|
||||||
|
documentation = "https://www.rust-lang.org/learn"
|
||||||
|
keywords = ["cli"]
|
||||||
|
categories = ["development-tools"]
|
||||||
|
repository = "https://github.com/example/example"
|
||||||
|
|
||||||
|
[badges.gitlab]
|
||||||
|
branch = "master"
|
||||||
|
repository = "https://gitlab.com/rust-lang/rust"
|
||||||
|
"#,
|
||||||
|
cargo::core::package::MANIFEST_PREAMBLE
|
||||||
|
),
|
||||||
|
)],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn inherit_dependencies() {
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[workspace]
|
||||||
|
members = ["bar"]
|
||||||
|
[workspace.dependencies]
|
||||||
|
dep = "0.1"
|
||||||
|
dep-build = "0.8"
|
||||||
|
dep-dev = "0.5.2"
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file(
|
||||||
|
"bar/Cargo.toml",
|
||||||
|
r#"
|
||||||
|
cargo-features = ["workspace-inheritance"]
|
||||||
|
|
||||||
|
[project]
|
||||||
|
workspace = ".."
|
||||||
|
name = "bar"
|
||||||
|
version = "0.2.0"
|
||||||
|
authors = []
|
||||||
|
[dependencies]
|
||||||
|
dep = { workspace = true }
|
||||||
|
[build-dependencies]
|
||||||
|
dep-build = { workspace = true }
|
||||||
|
[dev-dependencies]
|
||||||
|
dep-dev = { workspace = true }
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("bar/src/main.rs", "fn main() {}")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Package::new("dep", "0.1.2").publish();
|
||||||
|
Package::new("dep-build", "0.8.2").publish();
|
||||||
|
Package::new("dep-dev", "0.5.2").publish();
|
||||||
|
|
||||||
|
p.cargo("build")
|
||||||
|
.masquerade_as_nightly_cargo()
|
||||||
|
.masquerade_as_nightly_cargo()
|
||||||
|
.with_stderr(
|
||||||
|
"\
|
||||||
|
[UPDATING] `[..]` index
|
||||||
|
[DOWNLOADING] crates ...
|
||||||
|
[DOWNLOADED] dep-build v0.8.2 ([..])
|
||||||
|
[DOWNLOADED] dep v0.1.2 ([..])
|
||||||
|
[COMPILING] dep v0.1.2
|
||||||
|
[COMPILING] bar v0.2.0 ([CWD]/bar)
|
||||||
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
|
p.cargo("check").masquerade_as_nightly_cargo().run();
|
||||||
|
let lockfile = p.read_lockfile();
|
||||||
|
assert!(lockfile.contains("dep"));
|
||||||
|
assert!(lockfile.contains("dep-dev"));
|
||||||
|
assert!(lockfile.contains("dep-build"));
|
||||||
|
p.cargo("publish --token sekrit")
|
||||||
|
.masquerade_as_nightly_cargo()
|
||||||
|
.cwd("bar")
|
||||||
|
.run();
|
||||||
|
publish::validate_upload_with_contents(
|
||||||
|
r#"
|
||||||
|
{
|
||||||
|
"authors": [],
|
||||||
|
"badges": {},
|
||||||
|
"categories": [],
|
||||||
|
"deps": [
|
||||||
|
{
|
||||||
|
"default_features": true,
|
||||||
|
"features": [],
|
||||||
|
"kind": "normal",
|
||||||
|
"name": "dep",
|
||||||
|
"optional": false,
|
||||||
|
"registry": "https://github.com/rust-lang/crates.io-index",
|
||||||
|
"target": null,
|
||||||
|
"version_req": "^0.1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default_features": true,
|
||||||
|
"features": [],
|
||||||
|
"kind": "dev",
|
||||||
|
"name": "dep-dev",
|
||||||
|
"optional": false,
|
||||||
|
"registry": "https://github.com/rust-lang/crates.io-index",
|
||||||
|
"target": null,
|
||||||
|
"version_req": "^0.5.2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default_features": true,
|
||||||
|
"features": [],
|
||||||
|
"kind": "build",
|
||||||
|
"name": "dep-build",
|
||||||
|
"optional": false,
|
||||||
|
"registry": "https://github.com/rust-lang/crates.io-index",
|
||||||
|
"target": null,
|
||||||
|
"version_req": "^0.8"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": null,
|
||||||
|
"documentation": null,
|
||||||
|
"features": {},
|
||||||
|
"homepage": null,
|
||||||
|
"keywords": [],
|
||||||
|
"license": null,
|
||||||
|
"license_file": null,
|
||||||
|
"links": null,
|
||||||
|
"name": "bar",
|
||||||
|
"readme": null,
|
||||||
|
"readme_file": null,
|
||||||
|
"repository": null,
|
||||||
|
"vers": "0.2.0"
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
"bar-0.2.0.crate",
|
||||||
|
&["Cargo.toml", "Cargo.toml.orig", "Cargo.lock", "src/main.rs"],
|
||||||
|
&[(
|
||||||
|
"Cargo.toml",
|
||||||
|
&format!(
|
||||||
|
r#"{}
|
||||||
|
cargo-features = ["workspace-inheritance"]
|
||||||
|
|
||||||
|
[package]
|
||||||
|
name = "bar"
|
||||||
|
version = "0.2.0"
|
||||||
|
authors = []
|
||||||
|
|
||||||
|
[dependencies.dep]
|
||||||
|
version = "0.1"
|
||||||
|
|
||||||
|
[dev-dependencies.dep-dev]
|
||||||
|
version = "0.5.2"
|
||||||
|
|
||||||
|
[build-dependencies.dep-build]
|
||||||
|
version = "0.8"
|
||||||
|
"#,
|
||||||
|
cargo::core::package::MANIFEST_PREAMBLE
|
||||||
|
),
|
||||||
|
)],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn inherit_target_dependencies() {
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[workspace]
|
||||||
|
members = ["bar"]
|
||||||
|
[workspace.dependencies]
|
||||||
|
dep = "0.1"
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file(
|
||||||
|
"bar/Cargo.toml",
|
||||||
|
r#"
|
||||||
|
cargo-features = ["workspace-inheritance"]
|
||||||
|
|
||||||
|
[project]
|
||||||
|
workspace = ".."
|
||||||
|
name = "bar"
|
||||||
|
version = "0.2.0"
|
||||||
|
authors = []
|
||||||
|
[target.'cfg(unix)'.dependencies]
|
||||||
|
dep = { workspace = true }
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
dep = { workspace = true }
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("bar/src/main.rs", "fn main() {}")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Package::new("dep", "0.1.2").publish();
|
||||||
|
|
||||||
|
p.cargo("build")
|
||||||
|
.masquerade_as_nightly_cargo()
|
||||||
|
.with_stderr(
|
||||||
|
"\
|
||||||
|
[UPDATING] `[..]` index
|
||||||
|
[DOWNLOADING] crates ...
|
||||||
|
[DOWNLOADED] dep v0.1.2 ([..])
|
||||||
|
[COMPILING] dep v0.1.2
|
||||||
|
[COMPILING] bar v0.2.0 ([CWD]/bar)
|
||||||
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
|
let lockfile = p.read_lockfile();
|
||||||
|
assert!(lockfile.contains("dep"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn inherit_dependency_override_optional() {
|
||||||
|
Package::new("dep", "0.1.0").publish();
|
||||||
|
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[workspace]
|
||||||
|
members = ["bar"]
|
||||||
|
[workspace.dependencies]
|
||||||
|
dep = "0.1.0"
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file(
|
||||||
|
"bar/Cargo.toml",
|
||||||
|
r#"
|
||||||
|
cargo-features = ["workspace-inheritance"]
|
||||||
|
|
||||||
|
[project]
|
||||||
|
workspace = ".."
|
||||||
|
name = "bar"
|
||||||
|
version = "0.2.0"
|
||||||
|
authors = []
|
||||||
|
[dependencies]
|
||||||
|
dep = { workspace = true, optional = true }
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.file("LICENSE", "license")
|
|
||||||
.file("README.md", "README.md")
|
|
||||||
.file("bar/src/main.rs", "fn main() {}")
|
.file("bar/src/main.rs", "fn main() {}")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("build")
|
p.cargo("build")
|
||||||
.masquerade_as_nightly_cargo()
|
.masquerade_as_nightly_cargo()
|
||||||
.cwd("bar")
|
|
||||||
.with_status(101)
|
|
||||||
.with_stderr(
|
.with_stderr(
|
||||||
"\
|
"\
|
||||||
[ERROR] failed to parse manifest at `[CWD]/Cargo.toml`
|
[UPDATING] `[..]` index
|
||||||
|
[COMPILING] bar v0.2.0 ([CWD]/bar)
|
||||||
Caused by:
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
||||||
error inheriting `version` from workspace root manifest's `workspace.version`
|
|
||||||
|
|
||||||
Caused by:
|
|
||||||
inheriting from a parent workspace is not implemented yet
|
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn error_on_unimplemented_inheritance_dependencies() {
|
fn inherit_dependency_features() {
|
||||||
|
Package::new("dep", "0.1.0")
|
||||||
|
.feature("fancy", &["fancy_dep"])
|
||||||
|
.add_dep(Dependency::new("fancy_dep", "0.2").optional(true))
|
||||||
|
.file("src/lib.rs", "")
|
||||||
|
.publish();
|
||||||
|
|
||||||
|
Package::new("fancy_dep", "0.2.4").publish();
|
||||||
|
Package::new("dancy_dep", "0.6.8").publish();
|
||||||
|
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
cargo-features = ["workspace-inheritance"]
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "bar"
|
||||||
|
version = "0.2.0"
|
||||||
|
authors = []
|
||||||
|
[dependencies]
|
||||||
|
dep = { workspace = true, features = ["fancy"] }
|
||||||
|
|
||||||
|
[workspace]
|
||||||
|
members = []
|
||||||
|
[workspace.dependencies]
|
||||||
|
dep = "0.1"
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/main.rs", "fn main() {}")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("build")
|
||||||
|
.masquerade_as_nightly_cargo()
|
||||||
|
.with_stderr(
|
||||||
|
"\
|
||||||
|
[UPDATING] `[..]` index
|
||||||
|
[DOWNLOADING] crates ...
|
||||||
|
[DOWNLOADED] fancy_dep v0.2.4 ([..])
|
||||||
|
[DOWNLOADED] dep v0.1.0 ([..])
|
||||||
|
[COMPILING] fancy_dep v0.2.4
|
||||||
|
[COMPILING] dep v0.1.0
|
||||||
|
[COMPILING] bar v0.2.0 ([CWD])
|
||||||
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
|
let lockfile = p.read_lockfile();
|
||||||
|
assert!(lockfile.contains("dep"));
|
||||||
|
assert!(lockfile.contains("fancy_dep"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn inherit_detailed_dependencies() {
|
||||||
let git_project = git::new("detailed", |project| {
|
let git_project = git::new("detailed", |project| {
|
||||||
project
|
project
|
||||||
.file("Cargo.toml", &basic_lib_manifest("detailed"))
|
.file("Cargo.toml", &basic_lib_manifest("detailed"))
|
||||||
@ -641,7 +999,6 @@ fn error_on_unimplemented_inheritance_dependencies() {
|
|||||||
r#"
|
r#"
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["bar"]
|
members = ["bar"]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
detailed = {{ git = '{}', branch = "branchy" }}
|
detailed = {{ git = '{}', branch = "branchy" }}
|
||||||
"#,
|
"#,
|
||||||
@ -658,7 +1015,6 @@ fn error_on_unimplemented_inheritance_dependencies() {
|
|||||||
name = "bar"
|
name = "bar"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = []
|
authors = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
detailed = { workspace = true }
|
detailed = { workspace = true }
|
||||||
"#,
|
"#,
|
||||||
@ -666,23 +1022,19 @@ fn error_on_unimplemented_inheritance_dependencies() {
|
|||||||
.file("bar/src/main.rs", "fn main() {}")
|
.file("bar/src/main.rs", "fn main() {}")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
let git_root = git_project.root();
|
||||||
|
|
||||||
p.cargo("build")
|
p.cargo("build")
|
||||||
.masquerade_as_nightly_cargo()
|
.masquerade_as_nightly_cargo()
|
||||||
.with_status(101)
|
.with_stderr(&format!(
|
||||||
.with_stderr(
|
|
||||||
"\
|
"\
|
||||||
[ERROR] failed to load manifest for workspace member `[CWD]/bar`
|
[UPDATING] git repository `{}`\n\
|
||||||
|
[COMPILING] detailed v0.5.0 ({}?branch=branchy#[..])\n\
|
||||||
Caused by:
|
[COMPILING] bar v0.2.0 ([CWD]/bar)\n\
|
||||||
failed to parse manifest at `[CWD]/bar/Cargo.toml`
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n",
|
||||||
|
path2url(&git_root),
|
||||||
Caused by:
|
path2url(&git_root),
|
||||||
error reading `dependencies.detailed` from workspace root manifest's `workspace.dependencies.detailed`
|
))
|
||||||
|
|
||||||
Caused by:
|
|
||||||
inheriting from a parent workspace is not implemented yet
|
|
||||||
",
|
|
||||||
)
|
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -775,6 +1127,149 @@ Caused by:
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn error_malformed_workspace_root() {
|
||||||
|
registry::init();
|
||||||
|
|
||||||
|
let p = project().build();
|
||||||
|
|
||||||
|
let _ = git::repo(&paths::root().join("foo"))
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[workspace]
|
||||||
|
members = [invalid toml
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/main.rs", "fn main() {}")
|
||||||
|
.file(
|
||||||
|
"bar/Cargo.toml",
|
||||||
|
r#"
|
||||||
|
cargo-features = ["workspace-inheritance"]
|
||||||
|
|
||||||
|
[package]
|
||||||
|
name = "bar"
|
||||||
|
workspace = ".."
|
||||||
|
version = "1.2.3"
|
||||||
|
authors = ["rustaceans"]
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("bar/src/main.rs", "fn main() {}")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("build")
|
||||||
|
.masquerade_as_nightly_cargo()
|
||||||
|
.cwd("bar")
|
||||||
|
.with_status(101)
|
||||||
|
.with_stderr(
|
||||||
|
"\
|
||||||
|
[ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
|
||||||
|
|
||||||
|
Caused by:
|
||||||
|
[..]
|
||||||
|
|
||||||
|
Caused by:
|
||||||
|
[..]
|
||||||
|
|
|
||||||
|
3 | members = [invalid toml
|
||||||
|
| ^
|
||||||
|
Unexpected `i`
|
||||||
|
Expected newline or `#`
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn error_no_root_workspace() {
|
||||||
|
registry::init();
|
||||||
|
|
||||||
|
let p = project().build();
|
||||||
|
|
||||||
|
let _ = git::repo(&paths::root().join("foo"))
|
||||||
|
.file(
|
||||||
|
"bar/Cargo.toml",
|
||||||
|
r#"
|
||||||
|
cargo-features = ["workspace-inheritance"]
|
||||||
|
|
||||||
|
[package]
|
||||||
|
name = "bar"
|
||||||
|
workspace = ".."
|
||||||
|
version = "1.2.3"
|
||||||
|
authors = ["rustaceans"]
|
||||||
|
description = { workspace = true }
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/main.rs", "fn main() {}")
|
||||||
|
.file("bar/src/main.rs", "fn main() {}")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("build")
|
||||||
|
.masquerade_as_nightly_cargo()
|
||||||
|
.cwd("bar")
|
||||||
|
.with_status(101)
|
||||||
|
.with_stderr(
|
||||||
|
"\
|
||||||
|
[ERROR] failed to parse manifest at `[..]/Cargo.toml`
|
||||||
|
|
||||||
|
Caused by:
|
||||||
|
error inheriting `description` from workspace root manifest's `workspace.description`
|
||||||
|
|
||||||
|
Caused by:
|
||||||
|
root of a workspace inferred but wasn't a root: [..]/Cargo.toml
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn error_inherit_unspecified_dependency() {
|
||||||
|
let p = project().build();
|
||||||
|
|
||||||
|
let _ = git::repo(&paths::root().join("foo"))
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[workspace]
|
||||||
|
members = ["bar"]
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/main.rs", "fn main() {}")
|
||||||
|
.file(
|
||||||
|
"bar/Cargo.toml",
|
||||||
|
r#"
|
||||||
|
cargo-features = ["workspace-inheritance"]
|
||||||
|
|
||||||
|
[package]
|
||||||
|
name = "bar"
|
||||||
|
workspace = ".."
|
||||||
|
version = "1.2.3"
|
||||||
|
authors = ["rustaceans"]
|
||||||
|
[dependencies]
|
||||||
|
foo = { workspace = true }
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("bar/src/main.rs", "fn main() {}")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("build")
|
||||||
|
.masquerade_as_nightly_cargo()
|
||||||
|
.cwd("bar")
|
||||||
|
.with_status(101)
|
||||||
|
.with_stderr(
|
||||||
|
"\
|
||||||
|
[ERROR] failed to parse manifest at `[CWD]/Cargo.toml`
|
||||||
|
|
||||||
|
Caused by:
|
||||||
|
error reading `dependencies.foo` from workspace root manifest's `workspace.dependencies.foo`
|
||||||
|
|
||||||
|
Caused by:
|
||||||
|
`workspace.dependencies` was not defined
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn workspace_inheritance_not_enabled() {
|
fn workspace_inheritance_not_enabled() {
|
||||||
registry::init();
|
registry::init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user