#!/bin/sh
set -xeu

# Create cargo config directory
CARGO_TMP_DIR=$(mktemp -d)
trap 'rm -rf "$CARGO_TMP_DIR"' EXIT

# Create config.toml
cat > $CARGO_TMP_DIR/config.toml << EOL
[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "$(pwd)/debian/rust-vendor"
EOL

# Run the actual test
export CARGO_HOME="$CARGO_TMP_DIR"
# We explicitly test the installed rather than building a new package,
# as this is the test other packages trigger
export SEQUOIA_TEST_BIN=/usr/bin/sq

debian/tests/run-cargo-tests
