History

change!: rename `scripted_fixture_*` to not contain 'repo' in the name. (#650)

Further make clear in the documentation that `bash` is used to execute the fixture scripts, previously it wasn't even implied and got lost in history.

Sebastian Thiel committed 3 years ago

Commit dbf6c8c1 parent 94750e11 file · +15 −15Browse files

Unified · Split

tests/tools/src/lib.rs+15−15
@@ -83,7 +83,7 @@ static EXCLUDE_LUT: Lazy<Mutex<Option<git_worktree::fs::Cache<'static>>>> = Lazy · 82 unmodified lines
8383 /// The major, minor and patch level of the git version on the system.
8484 pub static GIT_VERSION: Lazy<(u8, u8, u8)> = Lazy::new(|| parse_git_version().expect("git version to be parsable"));
8585
86−/// Define how [scripted_fixture_repo_writable_with_args()] uses produces the writable copy.
86+/// Define how [scripted_fixture_writable_with_args()] uses produces the writable copy.
8787 pub enum Creation {
8888 /// Run the script once and copy the data from its output to the writable location.
8989 /// This is fast but won't work if absolute paths are produced by the script.
@@ -205,7 +205,7 @@ pub fn fixture_bytes(path: impl AsRef<Path>) -> Vec<u8> { · 115 unmodified lines
205205 }
206206 }
207207
208−/// Run the executable at `script_name`, like `make_repo.sh` to produce a read-only directory to which
208+/// Run the script file `script_name` using `bash`, like `make_repo.sh` to produce a read-only directory to which
209209 /// the path is returned.
210210 ///
211211 /// Note that it persists and the script at `script_name` will only be executed once if it ran without error.
@@ -227,21 +227,21 @@ pub fn fixture_bytes(path: impl AsRef<Path>) -> Vec<u8> { · 15 unmodified lines
227227 /// or more specific `.gitignore` configurations in lower levels of the work tree.
228228 ///
229229 /// The latter is useful if the the script's output is platform specific.
230−pub fn scripted_fixture_repo_read_only(script_name: impl AsRef<Path>) -> Result<PathBuf> {
231− scripted_fixture_repo_read_only_with_args(script_name, None::<String>)
230+pub fn scripted_fixture_read_only(script_name: impl AsRef<Path>) -> Result<PathBuf> {
231+ scripted_fixture_read_only_with_args(script_name, None::<String>)
232232 }
233233
234234 /// Run the executable at `script_name`, like `make_repo.sh` to produce a writable directory to which
235235 /// the tempdir is returned. It will be removed automatically, courtesy of [`tempfile::TempDir`].
236236 ///
237237 /// Note that `script_name` is only executed once, so the data can be copied from its read-only location.
238−pub fn scripted_fixture_repo_writable(script_name: &str) -> Result<tempfile::TempDir> {
239− scripted_fixture_repo_writable_with_args(script_name, None::<String>, Creation::CopyFromReadOnly)
238+pub fn scripted_fixture_writable(script_name: &str) -> Result<tempfile::TempDir> {
239+ scripted_fixture_writable_with_args(script_name, None::<String>, Creation::CopyFromReadOnly)
240240 }
241241
242−/// Like [`scripted_fixture_repo_writable()`], but passes `args` to `script_name` while providing control over
242+/// Like [`scripted_fixture_writable()`], but passes `args` to `script_name` while providing control over
243243 /// the way files are created with `mode`.
244−pub fn scripted_fixture_repo_writable_with_args(
244+pub fn scripted_fixture_writable_with_args(
245245 script_name: &str,
246246 args: impl IntoIterator<Item = impl Into<String>>,
247247 mode: Creation,
@@ -249,12 +249,12 @@ pub fn scripted_fixture_repo_writable_with_args( · 1 unmodified line
249249 let dst = tempfile::TempDir::new()?;
250250 Ok(match mode {
251251 Creation::CopyFromReadOnly => {
252− let ro_dir = scripted_fixture_repo_read_only_with_args_inner(script_name, args, None)?;
252+ let ro_dir = scripted_fixture_read_only_with_args_inner(script_name, args, None)?;
253253 copy_recursively_into_existing_dir(&ro_dir, dst.path())?;
254254 dst
255255 }
256256 Creation::ExecuteScript => {
257− scripted_fixture_repo_read_only_with_args_inner(script_name, args, dst.path().into())?;
257+ scripted_fixture_read_only_with_args_inner(script_name, args, dst.path().into())?;
258258 dst
259259 }
260260 })
@@ -279,15 +279,15 @@ pub fn copy_recursively_into_existing_dir(src_dir: impl AsRef<Path>, dst_dir: im · 18 unmodified lines
279279 Ok(())
280280 }
281281
282−/// Like `scripted_fixture_repo_read_only()`], but passes `args` to `script_name`.
283−pub fn scripted_fixture_repo_read_only_with_args(
282+/// Like `scripted_fixture_read_only()`], but passes `args` to `script_name`.
283+pub fn scripted_fixture_read_only_with_args(
284284 script_name: impl AsRef<Path>,
285285 args: impl IntoIterator<Item = impl Into<String>>,
286286 ) -> Result<PathBuf> {
287− scripted_fixture_repo_read_only_with_args_inner(script_name, args, None)
287+ scripted_fixture_read_only_with_args_inner(script_name, args, None)
288288 }
289289
290−fn scripted_fixture_repo_read_only_with_args_inner(
290+fn scripted_fixture_read_only_with_args_inner(
291291 script_name: impl AsRef<Path>,
292292 args: impl IntoIterator<Item = impl Into<String>>,
293293 destination_dir: Option<&Path>,
@@ -397,7 +397,7 @@ fn scripted_fixture_repo_read_only_with_args_inner( · 103 unmodified lines
397397 }
398398 assert!(
399399 output.status.success(),
400− "repo script failed: stdout: {}\nstderr: {}",
400+ "fixture script failed: stdout: {}\nstderr: {}",
401401 output.stdout.as_bstr(),
402402 output.stderr.as_bstr()
403403 );