From 7a6e50931d3de40fde82153d20aeda703555a07d Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Mon, 21 Nov 2022 12:50:15 +0800 Subject: [PATCH] chore: replace justfile with deno task --- .vscode/settings.json | 3 ++ crates/loro-core/deno.json | 11 ++++++ .../fuzz/fuzz_targets/two_client_text.rs | 2 +- crates/loro-core/justfile | 31 --------------- crates/loro-core/scripts/fuzz.ts | 28 ++++++++++++++ crates/loro-wasm/deno.json | 11 ++++++ crates/loro-wasm/deno.lock | 28 ++++++++++++++ crates/loro-wasm/deno_test/test.ts | 8 +++- crates/loro-wasm/justfile | 5 --- deno.json | 12 ++++++ justfile | 38 ------------------- 11 files changed, 101 insertions(+), 76 deletions(-) create mode 100644 crates/loro-core/deno.json delete mode 100644 crates/loro-core/justfile create mode 100644 crates/loro-core/scripts/fuzz.ts create mode 100644 crates/loro-wasm/deno.json create mode 100644 crates/loro-wasm/deno.lock delete mode 100644 crates/loro-wasm/justfile create mode 100644 deno.json delete mode 100644 justfile diff --git a/.vscode/settings.json b/.vscode/settings.json index fc622ddf..1f3d22f4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,13 @@ { "cSpell.words": [ "arbtest", + "clippy", "flate", "Leeeon", "LOGSTORE", + "nextest", "Peritext", + "RUSTFLAGS", "smstring", "thiserror", "txns", diff --git a/crates/loro-core/deno.json b/crates/loro-core/deno.json new file mode 100644 index 00000000..865b0dc8 --- /dev/null +++ b/crates/loro-core/deno.json @@ -0,0 +1,11 @@ +{ + "tasks": { + "test": "cargo nextest run", + "deny": "cargo deny check", + "fuzz": "cargo fuzz run", + "quick-fuzz": "deno run -A ./scripts/fuzz.ts text recursive encoding", + "mem": "RUSTFLAGS='--cfg=mem' cargo run --example mem -r --features=test_utils", + "flame": "cargo flamegraph --example text_sync --features=test_utils --root", + "bench": "cargo bench --features test_utils" + } +} diff --git a/crates/loro-core/fuzz/fuzz_targets/two_client_text.rs b/crates/loro-core/fuzz/fuzz_targets/two_client_text.rs index ecbeff80..a2c0344d 100644 --- a/crates/loro-core/fuzz/fuzz_targets/two_client_text.rs +++ b/crates/loro-core/fuzz/fuzz_targets/two_client_text.rs @@ -2,4 +2,4 @@ use libfuzzer_sys::fuzz_target; use loro_core::fuzz::{test_multi_sites, Action}; -fuzz_target!(|actions: Vec| { test_multi_sites(2, actions) }); +fuzz_target!(|actions: Vec| { test_multi_sites(2, &mut actions.clone()) }); diff --git a/crates/loro-core/justfile b/crates/loro-core/justfile deleted file mode 100644 index 868f5e66..00000000 --- a/crates/loro-core/justfile +++ /dev/null @@ -1,31 +0,0 @@ -build: - cargo build - -test: - cargo nextest run - -check-unsafe: - env RUSTFLAGS="-Funsafe-code --cap-lints=warn" cargo check - -deny: - cargo deny check - -crev: - cargo crev crate check - -fuzz-long TARGET: - cargo fuzz run {{TARGET}} -- -max_total_time=300 -max_len=4000 -jobs=2 - -quick-fuzz: - cargo fuzz run yata -- -max_total_time=10 -max_len=1000 & - cargo fuzz run text -- -max_total_time=10 -max_len=1000 & - cargo fuzz run recursive -- -max_total_time=10 -max_len=1000 - -flame: - cargo flamegraph --example text_sync --features=test_utils --root - -bench *FLAGS: - cargo bench --features test_utils {{FLAGS}} - -mem: - RUSTFLAGS="--cfg=mem" cargo run --example mem -r --features=test_utils diff --git a/crates/loro-core/scripts/fuzz.ts b/crates/loro-core/scripts/fuzz.ts new file mode 100644 index 00000000..1a44208b --- /dev/null +++ b/crates/loro-core/scripts/fuzz.ts @@ -0,0 +1,28 @@ +import __ from "https://deno.land/x/dirname@1.1.2/mod.ts"; +const { __dirname } = __(import.meta); +import { resolve } from "https://deno.land/std@0.105.0/path/mod.ts"; + +const validTargets = Array.from( + Deno.readDirSync(resolve(__dirname, "../fuzz/fuzz_targets")) +).map((x) => x.name.replace(/.rs$/, "")); + +const targets = + Deno.args.length === 0 + ? validTargets + : Deno.args.filter((x) => validTargets.includes(x)); + +const promises = []; +for (const target of targets) { + const cmd = ["cargo", "fuzz", "run", target, "--", "-max_total_time=1"]; + console.log("🔨" + cmd.join(" ")); + promises.push( + Deno.run({ + cmd, + stdout: "inherit", + stderr: "inherit", + cwd: resolve(__dirname, ".."), + }).status() + ); +} + +await Promise.allSettled(promises); diff --git a/crates/loro-wasm/deno.json b/crates/loro-wasm/deno.json new file mode 100644 index 00000000..668aa9b1 --- /dev/null +++ b/crates/loro-wasm/deno.json @@ -0,0 +1,11 @@ +{ + "tasks": { + "build": "wasm-pack build --target web .", + "test": "deno test --allow-read" + }, + "test": { + "files": { + "include": ["deno_test/"] + } + } +} diff --git a/crates/loro-wasm/deno.lock b/crates/loro-wasm/deno.lock new file mode 100644 index 00000000..86befe69 --- /dev/null +++ b/crates/loro-wasm/deno.lock @@ -0,0 +1,28 @@ +{ + "version": "2", + "remote": { + "https://deno.land/std@0.105.0/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58", + "https://deno.land/std@0.105.0/_util/os.ts": "dfb186cc4e968c770ab6cc3288bd65f4871be03b93beecae57d657232ecffcac", + "https://deno.land/std@0.105.0/path/_constants.ts": "1247fee4a79b70c89f23499691ef169b41b6ccf01887a0abd131009c5581b853", + "https://deno.land/std@0.105.0/path/_interface.ts": "1fa73b02aaa24867e481a48492b44f2598cd9dfa513c7b34001437007d3642e4", + "https://deno.land/std@0.105.0/path/_util.ts": "2e06a3b9e79beaf62687196bd4b60a4c391d862cfa007a20fc3a39f778ba073b", + "https://deno.land/std@0.105.0/path/common.ts": "eaf03d08b569e8a87e674e4e265e099f237472b6fd135b3cbeae5827035ea14a", + "https://deno.land/std@0.105.0/path/glob.ts": "3b84af55c53febacf6afe214c095624b22a56b6f57d7312157479cc783a0de65", + "https://deno.land/std@0.105.0/path/mod.ts": "4465dc494f271b02569edbb4a18d727063b5dbd6ed84283ff906260970a15d12", + "https://deno.land/std@0.105.0/path/posix.ts": "b81974c768d298f8dcd2c720229639b3803ca4a241fa9a355c762fa2bc5ef0c1", + "https://deno.land/std@0.105.0/path/separator.ts": "8fdcf289b1b76fd726a508f57d3370ca029ae6976fcde5044007f062e643ff1c", + "https://deno.land/std@0.105.0/path/win32.ts": "f4a3d4a3f2c9fe894da046d5eac48b5e789a0ebec5152b2c0985efe96a9f7ae1", + "https://deno.land/x/dirname@1.1.2/mod.ts": "4029ca6b49da58d262d65f826ba9b3a89cc0b92a94c7220d5feb7bd34e498a54", + "https://deno.land/x/dirname@1.1.2/types.ts": "c1ed1667545bc4b1d69bdb2fc26a5fa8edae3a56e3081209c16a408a322a2319", + "https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/_util/assert.ts": "e1f76e77c5ccb5a8e0dbbbe6cce3a56d2556c8cb5a9a8802fc9565af72462149", + "https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/path/_constants.ts": "aba480c4a2c098b6374fdd5951fea13ecc8aaaf8b8aa4dae1871baa50243d676", + "https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/path/_interface.ts": "67b276380d297a7cedc3c17f7a0bf122edcfc96a3e1f69de06f379d85ba0e2c0", + "https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/path/_util.ts": "7820a788b35c26dfc27ff329df12507fc0553ae92727009597046f6cf856b4fa", + "https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/path/common.ts": "e4ec66a7416d56f60331b66e27a8a4f08c7b1cf48e350271cb69754a01cf5c04", + "https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/path/glob.ts": "54fea22f0f47dee07399d22e18a34a84eaf4b8a3771bbed96db43bbec71ef237", + "https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/path/mod.ts": "6de8885c2534757097818e302becd1cefcbc4c28ac022cc279e612ee04e8cfd1", + "https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/path/posix.ts": "7c2539b5d9e22b47f02ccc5b6ef11e3975a5c60f49d2241271eaa5936e6082a0", + "https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/path/separator.ts": "9dd15d46ff84a16e13554f56af7fee1f85f8d0f379efbbe60ac066a60561f036", + "https://lra6z45nakk5lnu3yjchp7tftsdnwwikwr65ocha5eojfnlgu4sa.arweave.net/XEHs860CldW2m8JEd_5lnIbbWQq0fdcI4OkckrVmpyQ/path/win32.ts": "47114c941681ecbabab4ec355cb41d525fb5a14175cc47a5c76fdc5eaee2685a" + } +} diff --git a/crates/loro-wasm/deno_test/test.ts b/crates/loro-wasm/deno_test/test.ts index 06062151..3940dcd7 100644 --- a/crates/loro-wasm/deno_test/test.ts +++ b/crates/loro-wasm/deno_test/test.ts @@ -1,5 +1,11 @@ import init, { Loro } from "../pkg/loro_wasm.js"; -const wasm = await Deno.readFile("../pkg/loro_wasm_bg.wasm"); +import { resolve } from "https://deno.land/std@0.105.0/path/mod.ts"; +import __ from "https://deno.land/x/dirname@1.1.2/mod.ts"; +const { __dirname } = __(import.meta); + +const wasm = await Deno.readFile( + resolve(__dirname, "../pkg/loro_wasm_bg.wasm") +); await init(wasm); const loro = new Loro(); diff --git a/crates/loro-wasm/justfile b/crates/loro-wasm/justfile deleted file mode 100644 index d12d5cd6..00000000 --- a/crates/loro-wasm/justfile +++ /dev/null @@ -1,5 +0,0 @@ -build: - wasm-pack build --target web . - -test: - cd deno_test && deno run -A test.ts diff --git a/deno.json b/deno.json new file mode 100644 index 00000000..c8e6d825 --- /dev/null +++ b/deno.json @@ -0,0 +1,12 @@ +{ + "tasks": { + "build": "cargo build", + "test": "RUST_BACKTRACE=full cargo nextest run --features=test_utils", + "test-all": "deno task test & deno task quick-fuzz", + "test-prop": "RUSTFLAGS='--cfg=proptest' cargo nextest run --features=test_utils", + "check": "cargo clippy --all-features", + "quick-fuzz": "cd crates/loro-core && just quick-fuzz", + "fix": "cargo clippy --fix --features=test_utils", + "vet": "cargo vet" + } +} diff --git a/justfile b/justfile deleted file mode 100644 index ae53c779..00000000 --- a/justfile +++ /dev/null @@ -1,38 +0,0 @@ -build: - cargo build - -test *FLAGS: - RUST_BACKTRACE=full cargo nextest run --features=test_utils {{FLAGS}} - -test-all: - cargo nextest run --features=test_utils & - just _quickfuzz - -test-prop: - RUSTFLAGS="--cfg=proptest" cargo nextest run --features=test_utils - -_quickfuzz: - cd crates/loro-core && just quick-fuzz - -check: - cargo clippy - -check-unsafe: - env RUSTFLAGS="-Funsafe-code --cap-lints=warn" cargo check - -fix *FLAGS: - cargo clippy --fix --features=test_utils {{FLAGS}} - -deny: - cargo deny check - -vet: - cargo vet - -bench-rle: - cd crates/rle - cargo build --release --examples - cd ../.. - hyperfine --warmup=3 "./target/release/examples/string_tree_bench" - -