Skip to content

Commit

Permalink
Add ignored test case for dev-deps propagation (#1030)
Browse files Browse the repository at this point in the history
commit-id:001f9da5

---

**Stack**:
- #1007
- #1030⚠️ *Part of a stack created by [spr](https://github.com/ejoffe/spr). Do
not merge manually using the UI - doing so may have unexpected results.*
  • Loading branch information
maciektr authored Jan 12, 2024
1 parent 9706780 commit 1f1408b
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 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

0 comments on commit 1f1408b

Please sign in to comment.