diff options
Diffstat (limited to 'crates/shirabe/tests/config')
| -rw-r--r-- | crates/shirabe/tests/config/json_config_source_test.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/crates/shirabe/tests/config/json_config_source_test.rs b/crates/shirabe/tests/config/json_config_source_test.rs index 293f32e..bab36a9 100644 --- a/crates/shirabe/tests/config/json_config_source_test.rs +++ b/crates/shirabe/tests/config/json_config_source_test.rs @@ -1,5 +1,36 @@ //! ref: composer/tests/Composer/Test/Config/JsonConfigSourceTest.php +use shirabe::util::filesystem::Filesystem; +use std::path::PathBuf; +use tempfile::TempDir; + +fn set_up() -> TearDown { + let fs = Filesystem::new(None); + // getUniqueTmpDirectory creates a fresh unique temp directory. + let working_dir = TempDir::new().unwrap(); + TearDown { fs, working_dir } +} + +struct TearDown { + fs: Filesystem, + working_dir: TempDir, +} + +impl TearDown { + fn working_dir(&self) -> PathBuf { + self.working_dir.path().to_path_buf() + } +} + +impl Drop for TearDown { + fn drop(&mut self) { + let working_dir = self.working_dir.path(); + if working_dir.is_dir() { + self.fs.remove_directory(working_dir).unwrap(); + } + } +} + // JsonConfigSource edits composer.json through JsonManipulator, whose text-rewriting // operations reach addcslashes (todo!()) in the php-shim. macro_rules! stub { @@ -7,6 +38,7 @@ macro_rules! stub { #[test] #[ignore = "JsonConfigSource uses JsonManipulator, which reaches addcslashes (todo!()) in the php-shim"] fn $name() { + let _tear_down = set_up(); todo!() } }; |
