-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ptw/issue 74 Do not skelefy vendored directory (#120)
* Reorder skeleton so that we can pass config file contents into when we discover the manifests * Ignore vendored sources Derive the directory for the vendored sources using the `source.crates-io` field from `.cargo/config.toml` * Add failing test * Refactor `vendored_directory` and make test pass! * Remove debug println * Incorporate PR feedback Uses `format` instead of string addition Co-authored-by: Preston TW <[email protected]>
- Loading branch information
1 parent
e61ac69
commit dc12f7c
Showing
3 changed files
with
107 additions
and
3 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -807,6 +807,91 @@ version = "0.8.0" | |
); | ||
} | ||
|
||
#[test] | ||
pub fn ignore_vendored_directory() { | ||
// Arrange | ||
let content = r#" | ||
[package] | ||
name = "test-dummy" | ||
version = "1.2.3" | ||
edition = "2018" | ||
[dependencies] | ||
rocket = "0.5.0-rc.1" | ||
"#; | ||
let cargo_config = r#" | ||
[source.crates-io] | ||
replace-with = "vendored-sources" | ||
[source.vendored-sources] | ||
directory = "vendor" | ||
"#; | ||
|
||
let rocket_cargo_toml = r#"[package] | ||
edition = "2018" | ||
name = "rocket" | ||
version = "0.5.0-rc.1" | ||
authors = ["Sergio Benitez <[email protected]>"] | ||
build = "build.rs" | ||
description = "Web framework with a focus on usability, security, extensibility, and speed.\n" | ||
homepage = "https://rocket.rs" | ||
documentation = "https://api.rocket.rs/v0.5-rc/rocket/" | ||
readme = "../../README.md" | ||
keywords = ["rocket", "web", "framework", "server"] | ||
categories = ["web-programming::http-server"] | ||
license = "MIT OR Apache-2.0" | ||
repository = "https://github.com/SergioBenitez/Rocket" | ||
[package.metadata.docs.rs] | ||
all-features = true | ||
[dependencies.rocket_dep] | ||
version = "0.3.2""#; | ||
|
||
let rocket_dep_cargo_toml = r#"[package] | ||
edition = "2018" | ||
name = "rocket_dep" | ||
version = "0.3.2" | ||
authors = ["Test author"] | ||
description = "sample package representing all of rocket's dependencies""#; | ||
|
||
let recipe_directory = TempDir::new().unwrap(); | ||
let manifest = recipe_directory.child("Cargo.toml"); | ||
manifest.write_str(content).unwrap(); | ||
recipe_directory.child(".cargo").create_dir_all().unwrap(); | ||
recipe_directory | ||
.child(".cargo") | ||
.child("config.toml") | ||
.write_str(cargo_config) | ||
.unwrap(); | ||
recipe_directory.child("src").create_dir_all().unwrap(); | ||
recipe_directory | ||
.child("src") | ||
.child("main.rs") | ||
.touch() | ||
.unwrap(); | ||
|
||
let vendored = recipe_directory.child("vendor"); | ||
let rocket = vendored.child("rocket"); | ||
let sample_rocket_dep = vendored.child("rocket_dep"); | ||
rocket.create_dir_all().unwrap(); | ||
sample_rocket_dep.create_dir_all().unwrap(); | ||
|
||
rocket | ||
.child("Cargo.toml") | ||
.write_str(rocket_cargo_toml) | ||
.unwrap(); | ||
|
||
sample_rocket_dep | ||
.child("Cargo.toml") | ||
.write_str(rocket_dep_cargo_toml) | ||
.unwrap(); | ||
|
||
// Act | ||
let skeleton = Skeleton::derive(recipe_directory.path()).unwrap(); | ||
|
||
// Assert | ||
assert_eq!(1, skeleton.manifests.len()); | ||
} | ||
|
||
fn check(actual: &str, expect: Expect) { | ||
let actual = actual.to_string(); | ||
expect.assert_eq(&actual); | ||
|