Skip to content

Commit

Permalink
Merge pull request #2671 from IntersectMBO/reusable_test_env
Browse files Browse the repository at this point in the history
feat: make test env setup reusable in another shells
  • Loading branch information
mkoura authored Oct 10, 2024
2 parents abbf17a + 3785586 commit 38a6af6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ Sometimes it is useful to run individual tests and keep the local cluster runnin
./dev_workdir/conway_fast/stop-cluster
```

To reuse the existing testing environment in another nix shell, source the `.source` file that was generated during setup:

```sh
source ./dev_workdir/.source
```

## Variables for configuring testrun

Tests execution can be configured using env variables.
Expand Down
24 changes: 23 additions & 1 deletion prepare_test_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,32 @@ if [ ! -d "$_scripts_dest" ]; then
fi
unset _scripts_dest

cat > "$WORKDIR/.source" <<EoF
if [ -z "\${IN_NIX_SHELL:-""}" ]; then
echo "WARNING: This script is supposed to be sourced from nix shell." >&2
fi
source "$VIRTUAL_ENV/bin/activate"
PYTHONPATH="$(echo "\$VIRTUAL_ENV"/lib/python3*/site-packages):\$PYTHONPATH"
export PYTHONPATH
export CARDANO_NODE_SOCKET_PATH="$PWD/dev_workdir/state-cluster0/bft1.socket"
export TMPDIR="$PWD/dev_workdir/tmp"
export DEV_CLUSTER_RUNNING=1
export CLUSTERS_COUNT=1
export FORBID_RESTART=1
export NO_ARTIFACTS=1
export CLUSTER_ERA="$CLUSTER_ERA"
export COMMAND_ERA="${COMMAND_ERA:-""}"
EoF

echo
echo
echo "----------------------------------------"
echo "------------------------"
echo "| Test Env Ready |"
echo "------------------------"
echo
echo "To start local testnet, run:"
echo "$WORKDIR/${CLUSTER_ERA}_fast/start-cluster"
echo
echo "To reuse the test env in another shell, source the env with:"
echo "source $WORKDIR/.source"
echo

0 comments on commit 38a6af6

Please sign in to comment.