#!/bin/bash
require git git cargo
is_cargo_project || return 0

## In a rust/cargo project, when a $LAST_TEST_DIR is present then hardlink the /target
## build artifacts to the current test dir this can speed up builds.
## Also sets CARGO_NET_OFFLINE=true
if [[ "${LAST_TEST_DIR:-}" ]]; then
    debug "populating from $LAST_TEST_DIR/target"
    [[ -d "$LAST_TEST_DIR/target" ]] && cp -rluf "$LAST_TEST_DIR/target" "./"
    export CARGO_NET_OFFLINE=true
fi

