bench/suite_bench: use snake case for input files

rust identifiers may not contain -

use _ for files also to avoid confusion of having two names
This commit is contained in:
Noah Hellman 2023-04-10 11:29:40 +02:00
parent 9bdb4c59fc
commit bee3d5d747
4 changed files with 6 additions and 5 deletions

View file

@ -38,7 +38,8 @@ suite:
suite_bench: suite_bench:
git submodule update --init modules/djot.js git submodule update --init modules/djot.js
for f in $$(find modules/djot.js/bench -name '*.dj' | xargs basename -a); do \ for f in $$(find modules/djot.js/bench -name '*.dj' | xargs basename -a); do \
ln -fs ../../modules/djot.js/bench/$$f tests/bench/$$f; \ dst=$$(echo $$f | sed 's/-/_/g'); \
ln -fs ../../modules/djot.js/bench/$$f tests/bench/$$dst; \
done done
(cd tests/bench && make) (cd tests/bench && make)
cargo test --features suite_bench bench:: cargo test --features suite_bench bench::
@ -47,7 +48,8 @@ suite_bench:
bench: bench:
git submodule update --init modules/djot.js git submodule update --init modules/djot.js
for f in $$(find modules/djot.js/bench -name '*.dj' | xargs basename -a); do \ for f in $$(find modules/djot.js/bench -name '*.dj' | xargs basename -a); do \
ln -fs ../modules/djot.js/bench/$$f bench/$$f; \ dst=$$(echo $$f | sed 's/-/_/g'); \
ln -fs ../modules/djot.js/bench/$$f bench/$$dst; \
done done
cov: suite suite_bench cov: suite suite_bench

View file

@ -8,12 +8,11 @@ fn main() {
if let Some(name) = entry.file_name().to_str() { if let Some(name) = entry.file_name().to_str() {
if let Some(name) = name.strip_suffix(".dj") { if let Some(name) = name.strip_suffix(".dj") {
if entry.file_type().map_or(false, |ty| !ty.is_dir()) { if entry.file_type().map_or(false, |ty| !ty.is_dir()) {
let name_snake = name.replace('-', "_");
let input = std::fs::read_to_string( let input = std::fs::read_to_string(
std::path::Path::new("..").join(entry.file_name()), std::path::Path::new("..").join(entry.file_name()),
) )
.ok()?; .ok()?;
return Some((name_snake, input)); return Some((name.to_string(), input));
} }
} }
} }

View file

@ -9,7 +9,7 @@ DJOT_JS_SRC=$(shell find ${DJOT_JS}/src -name '.ts')
mod.rs: ${TEST_DJ} html mod.rs: ${TEST_DJ} html
echo "use crate::suite_test;" > $@ echo "use crate::suite_test;" > $@
for name in ${TEST}; do \ for name in ${TEST}; do \
name_snake=$$(basename -a $$name | sed 's/-/_/g'); \ name_snake=$$(basename -a $$name); \
skip_reason=$$(grep -E "^$${name_snake}:" skip | cut -d: -f2); \ skip_reason=$$(grep -E "^$${name_snake}:" skip | cut -d: -f2); \
[ -n "$$skip_reason" ] && echo "#[ignore = \"$${skip_reason}\"]"; \ [ -n "$$skip_reason" ] && echo "#[ignore = \"$${skip_reason}\"]"; \
echo "#[test]"; \ echo "#[test]"; \