#!/bin/bash
set -euo pipefail

cp -ar tests "$AUTOPKGTEST_TMP"/.
cd "$AUTOPKGTEST_TMP"

mkdir .cargo
cat <<'END' >.cargo/config.toml
[source.debian-packages]
directory = "/usr/share/cargo/registry"

[source.crates-io]
replace-with = "debian-packages"
END

HOME="$AUTOPKGTEST_TMP"
export HOME

cd tests

perl -i -ne '
    # neither TOML, nor TOML::Tiny, can produce a working edited Cargo.toml
    s{\bpath *= *"[^"]+",}{} if m/^derive-deftly /;
    print or die $!;
    print "\n[workspace]\n" or die $! if eof;
' Cargo.toml

# These can't sensibly be made to do as-installed,
# and it's not what they're for.
> directly.rs

cargo test --features=full
