2022-11-12 12:46:13 -05:00
|
|
|
.POSIX:
|
|
|
|
|
2023-02-11 08:40:20 -05:00
|
|
|
all: jotdown docs
|
|
|
|
cargo build --workspace
|
|
|
|
|
|
|
|
jotdown: target/release/jotdown
|
|
|
|
cp $< $@
|
|
|
|
|
|
|
|
target/release/jotdown:
|
|
|
|
cargo build --release
|
|
|
|
|
|
|
|
.PHONY:
|
|
|
|
docs:
|
|
|
|
cargo doc --no-deps --workspace
|
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint:
|
|
|
|
cargo fmt --all -- --check
|
|
|
|
cargo clippy -- -D warnings
|
|
|
|
cargo clippy --no-default-features -- -D warnings
|
|
|
|
cargo clippy --all-features -- -D warnings
|
|
|
|
|
|
|
|
.PHONY: check
|
|
|
|
check:
|
|
|
|
cargo test --workspace
|
|
|
|
cargo test --workspace --no-default-features
|
|
|
|
|
2022-11-12 12:46:13 -05:00
|
|
|
.PHONY: suite
|
|
|
|
suite:
|
2023-01-16 12:53:48 -05:00
|
|
|
git submodule update --init modules/djot.js
|
|
|
|
for f in $$(find modules/djot.js/test -name '*.test' | xargs basename -a); do \
|
2023-04-08 12:17:31 -04:00
|
|
|
ln -fs ../../modules/djot.js/test/$$f tests/suite/djot_js_$$f; \
|
2022-11-12 12:46:13 -05:00
|
|
|
done
|
|
|
|
(cd tests/suite && make)
|
2023-02-06 12:37:34 -05:00
|
|
|
cargo test --features suite suite::
|
2022-11-12 12:46:13 -05:00
|
|
|
|
2023-01-30 10:58:46 -05:00
|
|
|
.PHONY: suite_bench
|
|
|
|
suite_bench:
|
|
|
|
git submodule update --init modules/djot.js
|
|
|
|
for f in $$(find modules/djot.js/bench -name '*.dj' | xargs basename -a); do \
|
2023-04-10 05:29:40 -04:00
|
|
|
dst=$$(echo $$f | sed 's/-/_/g'); \
|
|
|
|
ln -fs ../../modules/djot.js/bench/$$f tests/bench/$$dst; \
|
2023-01-30 10:58:46 -05:00
|
|
|
done
|
|
|
|
(cd tests/bench && make)
|
2023-02-06 12:37:34 -05:00
|
|
|
cargo test --features suite_bench bench::
|
2023-01-30 10:58:46 -05:00
|
|
|
|
2023-01-31 16:51:16 -05:00
|
|
|
.PHONY: bench
|
|
|
|
bench:
|
|
|
|
git submodule update --init modules/djot.js
|
|
|
|
for f in $$(find modules/djot.js/bench -name '*.dj' | xargs basename -a); do \
|
2023-04-10 05:29:40 -04:00
|
|
|
dst=$$(echo $$f | sed 's/-/_/g'); \
|
2023-04-10 05:38:32 -04:00
|
|
|
ln -fs ../../modules/djot.js/bench/$$f bench/input/$$dst; \
|
2023-01-31 16:51:16 -05:00
|
|
|
done
|
|
|
|
|
2023-02-02 10:01:01 -05:00
|
|
|
cov: suite suite_bench
|
|
|
|
LLVM_COV=llvm-cov LLVM_PROFDATA=llvm-profdata cargo llvm-cov --features=suite,suite_bench --workspace --html --ignore-run-fail
|
|
|
|
|
2023-03-12 14:51:38 -04:00
|
|
|
AFL_TARGET?=parse
|
2023-02-01 11:44:42 -05:00
|
|
|
AFL_JOBS?=1
|
|
|
|
AFL_TARGET_CRASH?=crashes
|
|
|
|
|
|
|
|
afl:
|
|
|
|
rm -rf tests/afl/out
|
|
|
|
(cd tests/afl && \
|
2023-03-12 15:03:58 -04:00
|
|
|
cargo afl build --no-default-features --release --config profile.release.debug-assertions=true && \
|
2023-02-11 16:04:39 -05:00
|
|
|
(AFL_NO_UI=1 cargo afl fuzz -i in -o out -Mm target/release/${AFL_TARGET} &) && \
|
2023-02-01 11:44:42 -05:00
|
|
|
for i in $$(seq $$((${AFL_JOBS} - 1))); do \
|
2023-02-11 16:04:39 -05:00
|
|
|
AFL_NO_UI=1 cargo afl fuzz -i in -o out -Ss$$i target/release/${AFL_TARGET} & \
|
2023-02-01 11:44:42 -05:00
|
|
|
done; \
|
|
|
|
trap - EXIT;\
|
|
|
|
cat) # keep process alive for trap
|
|
|
|
|
2023-02-13 11:44:50 -05:00
|
|
|
afl_quick:
|
|
|
|
rm -rf tests/afl/out
|
|
|
|
(cd tests/afl && \
|
2023-03-12 15:03:58 -04:00
|
|
|
cargo afl build --no-default-features --release --config profile.release.debug-assertions=true && \
|
2023-02-13 11:44:50 -05:00
|
|
|
AFL_NO_UI=1 AFL_BENCH_UNTIL_CRASH=1 \
|
|
|
|
cargo afl fuzz -i in -o out -V 60 target/release/${AFL_TARGET})
|
2023-03-20 12:43:09 -04:00
|
|
|
[ -z "$$(find tests/afl/out/default/crashes -type f -name 'id:*')" ]
|
2023-02-13 11:44:50 -05:00
|
|
|
|
2023-02-01 11:44:42 -05:00
|
|
|
afl_crash:
|
|
|
|
set +e; \
|
2023-03-12 14:04:04 -04:00
|
|
|
failures="$$(find . -path './tmin/*') $$(find tests/afl/out -path '*/${AFL_TARGET_CRASH}/id*')"; \
|
|
|
|
for f in $$failures; do \
|
2023-03-12 13:47:59 -04:00
|
|
|
echo $$f; \
|
|
|
|
out=$$(cat $$f | (cd tests/afl && RUST_BACKTRACE=1 cargo run ${AFL_TARGET} 2>&1)); \
|
2023-02-01 11:44:42 -05:00
|
|
|
if [ $$? -ne 0 ]; then \
|
|
|
|
echo; \
|
|
|
|
echo "FAIL"; \
|
|
|
|
echo "$$out"; \
|
|
|
|
exit 1; \
|
|
|
|
fi; \
|
|
|
|
done
|
|
|
|
|
2023-03-12 14:04:04 -04:00
|
|
|
afl_tmin:
|
|
|
|
rm -rf tmin
|
|
|
|
mkdir tmin
|
|
|
|
for f in $$(find tests/afl/out -path '*/${AFL_TARGET_CRASH}/id*'); do \
|
|
|
|
cargo afl tmin -i $$f -o tmin/$$(basename $$f) tests/afl/target/release/${AFL_TARGET}; \
|
|
|
|
done
|
|
|
|
|
2022-11-12 12:46:13 -05:00
|
|
|
clean:
|
|
|
|
cargo clean
|
|
|
|
git submodule deinit -f --all
|
|
|
|
rm -f tests/suite/*.test
|
|
|
|
(cd tests/suite && make clean)
|
2023-01-30 10:58:46 -05:00
|
|
|
rm -f tests/bench/*.dj
|
|
|
|
(cd tests/bench && make clean)
|
2023-03-27 17:00:57 -04:00
|
|
|
find bench -type l -path 'bench/*.dj' -print0 | xargs -0 rm -f
|
2023-02-01 11:44:42 -05:00
|
|
|
rm -rf tests/afl/out
|
2023-02-05 13:41:11 -05:00
|
|
|
(cd examples/jotdown_wasm && make clean)
|