-
Notifications
You must be signed in to change notification settings - Fork 9
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
Call out in docs that you can operate on things besides the built-in temp support #48
Comments
So, the #[test]
fn default_works() {
let temp_package = common::create_test_package();
let package = ChildPath::new(temp_package.path());
// ...
} which would require updating/modifying every test? I understand this is a workaround, but it would be nicer if I could just change the #[allow(dead_code)]
pub fn create_test_package() -> assert_fs::TempDir {
let temp_dir = tempfile::Builder::new().prefix("cargo_wix_test_").tempdir().unwrap();
let cargo_init_status = Command::new("cargo")
.arg("init")
.arg("--bin")
.arg("--quiet")
.arg("--vcs")
.arg("none")
.arg(temp_dir.path())
.status()
.expect("Creation of test Cargo package");
assert!(cargo_init_status.success());
temp_dir.into()
//
// or
// assert_fs::TempDir::from(temp_dir)
//
// or do the "upcast" earlier with:
//
// let temp_dir = assert_fs::TempDir::from(tempfile::Builder::new().prefix("cargo_wix_test_"));
} Justification for needing the prefix and "special" temporary directory name is given in #46. |
I know it has been awhile, but a brief update on this since it is still open. I have upgraded to v0.11 and changed the #[allow(dead_code)]
pub fn create_test_package() -> TempDir {
let temp_dir = TempDir::new().unwrap();
let cargo_init_status = Command::new("cargo")
.arg("init")
.arg("--bin")
.arg("--quiet")
.arg("--vcs")
.arg("none")
.arg("--name")
.arg(PACKAGE_NAME)
.arg(temp_dir.path())
.status()
.expect("Creation of test Cargo package");
assert!(cargo_init_status.success());
temp_dir
} The Side note, on Windows 10, the temporary directory does have a leading period, but this no longer appears to be a problem. I think there were some recent updates to Windows Explorer that better handle leading periods in file and folder names and any problems I was experiencing with this were specific to an older version of Windows I was runing. I still think it would be nice to have |
Could you create a separate issue for that? I'll then copy over relevant parts from #46 I'm still hesitant about exposing |
This required changing the implementation of creating test projects. The `.tmp` prefix can be used in Windows but the cargo project name cannot. Thus, the `--name <NAME>` option needed to be used for creating a test package because the `TempDir` type from the assert_fs package does not support the tempfile TempDir builder or changing the prefix in newer versions. See Issues [#46] and [#48] from the `assert_fs` project for more information. [#46]: assert-rs/assert_fs#46 [#48]: assert-rs/assert_fs#48
In case someone wants custom temp dir functionality or some other unknown situation.
From @volks73 at #46
This can be worked around today with
ChildPath
but the docs never talk about it!The text was updated successfully, but these errors were encountered: