# Comment this out to build with network access.
OFFLINE = --offline --locked

all: check build test

check:
	cargo clippy --all-targets $(OFFLINE) -- --deny warnings
	cargo fmt -- --check

build:
	cargo build --all-targets $(OFFLINE)
	subplot docgen jt.subplot --output jt.html
	subplot codegen jt.subplot --output test.py

test:
	cargo test $(OFFLINE) -- $(TESTS)
	rm -f test.log
	target="$(cargo metadata --format-version=1 | python3 -c 'import json, sys; o = json.load(sys.stdin); print (o["target_directory"])')" &&  \
	    if ! python3 test.py --log test.log --env "CARGO_TARGET_DIR=$target" "$@"; then cat test.log; fi
