Creates test files and directories below `path`.
(path: impl AsRef<Path>)
| 129 | |
| 130 | /// Creates test files and directories below `path`. |
| 131 | fn create_data_files(path: impl AsRef<Path>) -> TestResult { |
| 132 | let path = path.as_ref(); |
| 133 | // Create dummy directory structure |
| 134 | create_dir_all(path.join("foo/bar/baz"))?; |
| 135 | create_dir_all(path.join("foo/bar/buh"))?; |
| 136 | |
| 137 | // Create dummy text file |
| 138 | let mut file = File::create(path.join("foo/beh.txt"))?; |
| 139 | write!(file, "test")?; |
| 140 | file.set_times(default_filetimes())?; |
| 141 | |
| 142 | // Create relative symlink to actual text file |
| 143 | let existing_target_link = path.join("foo/bar/baz/beh.txt"); |
| 144 | symlink("../../beh.txt", &existing_target_link)?; |
| 145 | set_symlink_file_times( |
| 146 | &existing_target_link, |
| 147 | default_filetime(), |
| 148 | default_filetime(), |
| 149 | )?; |
| 150 | |
| 151 | // Create symlink to absolute, non-existing file. |
| 152 | let non_existing_target_link = path.join("foo/bar/baz/buh.txt"); |
| 153 | symlink( |
| 154 | "/tmp/something/very/unlikely/to/ever/exist/hopefully.txt", |
| 155 | &non_existing_target_link, |
| 156 | )?; |
| 157 | set_symlink_file_times( |
| 158 | &non_existing_target_link, |
| 159 | default_filetime(), |
| 160 | default_filetime(), |
| 161 | )?; |
| 162 | |
| 163 | // Adjust file times of directory structure. |
| 164 | for path in [ |
| 165 | path.join("foo/bar/baz"), |
| 166 | path.join("foo/bar/buh"), |
| 167 | path.join("foo/bar"), |
| 168 | path.join("foo"), |
| 169 | ] { |
| 170 | let file = File::open(path)?; |
| 171 | file.set_times(default_filetimes())?; |
| 172 | } |
| 173 | |
| 174 | Ok(()) |
| 175 | } |
| 176 | |
| 177 | /// Creates ALPM package metadata files in `path`. |
| 178 | fn create_build_info_file(path: impl AsRef<Path>) -> TestResult { |
no test coverage detected