2022-10-28 21:52:39 +03:00
|
|
|
#!/usr/bin/env just --justfile
|
|
|
|
set shell := ["bash", "-c"]
|
|
|
|
|
|
|
|
export DATABASE_URL := "postgres://postgres@localhost/db"
|
|
|
|
export CARGO_TERM_COLOR := "always"
|
|
|
|
# export RUST_BACKTRACE := "1"
|
|
|
|
|
|
|
|
@_default:
|
2022-10-31 23:28:21 +03:00
|
|
|
just --list --unsorted
|
2022-10-28 21:52:39 +03:00
|
|
|
|
|
|
|
# Start Martin server and a test database
|
2022-11-02 21:00:05 +03:00
|
|
|
run *ARGS: start-db
|
|
|
|
cargo run -- {{ARGS}}
|
2022-10-28 21:52:39 +03:00
|
|
|
|
2022-11-30 19:57:27 +03:00
|
|
|
# Run PSQL utility against the test database
|
|
|
|
psql *ARGS: start-db
|
|
|
|
psql {{ARGS}} {{DATABASE_URL}}
|
|
|
|
|
2022-10-28 21:52:39 +03:00
|
|
|
# Perform cargo clean to delete all build files
|
2022-11-30 19:57:27 +03:00
|
|
|
clean: clean-test stop
|
2022-10-28 21:52:39 +03:00
|
|
|
cargo clean
|
|
|
|
|
|
|
|
# Delete test output files
|
|
|
|
clean-test:
|
|
|
|
rm -rf tests/output
|
|
|
|
|
|
|
|
# Start a test database
|
2022-12-04 08:34:44 +03:00
|
|
|
start-db: (docker-up "db")
|
|
|
|
|
|
|
|
# Start a legacy test database
|
|
|
|
start-legacy: (docker-up "db-legacy")
|
|
|
|
|
|
|
|
# Start a specific test database, e.g. db or db-legacy
|
|
|
|
@docker-up name:
|
|
|
|
docker-compose up -d {{name}}
|
2022-10-28 21:52:39 +03:00
|
|
|
|
|
|
|
alias _down := stop
|
|
|
|
alias _stop-db := stop
|
|
|
|
|
|
|
|
# Stop the test database
|
|
|
|
stop:
|
|
|
|
docker-compose down
|
|
|
|
|
|
|
|
# Run benchmark tests
|
|
|
|
bench: start-db
|
|
|
|
cargo bench
|
|
|
|
|
|
|
|
# Run all tests using a test database
|
2022-10-31 23:28:21 +03:00
|
|
|
test: test-unit test-int
|
2022-10-28 21:52:39 +03:00
|
|
|
|
2022-11-19 18:52:58 +03:00
|
|
|
# Run Rust unit and doc tests (cargo test)
|
2022-10-28 21:52:39 +03:00
|
|
|
test-unit: start-db
|
2022-11-19 18:52:58 +03:00
|
|
|
cargo test --all-targets
|
|
|
|
cargo test --all-targets --all-features
|
|
|
|
cargo test --doc
|
2022-10-28 21:52:39 +03:00
|
|
|
|
|
|
|
# Run integration tests
|
2022-12-04 08:34:44 +03:00
|
|
|
test-int: (test-integration "db")
|
|
|
|
|
|
|
|
# Run integration tests using legacy database
|
|
|
|
test-int-legacy: (test-integration "db-legacy")
|
|
|
|
|
|
|
|
# Run integration tests with the given docker compose target
|
|
|
|
@test-integration name: (docker-up name) clean-test
|
2022-10-31 23:28:21 +03:00
|
|
|
#!/usr/bin/env sh
|
2022-10-28 21:52:39 +03:00
|
|
|
tests/test.sh
|
2022-12-04 08:34:44 +03:00
|
|
|
# echo "** Skipping comparison with the expected values - not yet stable"
|
|
|
|
# if ( ! diff --brief --recursive --new-file tests/output tests/expected ); then
|
|
|
|
# echo "** Expected output does not match actual output"
|
|
|
|
# echo "** If this is expected, run 'just bless' to update expected output"
|
|
|
|
# echo "** Note that this error is not fatal because we don't have a stable output yet"
|
|
|
|
# fi
|
2022-10-28 21:52:39 +03:00
|
|
|
|
|
|
|
# Run integration tests and save its output as the new expected output
|
2022-10-31 23:28:21 +03:00
|
|
|
bless: start-db clean-test
|
2022-10-28 21:52:39 +03:00
|
|
|
tests/test.sh
|
|
|
|
rm -rf tests/expected
|
|
|
|
mv tests/output tests/expected
|
2022-10-31 23:28:21 +03:00
|
|
|
|
2022-11-02 21:00:05 +03:00
|
|
|
# Build martin docker image
|
|
|
|
docker-build:
|
|
|
|
docker build -t martin .
|
|
|
|
|
|
|
|
# Build and run martin docker image
|
|
|
|
docker-run *ARGS:
|
|
|
|
docker run -it --rm --net host -e DATABASE_URL -v $PWD/tests:/tests martin {{ARGS}}
|
|
|
|
|
2022-10-31 23:28:21 +03:00
|
|
|
# Do any git command, ensuring that the testing environment is set up. Accepts the same arguments as git.
|
2022-11-30 19:57:27 +03:00
|
|
|
[no-exit-message]
|
2022-10-31 23:28:21 +03:00
|
|
|
git *ARGS: start-db
|
|
|
|
git {{ARGS}}
|