mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-05 20:17:13 +00:00
refactor: rename feature fuzzing to test_utils
This commit is contained in:
parent
9758303c28
commit
1ca3f0e774
20 changed files with 35 additions and 35 deletions
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -3,7 +3,7 @@
|
|||
"rust-analyzer.runnableEnv": {
|
||||
"RUST_BACKTRACE": "full"
|
||||
},
|
||||
"rust-analyzer.cargo.features": ["fuzzing", "wasm"],
|
||||
"rust-analyzer.cargo.features": ["test_utils", "wasm"],
|
||||
"editor.defaultFormatter": "rust-lang.rust-analyzer",
|
||||
"editor.formatOnSave": true,
|
||||
"todo-tree.general.tags": [
|
||||
|
|
|
@ -30,6 +30,7 @@ js-sys = { version = "0.3.60", optional = true }
|
|||
serde_json = { version = "1.0.87", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0.87"
|
||||
dhat = "0.3.1"
|
||||
rand = { version = "0.8.5" }
|
||||
proptest = "1.0.0"
|
||||
|
@ -51,7 +52,7 @@ doctest = false
|
|||
wasm = ["wasm-bindgen", "js-sys"]
|
||||
json = ["serde_json"]
|
||||
# whether to use list slice instead of raw str in text container
|
||||
fuzzing = ["crdt-list/fuzzing", "rand", "arbitrary", "tabled", "json"]
|
||||
test_utils = ["crdt-list/fuzzing", "rand", "arbitrary", "tabled", "json"]
|
||||
|
||||
[[bench]]
|
||||
name = "text"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
const RAW_DATA: &[u8; 901823] = include_bytes!("automerge-paper.json.gz");
|
||||
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
mod run {
|
||||
use std::io::Read;
|
||||
|
||||
|
@ -148,8 +148,8 @@ mod run {
|
|||
}
|
||||
pub fn dumb(_c: &mut Criterion) {}
|
||||
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
criterion_group!(benches, run::two_client_edits, run::b4);
|
||||
#[cfg(not(feature = "fuzzing"))]
|
||||
#[cfg(not(feature = "test_utils"))]
|
||||
criterion_group!(benches, dumb);
|
||||
criterion_main!(benches);
|
||||
|
|
|
@ -51,7 +51,7 @@ pub fn main() {
|
|||
}
|
||||
drop(json);
|
||||
drop(d);
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
loro.debug_inspect();
|
||||
#[cfg(mem)]
|
||||
drop(profiler);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#[cfg(not(feature = "fuzzing"))]
|
||||
#[cfg(not(feature = "test_utils"))]
|
||||
fn main() {}
|
||||
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
fn main() {
|
||||
const RAW_DATA: &[u8; 901823] = include_bytes!("../benches/automerge-paper.json.gz");
|
||||
use std::{io::Read, time::Instant};
|
||||
|
||||
use flate2::read::GzDecoder;
|
||||
use loro_core::{LoroCore};
|
||||
use loro_core::LoroCore;
|
||||
use serde_json::Value;
|
||||
|
||||
let mut d = GzDecoder::new(&RAW_DATA[..]);
|
||||
|
|
4
crates/loro-core/fuzz/Cargo.lock
generated
4
crates/loro-core/fuzz/Cargo.lock
generated
|
@ -69,9 +69,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.11.0"
|
||||
version = "3.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d"
|
||||
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
|
|
|
@ -14,7 +14,7 @@ libfuzzer-sys = "0.4"
|
|||
|
||||
[dependencies.loro-core]
|
||||
path = ".."
|
||||
features = ["fuzzing"]
|
||||
features = ["test_utils"]
|
||||
|
||||
# Prevent this from interfering with workspaces
|
||||
[workspace]
|
||||
|
|
|
@ -22,10 +22,10 @@ quick-fuzz:
|
|||
cargo fuzz run recursive -- -max_total_time=10 -max_len=1000
|
||||
|
||||
flame:
|
||||
cargo flamegraph --example text_sync --features=fuzzing --root
|
||||
cargo flamegraph --example text_sync --features=test_utils --root
|
||||
|
||||
bench *FLAGS:
|
||||
cargo bench --features fuzzing {{FLAGS}}
|
||||
cargo bench --features test_utils {{FLAGS}}
|
||||
|
||||
mem:
|
||||
RUSTFLAGS="--cfg=mem" cargo run --example mem -r --features=fuzzing
|
||||
RUSTFLAGS="--cfg=mem" cargo run --example mem -r --features=test_utils
|
||||
|
|
|
@ -7,7 +7,7 @@ pub(crate) enum Slot {}
|
|||
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "fuzzing", derive(arbitrary::Arbitrary))]
|
||||
#[cfg_attr(feature = "test_utils", derive(arbitrary::Arbitrary))]
|
||||
pub enum ContainerType {
|
||||
/// See [`crate::text::TextContent`]
|
||||
Text,
|
||||
|
|
|
@ -194,7 +194,7 @@ impl ListContainer {
|
|||
self.tracker.check();
|
||||
}
|
||||
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
pub fn debug_inspect(&mut self) {
|
||||
println!(
|
||||
"Text Container {:?}, Raw String size={}, Tree=>\n",
|
||||
|
|
|
@ -175,7 +175,7 @@ impl ContainerRegistry {
|
|||
self.get_idx(id).unwrap()
|
||||
}
|
||||
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
pub fn debug_inspect(&mut self) {
|
||||
for ContainerAndId { container, id: _ } in self.containers.iter_mut() {
|
||||
if let ContainerInstance::Text(x) = container.lock().unwrap().deref_mut() {
|
||||
|
|
|
@ -127,7 +127,7 @@ impl TextContainer {
|
|||
self.tracker.check();
|
||||
}
|
||||
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
pub fn debug_inspect(&mut self) {
|
||||
println!(
|
||||
"Text Container {:?}, Raw String size={}, Tree=>\n",
|
||||
|
|
|
@ -28,9 +28,9 @@ mod content_map;
|
|||
mod cursor_map;
|
||||
mod effects_iter;
|
||||
mod y_span;
|
||||
#[cfg(not(feature = "fuzzing"))]
|
||||
#[cfg(not(feature = "test_utils"))]
|
||||
mod yata_impl;
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
pub mod yata_impl;
|
||||
|
||||
/// A tracker for a single text, we can use it to calculate the effect of an operation on a text.
|
||||
|
@ -42,7 +42,7 @@ pub mod yata_impl;
|
|||
///
|
||||
#[derive(Debug)]
|
||||
pub struct Tracker {
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
client_id: ClientID,
|
||||
/// from start_vv to latest vv are applied
|
||||
start_vv: VersionVector,
|
||||
|
@ -80,7 +80,7 @@ impl Tracker {
|
|||
Tracker {
|
||||
content,
|
||||
id_to_cursor,
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
client_id: 0,
|
||||
head_vv: start_vv.clone(),
|
||||
all_vv: start_vv.clone(),
|
||||
|
|
|
@ -189,7 +189,7 @@ impl HasLength for YSpan {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(test, features = "fuzzing"))]
|
||||
#[cfg(any(test, features = "test_utils"))]
|
||||
pub mod test {
|
||||
use crate::{
|
||||
container::text::text_content::ListSlice,
|
||||
|
|
|
@ -167,7 +167,7 @@ mod test {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
pub mod fuzz {
|
||||
use std::borrow::Cow;
|
||||
use tabled::Tabled;
|
||||
|
@ -283,7 +283,7 @@ pub mod fuzz {
|
|||
|
||||
fn new_container(client_id: usize) -> Self::Container {
|
||||
let mut tracker = Tracker::new(Default::default(), Counter::MAX / 2);
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
{
|
||||
tracker.client_id = client_id as ClientID;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ pub mod op;
|
|||
pub mod version;
|
||||
|
||||
mod error;
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
pub mod fuzz;
|
||||
mod loro;
|
||||
mod smstring;
|
||||
|
|
|
@ -370,7 +370,7 @@ impl LogStore {
|
|||
&self.vv
|
||||
}
|
||||
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
pub fn debug_inspect(&mut self) {
|
||||
println!(
|
||||
"LogStore:\n- Clients={}\n- Changes={}\n- Ops={}\n- Atoms={}",
|
||||
|
|
|
@ -87,7 +87,7 @@ impl LoroCore {
|
|||
store.import(changes)
|
||||
}
|
||||
|
||||
#[cfg(feature = "fuzzing")]
|
||||
#[cfg(feature = "test_utils")]
|
||||
pub fn debug_inspect(&self) {
|
||||
self.log_store.write().unwrap().debug_inspect();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,5 @@ rand = "0.8.5"
|
|||
static_assertions = "1.1.0"
|
||||
|
||||
[features]
|
||||
fuzzing = []
|
||||
proptest = ["fuzzing"]
|
||||
test_utils = []
|
||||
wasm = []
|
||||
|
|
8
justfile
8
justfile
|
@ -2,14 +2,14 @@ build:
|
|||
cargo build
|
||||
|
||||
test *FLAGS:
|
||||
RUST_BACKTRACE=full cargo nextest run --features=fuzzing {{FLAGS}}
|
||||
RUST_BACKTRACE=full cargo nextest run --features=test_utils {{FLAGS}}
|
||||
|
||||
test-all:
|
||||
cargo nextest run --features=fuzzing &
|
||||
cargo nextest run --features=test_utils &
|
||||
just _quickfuzz
|
||||
|
||||
test-prop:
|
||||
RUSTFLAGS="--cfg=proptest" cargo nextest run --features=fuzzing
|
||||
RUSTFLAGS="--cfg=proptest" cargo nextest run --features=test_utils
|
||||
|
||||
_quickfuzz:
|
||||
cd crates/loro-core && just quick-fuzz
|
||||
|
@ -21,7 +21,7 @@ check-unsafe:
|
|||
env RUSTFLAGS="-Funsafe-code --cap-lints=warn" cargo check
|
||||
|
||||
fix *FLAGS:
|
||||
cargo clippy --fix --features=fuzzing {{FLAGS}}
|
||||
cargo clippy --fix --features=test_utils {{FLAGS}}
|
||||
|
||||
deny:
|
||||
cargo deny check
|
||||
|
|
Loading…
Reference in a new issue