From a4144c9fb39c7a3cc1c15a8caec68b32de938ce7 Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Thu, 6 Feb 2025 04:12:21 +0100 Subject: Make symlinks into global fixtures So far, tests had to create their own symlinks which made them less concise. Also, now that we always have symlinks in all tests, side effects of having them won't go undetected. --- tests/fixtures/mod.rs | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'tests/fixtures/mod.rs') diff --git a/tests/fixtures/mod.rs b/tests/fixtures/mod.rs index f5231f7..a96a5b7 100644 --- a/tests/fixtures/mod.rs +++ b/tests/fixtures/mod.rs @@ -1,12 +1,13 @@ +use std::process::{Child, Command, Stdio}; +use std::thread::sleep; +use std::time::{Duration, Instant}; + use assert_cmd::prelude::*; use assert_fs::fixture::TempDir; use assert_fs::prelude::*; use port_check::free_local_port; use reqwest::Url; use rstest::fixture; -use std::process::{Child, Command, Stdio}; -use std::thread::sleep; -use std::time::{Duration, Instant}; /// Error type used by tests pub type Error = Box; @@ -41,6 +42,15 @@ pub static HIDDEN_DIRECTORIES: &[&str] = &[".hidden_dir1/", ".hidden_dir2/"]; /// Name of a deeply nested file pub static DEEPLY_NESTED_FILE: &str = "very/deeply/nested/test.rs"; +/// Name of a symlink pointing to a directory +pub static DIRECTORY_SYMLINK: &str = "dir_symlink/"; + +/// Name of a symlink pointing to a file +pub static FILE_SYMLINK: &str = "file_symlink"; + +/// Name of a symlink pointing to a path that doesn't exist +pub static BROKEN_SYMLINK: &str = "broken_symlink"; + /// Test fixture which creates a temporary directory with a few files and directories inside. /// The directories also contain files. #[fixture] @@ -70,6 +80,22 @@ pub fn tmpdir() -> TempDir { .child(DEEPLY_NESTED_FILE) .write_str("File in a deeply nested directory.") .expect("Couldn't write to file"); + + tmpdir + .child(DIRECTORY_SYMLINK.strip_suffix("/").unwrap()) + .symlink_to_dir(DIRECTORIES[0]) + .expect("Couldn't create symlink to dir"); + + tmpdir + .child(FILE_SYMLINK) + .symlink_to_file(FILES[0]) + .expect("Couldn't create symlink to file"); + + tmpdir + .child(BROKEN_SYMLINK) + .symlink_to_file("broken_symlink") + .expect("Couldn't create broken symlink"); + tmpdir } -- cgit v1.2.3