chore: move rustic_testing into rustic_core

Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>
This commit is contained in:
simonsan 2024-02-04 23:00:11 +01:00
parent 714629950f
commit e4cd0d7bb9
No known key found for this signature in database
GPG Key ID: E11D13668EC3B71B
7 changed files with 156 additions and 307 deletions

92
Cargo.lock generated
View File

@ -1027,18 +1027,6 @@ dependencies = [
"const-random",
]
[[package]]
name = "duct"
version = "0.13.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4ab5718d1224b63252cd0c6f74f6480f9ffeb117438a2e0f5cf6d9a4798929c"
dependencies = [
"libc",
"once_cell",
"os_pipe",
"shared_child",
]
[[package]]
name = "dunce"
version = "1.0.4"
@ -1111,6 +1099,16 @@ dependencies = [
"syn 2.0.48",
]
[[package]]
name = "env_logger"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
dependencies = [
"log",
"regex",
]
[[package]]
name = "equivalent"
version = "1.0.1"
@ -1549,9 +1547,9 @@ dependencies = [
[[package]]
name = "iana-time-zone"
version = "0.1.59"
version = "0.1.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539"
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
dependencies = [
"android_system_properties",
"core-foundation-sys",
@ -1893,9 +1891,9 @@ dependencies = [
[[package]]
name = "miniz_oxide"
version = "0.7.1"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7"
dependencies = [
"adler",
]
@ -2219,16 +2217,6 @@ dependencies = [
"hashbrown 0.14.3",
]
[[package]]
name = "os_pipe"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57119c3b893986491ec9aa85056780d3a0f3cf4da7cc09dd3650dbd6c6738fb9"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "overload"
version = "0.1.1"
@ -2497,6 +2485,28 @@ dependencies = [
"parking_lot",
]
[[package]]
name = "quickcheck"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
dependencies = [
"env_logger",
"log",
"rand",
]
[[package]]
name = "quickcheck_macros"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b22a693222d716a9587786f37ac3f6b4faedb5b80c23914e7303ff5a1d8016e9"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "quote"
version = "1.0.35"
@ -2843,6 +2853,7 @@ dependencies = [
"dialoguer",
"dircmp",
"directories",
"displaydoc",
"gethostname",
"humantime",
"indicatif",
@ -2854,6 +2865,8 @@ dependencies = [
"mimalloc",
"once_cell",
"pretty_assertions",
"quickcheck",
"quickcheck_macros",
"rhai",
"rstest",
"rustic_backend",
@ -2965,6 +2978,7 @@ dependencies = [
[[package]]
name = "rustic_testing"
version = "0.1.0"
source = "git+https://github.com/rustic-rs/rustic_core.git#a2ea02ba5345b4137254a188efbfb51fe084d9cc"
dependencies = [
"aho-corasick",
"once_cell",
@ -3308,16 +3322,6 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "shared_child"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0d94659ad3c2137fef23ae75b03d5241d633f8acded53d672decfa0e6e0caef"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "shell-escape"
version = "0.1.5"
@ -3664,9 +3668,9 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.33"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b24b79b7a07f10209f19e683ca1e289d80b1e76ffa8c2b779718566a083679"
checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749"
dependencies = [
"deranged",
"itoa",
@ -4475,18 +4479,6 @@ dependencies = [
"xml-rs",
]
[[package]]
name = "xtask"
version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"dialoguer",
"duct",
"fs_extra",
"glob",
]
[[package]]
name = "yansi"
version = "0.5.1"

View File

@ -1,35 +1,22 @@
[workspace.package]
[package]
name = "rustic-rs"
version = "0.7.0"
edition = "2021"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/rustic-rs/rustic"
homepage = "https://rustic.cli.rs/"
keywords = ["backup", "restic", "deduplication", "encryption", "cli"]
authors = ["the rustic-rs team"]
categories = ["command-line-utilities"]
documentation = "https://docs.rs/rustic-rs"
edition = "2021"
homepage = "https://rustic.cli.rs/"
include = ["src/**/*", "LICENSE-*", "README.md", "config/**/*"]
keywords = ["backup", "restic", "deduplication", "encryption", "cli"]
license = "Apache-2.0 OR MIT"
readme = "README.md"
repository = "https://github.com/rustic-rs/rustic"
resolver = "2"
rust-version = "1.70.0"
description = """
rustic - fast, encrypted, deduplicated backups powered by Rust
"""
[package]
name = "rustic-rs"
version = { workspace = true }
authors = ["the rustic-rs team"]
categories = { workspace = true }
documentation = "https://docs.rs/rustic-rs"
edition = { workspace = true }
homepage = { workspace = true }
include = ["src/**/*", "LICENSE-*", "README.md", "config/**/*"]
keywords = { workspace = true }
license = { workspace = true }
readme = "README.md"
repository = { workspace = true }
resolver = "2"
rust-version = "1.70.0"
description = { workspace = true }
[workspace]
members = ["crates/rustic_testing", "xtask"]
[features]
default = ["self-update", "webdav"]
mimalloc = ["dep:mimalloc"]
@ -52,111 +39,69 @@ all-features = true
rustdoc-args = ["--document-private-items", "--generate-link-to-definition"]
[dependencies]
abscissa_core = { workspace = true }
rustic_backend = { workspace = true }
rustic_core = { workspace = true }
# errors
anyhow = { workspace = true }
thiserror = { workspace = true }
# logging
log = { workspace = true }
# serialization
serde = { workspace = true }
serde_json = { workspace = true }
serde_with = { workspace = true }
# other dependencies
chrono = { workspace = true }
self_update = { workspace = true, optional = true }
semver = { workspace = true, optional = true }
# commands
clap = { workspace = true }
clap_complete = { workspace = true }
merge = { workspace = true }
bytesize = { workspace = true }
comfy-table = { workspace = true }
dav-server = { version = "0.5.8", default-features = false, features = ["warp-compat"], optional = true }
dialoguer = { workspace = true }
directories = { workspace = true }
gethostname = { workspace = true }
humantime = { workspace = true }
indicatif = { workspace = true }
itertools = { workspace = true }
jemallocator-global = { version = "0.3.2", optional = true }
mimalloc = { version = "0.1.39", default-features = false, optional = true }
rhai = { workspace = true }
simplelog = { workspace = true }
tokio = { version = "1", optional = true }
warp = { version = "0.3.6", optional = true }
[dev-dependencies]
abscissa_core = { workspace = true, features = ["testing"] }
aho-corasick = { workspace = true }
dircmp = { workspace = true }
once_cell = { workspace = true }
pretty_assertions = { workspace = true }
rstest.workspace = true
rustic_testing = { path = "crates/rustic_testing" }
tempfile = { workspace = true }
toml = { workspace = true }
[target.'cfg(not(windows))'.dependencies]
libc = "0.2.153"
[workspace.dependencies]
abscissa_core = { version = "0.7.0", default-features = false, features = ["application"] }
rustic_backend = { version = "0.1", features = ["cli"] }
rustic_core = { version = "0.2", features = ["cli"] }
# allocators
jemallocator-global = { version = "0.3.2", optional = true }
mimalloc = { version = "0.1.39", default-features = false, optional = true }
# webdav
dav-server = { version = "0.5.8", default-features = false, features = ["warp-compat"], optional = true }
tokio = { version = "1", optional = true }
warp = { version = "0.3.6", optional = true }
# logging
log = "0.4"
# errors
anyhow = "1"
displaydoc = "0.2.4"
thiserror = "1"
anyhow = "1"
# serialization
serde = { version = "1", features = ["serde_derive"] }
serde_with = { version = "3.6", features = ["base64"] }
serde_json = "1"
serde_with = { version = "3.6", features = ["base64"] }
# other dependencies
aho-corasick = "1.1.2"
chrono = { version = "0.4", default-features = false, features = ["clock", "serde"] }
rhai = { version = "1.17", features = ["sync", "serde", "no_optimize", "no_module", "no_custom_syntax", "only_i64"] }
semver = "1"
simplelog = "0.12"
comfy-table = "7.1.0"
rhai = { version = "1.17", features = ["sync", "serde", "no_optimize", "no_module", "no_custom_syntax", "only_i64"] }
semver = { version = "1", optional = true }
simplelog = "0.12"
# commands
merge = "0.1"
directories = "5"
dialoguer = "0.11.0"
indicatif = "0.17"
gethostname = "0.4"
bytesize = "1"
itertools = "0.12"
humantime = "2"
clap_complete = "4"
clap = { version = "4", features = ["derive", "env", "wrap_help"] }
clap_complete = "4"
dialoguer = "0.11.0"
directories = "5"
gethostname = "0.4"
humantime = "2"
indicatif = "0.17"
itertools = "0.12"
merge = "0.1"
once_cell = "1.19"
self_update = { version = "0.39", default-features = false, features = ["rustls", "archive-tar", "compression-flate2"] }
self_update = { version = "0.39", default-features = false, optional = true, features = ["rustls", "archive-tar", "compression-flate2"] }
# dev dependencies
rstest = "0.18"
[dev-dependencies]
abscissa_core = { version = "0.7.0", default-features = false, features = ["testing"] }
dircmp = "0.2"
pretty_assertions = "1.4"
quickcheck = "1"
quickcheck_macros = "1"
rstest = "0.18"
rustic_testing = { git = "https://github.com/rustic-rs/rustic_core.git" }
tempfile = "3.9"
pretty_assertions = "1.4"
toml = "0.8"
dircmp = "0.2"
[target.'cfg(not(windows))'.dependencies]
libc = "0.2.153"
[workspace.dependencies]
# cargo-binstall support
# https://github.com/cargo-bins/cargo-binstall/blob/HEAD/SUPPORT.md
[package.metadata.binstall]

66
ECOSYSTEM.md Normal file
View File

@ -0,0 +1,66 @@
# Ecosystem
## Crates
### rustic_backend - [Link](https://crates.io/crates/rustic_backend)
A library for supporting various backends in `rustic` and `rustic_core`.
### rustic_core - [Link](https://crates.io/crates/rustic_core)
Core functionality for the `rustic` ecosystem. Can be found
[here](https://github.com/rustic-rs/rustic_core).
### rustic_scheduler - [Link](https://crates.io/crates/rustic_scheduler)
Scheduling functionality for the `rustic` ecosystem.
### rustic_server - [Link](https://crates.io/crates/rustic_server)
A possible server implementation for `rustic` to support multiple clients when
backing up.
### rustic_testing (not published) - [Link](https://github.com/rustic-rs/rustic_core/tree/main/crates/testing)
Testing functionality for the `rustic` ecosystem.
<!-- ### rustic_bench (reserved) - [Link](https://crates.io/crates/rustic_bench)
Benchmarking functionality for the `rustic` ecosystem. -->
<!-- ### rustic_auth (reserved) - [Link](https://crates.io/crates/rustic_auth)
Authentication functionality for the `rustic` ecosystem. -->
<!-- ### rustic_ui (reserved) - [Link](https://crates.io/crates/rustic_ui)
General UI functionality for the `rustic` ecosystem. -->
<!-- ### rustic_gui (reserved) - [Link](https://crates.io/crates/rustic_gui)
Graphical UI for `rustic`. -->
<!-- ### rustic_tui (reserved) - [Link](https://crates.io/crates/rustic_tui)
Terminal UI for `rustic`. -->
<!-- ### rustic_cli (reserved) - [Link](https://crates.io/crates/rustic_cli)
Common used CLI functionality for the `rustic` ecosystem. -->
<!-- ### rustic_web (reserved) - [Link](https://crates.io/crates/rustic_web)
Possible WASM/WASI functionality for the `rustic` ecosystem. -->
<!-- ### rustic_store (reserved) - [Link](https://crates.io/crates/rustic_store)
Possible store functionality to support a plugin system for the `rustic`
ecosystem. -->
<!-- ### rustic_plugins (reserved) - [Link](https://crates.io/crates/rustic_plugins)
Plugin functionality for the `rustic` ecosystem. -->
<!-- ### rustic_daemon (reserved) - [Link](https://crates.io/crates/rustic_daemon)
A daemon for `rustic` and running it as a service. -->

View File

@ -35,8 +35,8 @@ The `rustic` project is split into multiple crates:
- [rustic](https://crates.io/crates/rustic-rs) - the main binary
- [rustic-core](https://crates.io/crates/rustic_core) - the core library
<!-- - [rustic-testing](https://crates.io/crates/rustic_testing) - testing utilities -->
- [rustic-backend](https://crates.io/crates/rustic_backend) - the library for
supporting various backends
## Features

View File

@ -1,73 +0,0 @@
# Ecosystem
**Note**: This is a work in progress. The crates are not yet published. The
descriptions will be updated as soon as the crates are published. We needed to
reserve some crates, because we discovered that another project recently chose
the same name as `rustic`.
## Crates
### rustic_core - [Link](https://crates.io/crates/rustic_core)
Core functionality for the `rustic` ecosystem. Can be found
[here](https://github.com/rustic-rs/rustic_core).
### rustic_testing (reserved) - [Link](https://crates.io/crates/rustic_testing)
Testing functionality for the `rustic` ecosystem. Can be found in
[crates/rustic_testing](./rustic_testing/).
### rustic_ui (reserved) - [Link](https://crates.io/crates/rustic_ui)
General UI functionality for the `rustic` ecosystem.
### rustic_gui (reserved) - [Link](https://crates.io/crates/rustic_gui)
Graphical UI for `rustic`.
### rustic_tui (reserved) - [Link](https://crates.io/crates/rustic_tui)
Terminal UI for `rustic`.
### rustic_cli (reserved) - [Link](https://crates.io/crates/rustic_cli)
Common used CLI functionality for the `rustic` ecosystem.
### rustic_web (reserved) - [Link](https://crates.io/crates/rustic_web)
Possible WASM/WASI functionality for the `rustic` ecosystem.
### rustic_store (reserved) - [Link](https://crates.io/crates/rustic_store)
Possible store functionality to support a plugin system for the `rustic`
ecosystem.
### rustic_plugins (reserved) - [Link](https://crates.io/crates/rustic_plugins)
Plugin functionality for the `rustic` ecosystem.
### rustic_scheduler (reserved) - [Link](https://crates.io/crates/rustic_scheduler)
Scheduling functionality for the `rustic` ecosystem.
### rustic_daemon (reserved) - [Link](https://crates.io/crates/rustic_daemon)
A daemon for `rustic` and running it as a service.
### rustic_backend (reserved) - [Link](https://crates.io/crates/rustic_backend)
A possible backend implementation for `rustic` to support multi-system backup
management.
### rustic_server (reserved) - [Link](https://crates.io/crates/rustic_server)
A possible server implementation for `rustic` to support client-/server
communication (for example for a web GUI or a TUI).
### rustic_bench (reserved) - [Link](https://crates.io/crates/rustic_bench)
Benchmarking functionality for the `rustic` ecosystem.
### rustic_auth (reserved) - [Link](https://crates.io/crates/rustic_auth)
Authentication functionality for the `rustic` ecosystem.

View File

@ -1,10 +0,0 @@
[package]
name = "rustic_testing"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
aho-corasick = { workspace = true }
once_cell = { workspace = true }
tempfile = { workspace = true }

View File

@ -1,71 +0,0 @@
use aho_corasick::{AhoCorasick, PatternID};
use std::{error::Error, ffi::OsStr};
use tempfile::NamedTempFile;
pub type TestResult<T> = std::result::Result<T, Box<dyn Error>>;
pub fn get_matches<I, P>(patterns: I, output: String) -> TestResult<Vec<(PatternID, usize)>>
where
I: IntoIterator<Item = P>,
P: AsRef<[u8]>,
{
let ac = AhoCorasick::new(patterns)?;
let mut matches = vec![];
for mat in ac.find_iter(output.as_str()) {
add_match_to_vector(&mut matches, mat);
}
Ok(matches)
}
pub fn add_match_to_vector(matches: &mut Vec<(PatternID, usize)>, mat: aho_corasick::Match) {
matches.push((mat.pattern(), mat.end() - mat.start()))
}
pub fn get_temp_file() -> TestResult<NamedTempFile> {
Ok(NamedTempFile::new()?)
}
pub fn files_differ(
path_left: impl AsRef<OsStr>,
path_right: impl AsRef<OsStr>,
) -> TestResult<bool> {
// diff the directories
#[cfg(not(windows))]
{
let proc = std::process::Command::new("diff")
.arg(path_left)
.arg(path_right)
.output()?;
if proc.stdout.is_empty() {
return Ok(false);
}
}
#[cfg(windows)]
{
let proc = std::process::Command::new("fc.exe")
.arg("/L")
.arg(path_left)
.arg(path_right)
.output()?;
let output = String::from_utf8(proc.stdout)?;
dbg!(&output);
let patterns = &["FC: no differences encountered"];
let ac = AhoCorasick::new(patterns)?;
let mut matches = vec![];
for mat in ac.find_iter(output.as_str()) {
matches.push((mat.pattern(), mat.end() - mat.start()));
}
if matches == vec![(PatternID::must(0), 30)] {
return Ok(false);
}
}
Ok(true)
}