Skip to content

Commit 3f857e9

Browse files
committed
test(publish): Show the build-dir behavior
1 parent 05bf93c commit 3f857e9

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/testsuite/build_dir.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use std::path::PathBuf;
1313

1414
use crate::prelude::*;
15+
use cargo_test_support::registry::RegistryBuilder;
1516
use cargo_test_support::{Project, prelude::*};
1617
use cargo_test_support::{paths, project, str};
1718
use std::env::consts::{DLL_PREFIX, DLL_SUFFIX, EXE_SUFFIX};
@@ -359,6 +360,40 @@ fn cargo_package_should_build_in_build_dir_and_output_to_target_dir() {
359360
assert!(package_build_dir.join("foo-0.0.1").is_dir());
360361
}
361362

363+
#[cargo_test]
364+
fn cargo_publish_should_only_touch_build_dir() {
365+
let registry = RegistryBuilder::new().http_api().http_index().build();
366+
367+
let p = project()
368+
.file("src/main.rs", r#"fn main() { println!("Hello, World!") }"#)
369+
.file(
370+
".cargo/config.toml",
371+
r#"
372+
[build]
373+
target-dir = "target-dir"
374+
build-dir = "build-dir"
375+
"#,
376+
)
377+
.build();
378+
379+
p.cargo("publish")
380+
.replace_crates_io(registry.index_url())
381+
.enable_mac_dsym()
382+
.run();
383+
384+
assert_build_dir_layout(p.root().join("build-dir"), "debug");
385+
386+
let package_artifact_dir = p.root().join("target-dir/package");
387+
assert_exists(&package_artifact_dir);
388+
assert_exists(&package_artifact_dir.join("foo-0.0.1.crate"));
389+
assert!(package_artifact_dir.join("foo-0.0.1.crate").is_file());
390+
391+
let package_build_dir = p.root().join("build-dir/package");
392+
assert_exists(&package_build_dir);
393+
assert_exists(&package_build_dir.join("foo-0.0.1"));
394+
assert!(package_build_dir.join("foo-0.0.1").is_dir());
395+
}
396+
362397
#[cargo_test]
363398
fn cargo_clean_should_clean_the_target_dir_and_build_dir() {
364399
let p = project()

0 commit comments

Comments
 (0)