Skip to content

Commit 107dea8

Browse files
committed
test(paths): migrate paths overrides config to e2e test
It is weird that we are testing our internal API for the case of path overrides unsupporting env vars
1 parent cfb2230 commit 107dea8

File tree

2 files changed

+50
-27
lines changed

2 files changed

+50
-27
lines changed

tests/testsuite/config_cli.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -264,33 +264,6 @@ fn merges_table() {
264264
assert_eq!(gctx.get::<i32>("foo.key5").unwrap(), 9);
265265
}
266266

267-
#[cargo_test]
268-
fn merge_array_mixed_def_paths() {
269-
// Merging of arrays with different def sites.
270-
write_config_toml(
271-
"
272-
paths = ['file']
273-
",
274-
);
275-
// Create a directory for CWD to differentiate the paths.
276-
let somedir = paths::root().join("somedir");
277-
fs::create_dir(&somedir).unwrap();
278-
let gctx = GlobalContextBuilder::new()
279-
.cwd(&somedir)
280-
.config_arg("paths=['cli']")
281-
// env is currently ignored for get_list()
282-
.env("CARGO_PATHS", "env")
283-
.build();
284-
let paths = gctx.paths_overrides().unwrap().unwrap();
285-
// The definition for the root value is somewhat arbitrary, but currently starts with the file because that is what is loaded first.
286-
assert_eq!(paths.definition, Definition::Path(paths::root()));
287-
assert_eq!(paths.val.len(), 2);
288-
assert_eq!(paths.val[0].0, "file");
289-
assert_eq!(paths.val[0].1.root(&gctx), paths::root());
290-
assert_eq!(paths.val[1].0, "cli");
291-
assert_eq!(paths.val[1].1.root(&gctx), somedir);
292-
}
293-
294267
#[cargo_test]
295268
fn enforces_format() {
296269
// These dotted key expressions should all be fine.

tests/testsuite/paths.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,53 @@ https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html
250250
"#]])
251251
.run();
252252
}
253+
254+
#[cargo_test]
255+
fn env_paths_overrides_not_supported() {
256+
Package::new("file", "0.1.0").publish();
257+
Package::new("cli", "0.1.0").publish();
258+
Package::new("env", "0.1.0").publish();
259+
260+
let p = project()
261+
.file(
262+
"Cargo.toml",
263+
r#"
264+
[package]
265+
name = "foo"
266+
edition = "2015"
267+
268+
[dependencies]
269+
file = "0.1.0"
270+
cli = "0.1.0"
271+
env = "0.1.0"
272+
"#,
273+
)
274+
.file("src/lib.rs", "")
275+
.file("file/Cargo.toml", &basic_manifest("file", "0.2.0"))
276+
.file("file/src/lib.rs", "")
277+
.file("cli/Cargo.toml", &basic_manifest("cli", "0.2.0"))
278+
.file("cli/src/lib.rs", "")
279+
.file("env/Cargo.toml", &basic_manifest("env", "0.2.0"))
280+
.file("env/src/lib.rs", "")
281+
.file(".cargo/config.toml", r#"paths = ["file"]"#)
282+
.build();
283+
284+
p.cargo("check")
285+
.arg("--config")
286+
.arg("paths=['cli']")
287+
// paths overrides ignore env
288+
.env("CARGO_PATHS", "env")
289+
.with_stderr_data(str![[r#"
290+
[UPDATING] `dummy-registry` index
291+
[LOCKING] 3 packages to latest compatible versions
292+
[DOWNLOADING] crates ...
293+
[DOWNLOADED] env v0.1.0 (registry `dummy-registry`)
294+
[CHECKING] file v0.2.0 ([ROOT]/foo/file)
295+
[CHECKING] cli v0.2.0 ([ROOT]/foo/cli)
296+
[CHECKING] env v0.1.0
297+
[CHECKING] foo v0.0.0 ([ROOT]/foo)
298+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
299+
300+
"#]])
301+
.run();
302+
}

0 commit comments

Comments
 (0)