Skip to content
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

Add ignored test case for conflicting deps in unrelated ws members #1007

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions scarb/tests/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::BTreeMap;

use assert_fs::prelude::*;
use indoc::indoc;
use itertools::Itertools;
use serde_json::json;

use scarb_metadata::{Cfg, DepKind, ManifestMetadataBuilder, Metadata, PackageMetadata};
Expand Down Expand Up @@ -31,6 +32,18 @@ fn packages_and_deps(meta: Metadata) -> BTreeMap<String, Vec<String>> {
.collect::<BTreeMap<_, _>>()
}

fn units_and_components(meta: Metadata) -> BTreeMap<String, Vec<String>> {
meta.compilation_units
.iter()
.map(|cu| {
(
cu.target.name.clone(),
cu.components.iter().map(|c| c.name.clone()).collect_vec(),
)
})
.collect::<BTreeMap<_, _>>()
}

#[test]
fn simple() {
let t = assert_fs::TempDir::new().unwrap();
Expand Down Expand Up @@ -259,6 +272,81 @@ fn dev_dependencies() {
);
}

#[test]
#[ignore = "not implemented yet"]
fn dev_deps_are_not_propagated() {
// TODO(maciektr): Make sure dev-deps are not propagated.
let t = assert_fs::TempDir::new().unwrap();

let dep1 = t.child("dep1");
ProjectBuilder::start().name("dep1").build(&dep1);

let dep2 = t.child("dep2");
ProjectBuilder::start()
.name("dep2")
.dev_dep("dep1", &dep1)
.build(&dep2);

let pkg = t.child("pkg");
ProjectBuilder::start()
.name("x")
.dev_dep("dep2", &dep2)
.build(&pkg);

let metadata = Scarb::quick_snapbox()
.arg("--json")
.arg("metadata")
.arg("--format-version")
.arg("1")
.current_dir(&pkg)
.stdout_json::<Metadata>();

assert_eq!(
packages_and_deps(metadata.clone()),
BTreeMap::from_iter([
("core".to_string(), vec![]),
("test_plugin".to_string(), vec![]),
(
"x".to_string(),
vec![
"core".to_string(),
"dep2".to_string(),
"test_plugin".to_string(),
]
),
(
"dep1".to_string(),
vec!["core".to_string(), "test_plugin".to_string()]
),
(
"dep2".to_string(),
vec![
"core".to_string(),
"dep1".to_string(),
"test_plugin".to_string()
]
)
])
);

assert_eq!(
units_and_components(metadata),
BTreeMap::from_iter(vec![
("x".to_string(), vec!["core".to_string(), "x".to_string()]),
(
"x_unittest".to_string(),
vec![
"core".to_string(),
// With dev-deps propagation enabled, this would be included
// "dep1".to_string(),
"dep2".to_string(),
"x".to_string()
]
),
])
);
}

#[test]
fn no_dep() {
let t = assert_fs::TempDir::new().unwrap();
Expand Down Expand Up @@ -557,6 +645,69 @@ fn workspace_with_root() {
)
}

#[test]
#[ignore = "not implemented yet"]
fn workspace_with_conflicting_dep() {
// TODO(#2): Allow using conflicting dependencies in unrelated workspace members.
let t = assert_fs::TempDir::new().unwrap().child("test_workspace");
let dep1 = t.child("dep1");
ProjectBuilder::start()
.name("some_dep")
.version("1.0.0")
.build(&dep1);
let dep2 = t.child("dep2");
ProjectBuilder::start()
.name("some_dep")
.version("2.0.0")
.build(&dep2);
let pkg1 = t.child("first");
ProjectBuilder::start()
.name("first")
.dep("some_dep", &dep1)
.build(&pkg1);
let pkg2 = t.child("second");
ProjectBuilder::start()
.name("second")
.dep("some_dep", &dep2)
.build(&pkg2);
WorkspaceBuilder::start()
.add_member("first")
.add_member("second")
.build(&t);

let metadata = Scarb::quick_snapbox()
.args(["--json", "metadata", "--format-version=1"])
.current_dir(&t)
.stdout_json::<Metadata>();
assert_eq!(
packages_and_deps(metadata),
BTreeMap::from_iter([
("core".to_string(), vec![]),
("test_plugin".to_string(), vec![]),
(
"first".to_string(),
vec![
"core".to_string(),
"some_dep".to_string(),
"test_plugin".to_string()
]
),
(
"second".to_string(),
vec![
"core".to_string(),
"some_dep".to_string(),
"test_plugin".to_string()
]
),
(
"some_dep".to_string(),
vec!["core".to_string(), "test_plugin".to_string()]
),
])
)
}

#[test]
fn workspace_as_dep() {
let t = assert_fs::TempDir::new().unwrap();
Expand Down
Loading