Skip to content

Commit e9dced1

Browse files
committed
refactor(ws): Group target-dir/build-dir init
1 parent ce58ead commit e9dced1

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/cargo/core/workspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ impl<'gctx> Workspace<'gctx> {
215215
/// before returning it, so `Ok` is only returned for valid workspaces.
216216
pub fn new(manifest_path: &Path, gctx: &'gctx GlobalContext) -> CargoResult<Workspace<'gctx>> {
217217
let mut ws = Workspace::new_default(manifest_path.to_path_buf(), gctx);
218-
ws.target_dir = gctx.target_dir()?;
219218

220219
if manifest_path.is_relative() {
221220
bail!(
@@ -226,6 +225,7 @@ impl<'gctx> Workspace<'gctx> {
226225
ws.root_manifest = ws.find_root(manifest_path)?;
227226
}
228227

228+
ws.target_dir = gctx.target_dir()?;
229229
ws.build_dir = gctx.build_dir(
230230
ws.root_manifest
231231
.as_ref()

tests/testsuite/bad_config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ fn invalid_global_config() {
159159
p.cargo("check -v")
160160
.with_status(101)
161161
.with_stderr_data(str![[r#"
162-
[ERROR] could not load Cargo configuration
162+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
163+
164+
Caused by:
165+
could not load Cargo configuration
163166
164167
Caused by:
165168
could not parse TOML configuration in `[ROOT]/foo/.cargo/config.toml`

tests/testsuite/config.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,19 @@ target-dir = ''
16491649

16501650
#[cargo_test]
16511651
fn cargo_target_empty_env() {
1652-
let project = project().build();
1652+
let project = project()
1653+
.file(
1654+
"Cargo.toml",
1655+
r#"
1656+
[package]
1657+
name = "foo"
1658+
authors = []
1659+
version = "0.0.0"
1660+
build = "build.rs"
1661+
"#,
1662+
)
1663+
.file("src/lib.rs", "")
1664+
.build();
16531665

16541666
project.cargo("check")
16551667
.env("CARGO_TARGET_DIR", "")

0 commit comments

Comments
 (0)