Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
Lynne Megido | a570b07672 | ||
Lynne Megido | 10c6512231 | ||
Lynne Megido | c048d21935 | ||
Lynne Megido | 4565487149 | ||
Lynne Megido | 5017854dd3 | ||
Lynne Megido | 4469104ac1 | ||
Lynne Megido | 7e03dd7cf7 | ||
Lynne Megido | 61196df626 | ||
Lynne Megido | 9e592863f1 | ||
Lynne Megido | 62a630249c | ||
Lynne Megido | 57fbbc23be |
|
@ -105,7 +105,7 @@ build-base-stable:
|
|||
|
||||
build-base-msrv:
|
||||
extends: build-base-stable
|
||||
image: "rust:1.57.0"
|
||||
image: "rust:1.64.0"
|
||||
cache:
|
||||
key: msrv
|
||||
paths:
|
||||
|
@ -131,7 +131,7 @@ build-stable:
|
|||
build-msrv:
|
||||
extends: build-stable
|
||||
needs: ["build-base-msrv"]
|
||||
image: "rust:1.57.0"
|
||||
image: "rust:1.64.0"
|
||||
cache:
|
||||
key: msrv
|
||||
paths:
|
||||
|
@ -156,7 +156,7 @@ test-stable:
|
|||
|
||||
test-msrv:
|
||||
extends: test-stable
|
||||
image: "rust:1.57.0"
|
||||
image: "rust:1.64.0"
|
||||
needs: ["build-msrv"]
|
||||
cache:
|
||||
key: msrv
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in library 'fif'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--lib",
|
||||
"--package=fif"
|
||||
],
|
||||
"filter": {
|
||||
"name": "fif",
|
||||
"kind": "lib"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug executable 'fif'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--bin=fif",
|
||||
"--package=fif"
|
||||
],
|
||||
"filter": {
|
||||
"name": "fif",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in executable 'fif'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--bin=fif",
|
||||
"--package=fif"
|
||||
],
|
||||
"filter": {
|
||||
"name": "fif",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
}
|
||||
]
|
||||
}
|
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -4,6 +4,17 @@ Dates are given in YYYY-MM-DD format - for example, the 15th of October 2021 is
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
|
||||
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## v0.7.1 - 2024-01-24
|
||||
### Changed
|
||||
- Updated and pinned dependencies, using the latest MSRV-compatible versions available.
|
||||
|
||||
## v0.7.0 - 2023-03-15
|
||||
### Changed
|
||||
- The Minimum Supported Rust Version (MSRV) is now **1.64.0**.
|
||||
- Update [`clap`] to v4.0
|
||||
- Update [`infer`] to v0.13.0, bringing support for formats such as [CPIO](https://en.wikipedia.org/wiki/Cpio) and
|
||||
[OpenRaster](https://www.openraster.org/index.html)
|
||||
|
||||
## v0.6.0 - 2022-09-04
|
||||
### Changed
|
||||
- The Minimum Supported Rust Version (MSRV) is now **1.57.0**.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
30
Cargo.toml
30
Cargo.toml
|
@ -1,11 +1,11 @@
|
|||
[package]
|
||||
name = "fif"
|
||||
description = "A command-line tool for detecting and optionally correcting files with incorrect extensions."
|
||||
version = "0.6.0"
|
||||
version = "0.7.1"
|
||||
authors = ["Lynnesbian <lynne@bune.city>"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
license = "GPL-3.0-or-later"
|
||||
rust-version = "1.57.0" # os_str_bytes requires >=1.57.0, numerous other deps require 2021 edition support
|
||||
rust-version = "1.64.0" # clap 4.1 requires >=1.64.0
|
||||
repository = "https://gitlab.com/Lynnesbian/fif"
|
||||
readme = "README.md"
|
||||
keywords = ["mime", "mimetype", "utilities", "tools"]
|
||||
|
@ -23,46 +23,46 @@ xdg-mime-backend = ["xdg-mime"]
|
|||
json = ["serde", "serde_json"]
|
||||
|
||||
[dependencies]
|
||||
walkdir = "~2.3.2"
|
||||
walkdir = "2.4.0"
|
||||
log = "0.4.14"
|
||||
mime = "0.3.16"
|
||||
mime_guess = { package = "new_mime_guess", features = ["phf-map"], version = "4.0.0" }
|
||||
mime_guess = { package = "new_mime_guess", version = "4.0.0" }
|
||||
snailquote = "0.3.0"
|
||||
once_cell = "1.8.0"
|
||||
rayon = { version = "1.5.0", optional = true }
|
||||
exitcode = "1.1.2"
|
||||
cfg-if = "1.0.0"
|
||||
itertools = "0.10.0"
|
||||
itertools = "0.12.0"
|
||||
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||
serde_json = { version = "1.0", optional = true }
|
||||
num_cpus = { version = "1.13.0", optional = true }
|
||||
maplit = "1.0.2"
|
||||
parking_lot = "0.12.0"
|
||||
smartstring = "1"
|
||||
maplit = "1.0.2"
|
||||
|
||||
[target.'cfg(not(unix))'.dependencies]
|
||||
xdg-mime = { version = "0.3.3", optional = true }
|
||||
infer = "0.9.0"
|
||||
infer = "=0.13.0" # 0.14.0 uses `let else`, which requires rust 1.65
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
xdg-mime = "0.3.3"
|
||||
infer = { version = "0.9.0", optional = true }
|
||||
infer = { version = "=0.13.0", optional = true }
|
||||
|
||||
[dependencies.clap]
|
||||
version = "3.2"
|
||||
version = "~4.1"
|
||||
default-features = false
|
||||
features = ["wrap_help", "color", "derive", "std", "unicode"]
|
||||
|
||||
[dependencies.env_logger]
|
||||
version = "0.9.0"
|
||||
version = "0.10.0"
|
||||
default-features = false
|
||||
features = ["termcolor", "atty"]
|
||||
features = ["color"]
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.2.0"
|
||||
rand = "0.8.3"
|
||||
assert_cmd = "2.0.2"
|
||||
regex = { version = "1.5.4", default-features = false, features = ["std"] }
|
||||
assert_cmd = "=2.0.5" # higher versions than this have dependencies that require later rust versions
|
||||
regex = { version = "=1.9.5", default-features = false, features = ["std"] } # 1.9.6 requires rust 1.65
|
||||
|
||||
[profile.release]
|
||||
lto = "thin"
|
||||
|
@ -75,4 +75,4 @@ opt-level = 3
|
|||
opt-level = 3
|
||||
|
||||
[package.metadata]
|
||||
msrv = "1.57.0"
|
||||
msrv = "1.64.0"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# avoid-breaking-exported-api = false # only available on nightly for now
|
||||
cognitive-complexity-threshold = 15
|
||||
msrv = "1.57.0"
|
||||
msrv = "1.64.0"
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 130 B |
|
@ -317,7 +317,7 @@ pub fn mime_type<T: MimeDb>(db: &T, path: &Path) -> io::Result<Option<Mime>> {
|
|||
// attempt to read up to BUF_SIZE bytes of the file.
|
||||
let mut buffer = [0; BUF_SIZE];
|
||||
file.seek(SeekFrom::Start(0))?;
|
||||
file.read(&mut buffer)?;
|
||||
_ = file.read(&mut buffer)?;
|
||||
Ok(db.get_type(&buffer))
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ use crate::String;
|
|||
/// // ...just use:
|
||||
/// smart_write(&mut f, writables!["hello", Newline]);
|
||||
/// ```
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! writables {
|
||||
[$($args:tt),+] => {
|
||||
|
@ -90,7 +89,7 @@ pub fn smart_write<W: Write>(f: &mut W, writeables: &[Writable]) -> io::Result<(
|
|||
}
|
||||
}
|
||||
}
|
||||
Writable::String(s) => write!(f, "{}", s)?,
|
||||
Writable::String(s) => write!(f, "{s}")?,
|
||||
Writable::Path(path) => {
|
||||
if let Some(path_str) = path.to_str() {
|
||||
let escaped = escape(path_str);
|
||||
|
@ -98,9 +97,9 @@ pub fn smart_write<W: Write>(f: &mut W, writeables: &[Writable]) -> io::Result<(
|
|||
// the escaped string is the same as the input - this will occur for inputs like "file.txt" which don't
|
||||
// need to be escaped. however, it's Best Practice™ to escape such strings anyway, so we prefix/suffix the
|
||||
// escaped string with single quotes.
|
||||
write!(f, "'{}'", escaped)?;
|
||||
write!(f, "'{escaped}'")?;
|
||||
} else {
|
||||
write!(f, "{}", escaped)?;
|
||||
write!(f, "{escaped}")?;
|
||||
}
|
||||
} else {
|
||||
write!(f, "'")?;
|
||||
|
|
|
@ -132,7 +132,7 @@ fn main() {
|
|||
if args.fix {
|
||||
fn ask(message: &str) -> bool {
|
||||
let mut buf = String::with_capacity(1);
|
||||
print!("{} [y/N] ", message);
|
||||
print!("{message} [y/N] ");
|
||||
|
||||
// flush stdout to ensure message is displayed
|
||||
stdout().flush().expect("Failed to flush stdout");
|
||||
|
@ -166,7 +166,7 @@ fn main() {
|
|||
} else if prompt == Prompt::Error || ask(&format!("Rename {:#?} to {:#?}?", &f.file, &rename_to)) {
|
||||
// handles: --prompt error --overwrite, --prompt always --overwrite [y]
|
||||
// if the target exists, prompt before renaming; otherwise, just rename
|
||||
!rename_to.exists() || ask(&format!("Destination {:#?} already exists, overwrite?", rename_to))
|
||||
!rename_to.exists() || ask(&format!("Destination {rename_to:#?} already exists, overwrite?"))
|
||||
} else {
|
||||
// handles: --prompt always --overwrite [n]
|
||||
// user was prompted and replied "no"
|
||||
|
@ -182,7 +182,7 @@ fn main() {
|
|||
loop {
|
||||
// until file is renamed successfully
|
||||
match std::fs::rename(&f.file, &rename_to) {
|
||||
Ok(_) => {
|
||||
Ok(()) => {
|
||||
info!("Renamed {:#?} -> {:#?}", f.file, rename_to);
|
||||
renamed += 1;
|
||||
break;
|
||||
|
@ -191,7 +191,7 @@ fn main() {
|
|||
warn!("Couldn't rename {:#?} to {:#?}: {:#?}", f.file, rename_to, e);
|
||||
// if the user passed --prompt never, continue to the next file
|
||||
// otherwise, prompt user to retry move, retrying until the rename succeeds or they respond "N"
|
||||
if prompt == Prompt::Never || !ask(&format!("Error while renaming file: {:#?}. Try again?", e)) {
|
||||
if prompt == Prompt::Never || !ask(&format!("Error while renaming file: {e:#?}. Try again?")) {
|
||||
failed += 1;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ cfg_if! {
|
|||
}
|
||||
|
||||
fn open_document_check(buf: &[u8], kind: &str) -> bool {
|
||||
let mime = format!("application/vnd.oasis.opendocument.{}", kind);
|
||||
let mime = format!("application/vnd.oasis.opendocument.{kind}");
|
||||
let mime = mime.as_bytes();
|
||||
|
||||
buf.len() > 38 + mime.len() && buf.starts_with(b"PK\x03\x04") && buf[38..mime.len() + 38] == mime[..]
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::collections::BTreeSet;
|
|||
use std::path::PathBuf;
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
use clap::{ArgEnum, Parser};
|
||||
use clap::{ArgAction, Parser, ValueEnum};
|
||||
|
||||
use crate::utils::{CLAP_LONG_VERSION, CLAP_VERSION};
|
||||
use crate::String as StringType;
|
||||
|
@ -22,7 +22,7 @@ cfg_if! {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(ArgEnum, Eq, PartialEq, Debug, Copy, Clone)]
|
||||
#[derive(ValueEnum, Eq, PartialEq, Debug, Copy, Clone)]
|
||||
/// The format to use when running fif without the `--fix` flag. Specified at runtime with the `-o`/`--output-format`
|
||||
/// flag.
|
||||
pub enum OutputFormat {
|
||||
|
@ -39,7 +39,7 @@ pub enum OutputFormat {
|
|||
Json,
|
||||
}
|
||||
|
||||
#[derive(ArgEnum, Eq, PartialEq, Debug, Copy, Clone)]
|
||||
#[derive(ValueEnum, Eq, PartialEq, Debug, Copy, Clone)]
|
||||
/// Specifies under what conditions the user should be prompted when running fif in `--fix` mode. Defaults to `Error`.
|
||||
/// Specified at runtime with the `-p`/`--prompt` flag.
|
||||
pub enum Prompt {
|
||||
|
@ -63,8 +63,7 @@ pub enum Prompt {
|
|||
This program is free software: you can redistribute it and/or modify \
|
||||
it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 \
|
||||
of the License, or (at your option) any later version.",
|
||||
max_term_width = 120,
|
||||
setting(clap::AppSettings::DeriveDisplayOrder)
|
||||
max_term_width = 120
|
||||
)]
|
||||
/// [`Clap`]-derived struct used to parse command line arguments.
|
||||
pub struct Parameters {
|
||||
|
@ -73,7 +72,7 @@ pub struct Parameters {
|
|||
pub fix: bool,
|
||||
|
||||
/// Requires --fix. Should fif prompt you `Never`, only on `Error`s and overwrites, or `Always`?
|
||||
#[clap(short = 'p', long, arg_enum, requires = "fix", help_heading = "RENAMING")]
|
||||
#[clap(short = 'p', long, value_enum, requires = "fix", help_heading = "RENAMING")]
|
||||
pub prompt: Option<Prompt>,
|
||||
|
||||
/// Requires --fix. Allow overwriting files. Warning: When used in combination with `--prompt never`, fif will
|
||||
|
@ -86,8 +85,8 @@ pub struct Parameters {
|
|||
/// Only examine files with these extensions.
|
||||
/// Multiple extensions can be specified by either using the flag multiple times (`-e jpg -e png -e gif`), or by
|
||||
/// separating them with commas (`-e jpg,png,gif`).
|
||||
#[clap(short, long, use_value_delimiter = true, require_value_delimiter = true, value_name = "ext", takes_value = true,
|
||||
validator = validate_exts, help_heading = "FILTERING")]
|
||||
#[clap(short, long, use_value_delimiter = true, value_delimiter = ',', value_name = "ext", num_args(1),
|
||||
value_parser = validate_exts, help_heading = "FILTERING")]
|
||||
pub exts: Option<Vec<StringType>>,
|
||||
|
||||
/// Use these preset lists of extensions as the search filter (comma-separated list).
|
||||
|
@ -96,9 +95,9 @@ pub struct Parameters {
|
|||
#[clap(
|
||||
short = 'E',
|
||||
long,
|
||||
arg_enum,
|
||||
value_enum,
|
||||
use_value_delimiter = true,
|
||||
require_value_delimiter = true,
|
||||
value_delimiter = ',',
|
||||
value_name = "set",
|
||||
help_heading = "FILTERING"
|
||||
)]
|
||||
|
@ -106,7 +105,7 @@ pub struct Parameters {
|
|||
|
||||
/// Don't scan files with these extensions.
|
||||
/// This option takes precedence over extensions specified with `-e` or `-E`.
|
||||
#[clap(short = 'x', long, use_value_delimiter = true, require_value_delimiter = true, value_name = "ext", validator =
|
||||
#[clap(short = 'x', long, use_value_delimiter = true, value_delimiter = ',', value_name = "ext", value_parser =
|
||||
validate_exts, help_heading = "FILTERING")]
|
||||
pub exclude: Option<Vec<StringType>>,
|
||||
|
||||
|
@ -115,9 +114,9 @@ pub struct Parameters {
|
|||
#[clap(
|
||||
short = 'X',
|
||||
long,
|
||||
arg_enum,
|
||||
value_enum,
|
||||
use_value_delimiter = true,
|
||||
require_value_delimiter = true,
|
||||
value_delimiter = ',',
|
||||
value_name = "set",
|
||||
help_heading = "FILTERING"
|
||||
)]
|
||||
|
@ -146,17 +145,17 @@ pub struct Parameters {
|
|||
|
||||
/// Output format to use.
|
||||
/// By default, fif will output a PowerShell script on Windows, and a Bourne Shell script on other platforms.
|
||||
#[clap(short, long, default_value = DEFAULT_FORMAT, arg_enum, value_name = "format", help_heading = "OUTPUT")]
|
||||
#[clap(short, long, default_value = DEFAULT_FORMAT, value_enum, value_name = "format", help_heading = "OUTPUT")]
|
||||
pub output_format: OutputFormat,
|
||||
|
||||
/// Output verbosity. Each additional `-v` increases verbosity.
|
||||
/// Can be overridden by FIF_LOG or RUST_LOG.
|
||||
#[clap(short, long, parse(from_occurrences), group = "verbosity", help_heading = "OUTPUT")]
|
||||
#[clap(short, long, action = ArgAction::Count, group = "verbosity", help_heading = "OUTPUT")]
|
||||
pub verbose: u8,
|
||||
|
||||
/// Output quietness. Each additional `-q` decreases verbosity.
|
||||
/// Can be overridden by FIF_LOG or RUST_LOG.
|
||||
#[clap(short, long, parse(from_occurrences), group = "verbosity", help_heading = "OUTPUT")]
|
||||
#[clap(short, long, action = ArgAction::Count, group = "verbosity", help_heading = "OUTPUT")]
|
||||
pub quiet: u8,
|
||||
|
||||
/// Use canonical (absolute) paths in output.
|
||||
|
@ -167,7 +166,7 @@ pub struct Parameters {
|
|||
pub canonical_paths: bool,
|
||||
|
||||
/// The directory to process.
|
||||
#[clap(name = "DIR", default_value = ".", parse(from_os_str))]
|
||||
#[clap(name = "DIR", default_value = ".", value_parser)]
|
||||
pub dir: PathBuf,
|
||||
|
||||
#[cfg(feature = "multi-threaded")]
|
||||
|
@ -181,7 +180,7 @@ pub struct Parameters {
|
|||
|
||||
/// Validation function for argument parsing that ensures passed-in extensions are lowercase, and that the user
|
||||
/// didn't supply an empty list.
|
||||
fn validate_exts(exts: &str) -> Result<(), String> {
|
||||
fn validate_exts(exts: &str) -> Result<StringType, String> {
|
||||
// TODO: i would much rather accept uppercase exts and convert them to lowercase than just rejecting lowercase exts...
|
||||
|
||||
if exts.is_empty() {
|
||||
|
@ -191,7 +190,7 @@ fn validate_exts(exts: &str) -> Result<(), String> {
|
|||
if exts.to_lowercase() != exts {
|
||||
return Err(String::from("Supplied extensions must be lowercase"));
|
||||
}
|
||||
Ok(())
|
||||
Ok(exts.into())
|
||||
}
|
||||
|
||||
/// Further options relating to scanning.
|
||||
|
@ -298,7 +297,7 @@ impl Parameters {
|
|||
}
|
||||
|
||||
/// Sets of extensions for use with [Parameter](crate::parameters::Parameters)'s `-E` flag.
|
||||
#[derive(ArgEnum, Eq, PartialEq, Debug, Copy, Clone)]
|
||||
#[derive(ValueEnum, Eq, PartialEq, Debug, Copy, Clone)]
|
||||
pub enum ExtensionSet {
|
||||
/// Extensions used for image file formats, such as `png`, `jpeg`, `webp`, etc.
|
||||
Images,
|
||||
|
|
|
@ -102,12 +102,11 @@ fn simple_directory() {
|
|||
set_current_dir(dir.path()).expect("Failed to change directory.");
|
||||
|
||||
for (name, bytes) in &files {
|
||||
let mut file = File::create(dir.path().join(name))
|
||||
.unwrap_or_else(|_| panic!("Failed to create file: {}", name));
|
||||
let mut file = File::create(dir.path().join(name)).unwrap_or_else(|_| panic!("Failed to create file: {name}"));
|
||||
|
||||
file
|
||||
.write_all(bytes)
|
||||
.unwrap_or_else(|_| panic!("Failed to write to file: {}", name));
|
||||
.unwrap_or_else(|_| panic!("Failed to write to file: {name}"));
|
||||
drop(file);
|
||||
}
|
||||
|
||||
|
@ -280,12 +279,12 @@ fn exclude_set_overrides_include_set() {
|
|||
.iter()
|
||||
.chain(ExtensionSet::Video.extensions().iter())
|
||||
{
|
||||
assert!(extensions.contains(&ext), "Extensions should contain {}!", ext);
|
||||
assert!(extensions.contains(&ext), "Extensions should contain {ext}!");
|
||||
}
|
||||
|
||||
// ensure all of images' extensions are excluded
|
||||
for ext in ExtensionSet::Images.extensions() {
|
||||
assert!(!extensions.contains(&ext), "Extensions should not contain {}!", ext);
|
||||
assert!(!extensions.contains(&ext), "Extensions should not contain {ext}!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,7 +315,7 @@ fn rejects_bad_args() {
|
|||
|
||||
for test in &tests {
|
||||
// first, try testing the flags against the Parameters struct...
|
||||
assert!(Parameters::try_parse_from(test).is_err(), "Failed to reject {:?}", test);
|
||||
assert!(Parameters::try_parse_from(test).is_err(), "Failed to reject {test:?}");
|
||||
// ...then, make sure it actually works against the binary
|
||||
let mut cmd = Command::cargo_bin("fif").unwrap();
|
||||
cmd.args(test).assert().failure();
|
||||
|
@ -358,9 +357,8 @@ fn check_version_output() {
|
|||
let output = cmd.arg("-V").ok().unwrap().stdout;
|
||||
let output = String::from_utf8(output).unwrap();
|
||||
assert!(
|
||||
Regex::new(r#"fif v([0-9]\.){2}[0-9]"#).unwrap().is_match(output.trim()),
|
||||
"\"{}\" does not match the expected `-v` format!",
|
||||
output
|
||||
Regex::new(r"fif v([0-9]\.){2}[0-9]").unwrap().is_match(output.trim()),
|
||||
"\"{output}\" does not match the expected `-v` format!"
|
||||
);
|
||||
|
||||
// test `--version` matches the format of "fif x.y.z (OS, example backend, commit #1234abc)"
|
||||
|
@ -368,7 +366,7 @@ fn check_version_output() {
|
|||
let output = cmd.arg("--version").ok().unwrap().stdout;
|
||||
let output = String::from_utf8(output).unwrap();
|
||||
assert!(
|
||||
Regex::new(r#"fif v([0-9]\.){2}[0-9] \(.+, .+ backend, (unknown commit|commit #[[:xdigit:]]{7})\)"#)
|
||||
Regex::new(r"fif v([0-9]\.){2}[0-9] \(.+, .+ backend, (unknown commit|commit #[[:xdigit:]]{7})\)")
|
||||
.unwrap()
|
||||
.is_match(output.trim()),
|
||||
"\"{}\" does not match the expected `--version` format!",
|
||||
|
@ -393,7 +391,7 @@ fn identify_random_bytes() {
|
|||
}
|
||||
|
||||
for (mime, count) in &results {
|
||||
println!("{}:\t{} counts", mime, count);
|
||||
println!("{mime}:\t{count} counts");
|
||||
}
|
||||
println!("No type found:\t{} counts", 1000 - results.values().sum::<i32>());
|
||||
}
|
||||
|
@ -430,9 +428,7 @@ fn outputs_move_commands() {
|
|||
// the output should contain a command like "mv -i misnamed_file.png misnamed_file.jpg"
|
||||
assert!(
|
||||
contents.contains("misnamed_file.jpg") && contents.contains("misnamed_file.png"),
|
||||
"{} output doesn't contain move command!\n===\n{}",
|
||||
format,
|
||||
contents
|
||||
"{format} output doesn't contain move command!\n===\n{contents}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -466,8 +462,7 @@ fn test_json() {
|
|||
// the output should contain the file's MIME type
|
||||
assert!(
|
||||
contents.contains(IMAGE_JPEG.essence_str()),
|
||||
"JSON output doesn't contain move command!\n===\n{}",
|
||||
contents
|
||||
"JSON output doesn't contain move command!\n===\n{contents}"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue