-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Implement path-bases (RFC 3529) 2/n: support for nested packages #14416
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -17,6 +17,8 @@ use cargo_test_support::registry::Package; | |
use cargo_test_support::{basic_lib_manifest, basic_manifest, git, main_file, project}; | ||
use cargo_test_support::{sleep_ms, str, t, Project}; | ||
|
||
use crate::config::write_config_at; | ||
|
||
#[cargo_test] | ||
fn cargo_compile_simple_git_dep() { | ||
let project = project(); | ||
|
@@ -380,6 +382,109 @@ hello world | |
.run(); | ||
} | ||
|
||
#[cargo_test] | ||
fn dependency_in_submodule_via_path_base() { | ||
// Using a submodule prevents the dependency from being discovered during the directory walk, | ||
// so Cargo will need to follow the path dependency to discover it. | ||
|
||
let git_project = git::new("dep1", |project| { | ||
project | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
cargo-features = ["path-bases"] | ||
|
||
[package] | ||
name = "dep1" | ||
version = "0.5.0" | ||
edition = "2015" | ||
authors = ["[email protected]"] | ||
|
||
[dependencies] | ||
dep2 = { version = "0.5.0", base = "submodules", path = "dep2" } | ||
|
||
[lib] | ||
name = "dep1" | ||
"#, | ||
) | ||
.file( | ||
"src/dep1.rs", | ||
r#" | ||
extern crate dep2; | ||
|
||
pub fn hello() -> &'static str { | ||
dep2::hello() | ||
} | ||
"#, | ||
) | ||
}); | ||
|
||
let git_project2 = git::new("dep2", |project| { | ||
project | ||
.file("Cargo.toml", &basic_lib_manifest("dep2")) | ||
.file( | ||
"src/dep2.rs", | ||
r#" | ||
pub fn hello() -> &'static str { | ||
"hello world" | ||
} | ||
"#, | ||
) | ||
}); | ||
|
||
let repo = git2::Repository::open(&git_project.root()).unwrap(); | ||
let url = git_project2.root().to_url().to_string(); | ||
git::add_submodule(&repo, &url, Path::new("submods/dep2")); | ||
git::commit(&repo); | ||
|
||
write_config_at( | ||
paths::home().join(".cargo/config.toml"), | ||
r#" | ||
[path-bases] | ||
submodules = '../dep1/submods' | ||
"#, | ||
); | ||
Comment on lines
+440
to
+446
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imo writing path-bases on behalf of git dependencies seems very questionable
If you want to test |
||
|
||
let p = project() | ||
.file( | ||
"Cargo.toml", | ||
&format!( | ||
r#" | ||
[package] | ||
name = "foo" | ||
version = "0.5.0" | ||
edition = "2015" | ||
authors = ["[email protected]"] | ||
|
||
[dependencies] | ||
dep1 = {{ version = "0.5.0", git = '{}' }} | ||
|
||
[[bin]] | ||
name = "foo" | ||
"#, | ||
git_project.url() | ||
), | ||
) | ||
.file( | ||
"src/foo.rs", | ||
&main_file(r#""{}", dep1::hello()"#, &["dep1"]), | ||
) | ||
.build(); | ||
|
||
p.cargo("build") | ||
.masquerade_as_nightly_cargo(&["path-bases"]) | ||
.run(); | ||
|
||
assert!(p.bin("foo").is_file()); | ||
|
||
p.process(&p.bin("foo")) | ||
.with_stdout_data(str![[r#" | ||
hello world | ||
|
||
"#]]) | ||
.run(); | ||
} | ||
|
||
#[cargo_test] | ||
fn cargo_compile_with_malformed_nested_paths() { | ||
let git_project = git::new("dep1", |project| { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Aren't we operating on a normalized package and don't we resolve path-bases during normaization?
For either of us to verify that is one of the reasons I recommend splitting commits into