diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2023-03-09 10:23:42 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2023-03-09 10:37:41 +0100 |
commit | 93433ff067978e76a90e9bf87741f332bd2fce20 (patch) | |
tree | 9770c9db50dced57870aa88fac8469d14d42dcc7 | |
parent | c9c5d9be5bde3b356a5a18af8324b59cc1492642 (diff) |
Replace "tempdir" with "tempfile"
Fixes the issue that the "tempdir" crate is unmaintained:
https://rustsec.org/advisories/RUSTSEC-2018-0017
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | Cargo.lock | 73 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | tests/generate_command.rs | 10 | ||||
-rw-r--r-- | tests/init_command.rs | 20 | ||||
-rw-r--r-- | tests/new_command.rs | 40 | ||||
-rw-r--r-- | tests/new_command_creates_default_header.rs | 5 | ||||
-rw-r--r-- | tests/new_command_editor.rs | 10 | ||||
-rw-r--r-- | tests/no_config_error.rs | 10 | ||||
-rw-r--r-- | tests/no_repo_error.rs | 10 | ||||
-rw-r--r-- | tests/release_command.rs | 10 | ||||
-rw-r--r-- | tests/verify_metadata_command.rs | 10 |
11 files changed, 106 insertions, 94 deletions
@@ -129,7 +129,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "tempdir", + "tempfile", "thiserror", "time", "toml", @@ -361,12 +361,6 @@ dependencies = [ ] [[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] name = "generic-array" version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -877,43 +871,6 @@ dependencies = [ ] [[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] name = "redox_syscall" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -946,15 +903,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - -[[package]] name = "rustc-demangle" version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1134,27 +1082,16 @@ dependencies = [ ] [[package]] -name = "tempdir" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" -dependencies = [ - "rand", - "remove_dir_all", -] - -[[package]] name = "tempfile" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" dependencies = [ "cfg-if", "fastrand", - "libc", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix 0.36.3", + "windows-sys 0.42.0", ] [[package]] @@ -41,4 +41,4 @@ walkdir = "2.3.2" assert_cmd = "2.0.5" indoc = "2.0.0" predicates = "2.1.5" -tempdir = "0.3.7" +tempfile = "3.4.0" diff --git a/tests/generate_command.rs b/tests/generate_command.rs index 6ebc936..c66682b 100644 --- a/tests/generate_command.rs +++ b/tests/generate_command.rs @@ -6,7 +6,10 @@ mod common; #[test] fn generate_command_creates_new_directory() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo(temp_dir.path(), "cargo-changelog-testpkg-generatecommand"); self::common::init_cargo_changelog(temp_dir.path()); @@ -32,7 +35,10 @@ fn generate_command_creates_new_directory() { #[test] fn generate_command_moves_from_unreleased_dir() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo(temp_dir.path(), "cargo-changelog-testpkg-generatecommand"); self::common::init_cargo_changelog(temp_dir.path()); diff --git a/tests/init_command.rs b/tests/init_command.rs index 26b2106..c827321 100644 --- a/tests/init_command.rs +++ b/tests/init_command.rs @@ -2,7 +2,10 @@ mod common; #[test] fn init_command_creates_config_file() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); @@ -14,7 +17,10 @@ fn init_command_creates_config_file() { #[test] fn init_command_creates_fragment_dir() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); @@ -26,7 +32,10 @@ fn init_command_creates_fragment_dir() { #[test] fn init_command_creates_fragment_dir_unreleased() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); @@ -38,7 +47,10 @@ fn init_command_creates_fragment_dir_unreleased() { #[test] fn init_command_creates_default_template() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); diff --git a/tests/new_command.rs b/tests/new_command.rs index 68de468..f9f8680 100644 --- a/tests/new_command.rs +++ b/tests/new_command.rs @@ -4,7 +4,10 @@ mod common; #[test] fn new_command_creates_yaml_file() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); @@ -74,7 +77,10 @@ fn new_command_creates_yaml_file() { #[test] fn new_command_creates_unreleased_gitkeep() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); @@ -93,13 +99,19 @@ fn new_command_creates_unreleased_gitkeep() { #[test] fn new_command_with_text_creates_yaml_with_text_from_stdin() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); let test_text = "This is a test text"; { - let text_temp_dir = tempdir::TempDir::new("cargo-changelog-new-test-text").unwrap(); + let text_temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog-new-test-text") + .tempdir() + .unwrap(); let path = text_temp_dir.path().join("text_file.txt"); let mut file = std::fs::OpenOptions::new() .create(true) @@ -153,13 +165,19 @@ fn new_command_with_text_creates_yaml_with_text_from_stdin() { #[test] fn new_command_with_text_creates_yaml_with_text_from_file() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); let test_text = "This is a test text"; { - let text_temp_dir = tempdir::TempDir::new("cargo-changelog-new-test-text").unwrap(); + let text_temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog-new-test-text") + .tempdir() + .unwrap(); let path = text_temp_dir.path().join("text_file.txt"); let mut file = std::fs::OpenOptions::new() .create(true) @@ -215,7 +233,10 @@ fn new_command_with_text_creates_yaml_with_text_from_file() { #[test] fn new_command_creates_toml_header() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); @@ -262,7 +283,10 @@ fn new_command_creates_toml_header() { #[test] fn new_command_cannot_create_nonexistent_oneof() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); diff --git a/tests/new_command_creates_default_header.rs b/tests/new_command_creates_default_header.rs index 632a37e..51342f0 100644 --- a/tests/new_command_creates_default_header.rs +++ b/tests/new_command_creates_default_header.rs @@ -4,7 +4,10 @@ mod common; #[test] fn new_command_creates_default_header() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); diff --git a/tests/new_command_editor.rs b/tests/new_command_editor.rs index a126b75..7cdafdc 100644 --- a/tests/new_command_editor.rs +++ b/tests/new_command_editor.rs @@ -19,12 +19,18 @@ touch "${1}.edited" #[test] fn new_command_opens_editor() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); let (script_temp_dir, editor_script_path) = { - let temp = tempdir::TempDir::new("cargo-changelog-new-editor-script-helper").unwrap(); + let temp = tempfile::Builder::new() + .prefix("cargo-changelog-new-editor-script-helper") + .tempdir() + .unwrap(); let script_path = temp.path().join("editor"); let mut script = std::fs::OpenOptions::new() .create(true) diff --git a/tests/no_config_error.rs b/tests/no_config_error.rs index dade6b3..e77900d 100644 --- a/tests/no_config_error.rs +++ b/tests/no_config_error.rs @@ -4,7 +4,10 @@ mod common; #[test] fn no_configuration_file_errors() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); Command::cargo_bin("cargo-changelog") @@ -17,7 +20,10 @@ fn no_configuration_file_errors() { #[test] fn no_configuration_file_errors_with_error_message() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); Command::cargo_bin("cargo-changelog") diff --git a/tests/no_repo_error.rs b/tests/no_repo_error.rs index 8cc8be8..5337239 100644 --- a/tests/no_repo_error.rs +++ b/tests/no_repo_error.rs @@ -2,7 +2,10 @@ use assert_cmd::Command; #[test] fn no_repo_errors() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); Command::cargo_bin("cargo-changelog") .unwrap() @@ -14,7 +17,10 @@ fn no_repo_errors() { #[test] fn no_repo_errors_with_no_repo_error_message() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); Command::cargo_bin("cargo-changelog") .unwrap() diff --git a/tests/release_command.rs b/tests/release_command.rs index e69a94b..552c470 100644 --- a/tests/release_command.rs +++ b/tests/release_command.rs @@ -6,7 +6,10 @@ mod common; #[test] fn release_command_works() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo(temp_dir.path(), "release_command_works"); self::common::init_cargo_changelog(temp_dir.path()); @@ -51,7 +54,10 @@ fn release_command_works() { #[test] fn release_command_works_for_alpha_release() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo(temp_dir.path(), "release_command_works_for_alpha_release"); self::common::init_cargo_changelog(temp_dir.path()); diff --git a/tests/verify_metadata_command.rs b/tests/verify_metadata_command.rs index 0c63842..847d9fe 100644 --- a/tests/verify_metadata_command.rs +++ b/tests/verify_metadata_command.rs @@ -4,7 +4,10 @@ mod common; #[test] fn verify_metadata_command_succeeds_with_no_changelogs() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); @@ -18,7 +21,10 @@ fn verify_metadata_command_succeeds_with_no_changelogs() { #[test] fn verify_metadata_command_succeeds_with_empty_changelog() { - let temp_dir = tempdir::TempDir::new("cargo-changelog").unwrap(); + let temp_dir = tempfile::Builder::new() + .prefix("cargo-changelog") + .tempdir() + .unwrap(); self::common::init_git(temp_dir.path()); self::common::init_cargo_changelog(temp_dir.path()); |