Skip to content

Commit

Permalink
chore: streamline e2e and coverage test script
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcaron committed Jan 6, 2025
1 parent 922d7a8 commit 18711c2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 58 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/rust-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ jobs:
- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Launch Anvil
run: anvil --fork-url $ANVIL_FORK_URL --fork-block-number $ANVIL_BLOCK_NUMBER &
env:
ANVIL_FORK_URL: "https://eth.merkle.io"
ANVIL_BLOCK_NUMBER: 20395662
- name: Wait for Anvil to be ready
run: |
while ! nc -z localhost 8545; do
sleep 1
done

- name: Run unit tests
run: |
Expand Down
40 changes: 15 additions & 25 deletions scripts/e2e-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
#!/bin/bash
set -e

anvil --fork-url https://eth.merkle.io --fork-block-number 20395662 &
# Configuration
export PROPTEST_CASES=5
export ETH_FORK_URL=https://eth.merkle.io

subshell() {
set -e
rm -f target/madara-* lcov.info
# Clean up previous coverage data
rm -f target/madara-* lcov.info

source <(cargo llvm-cov show-env --export-prefix)
# Set up LLVM coverage environment
source <(cargo llvm-cov show-env --export-prefix)

cargo build --bin madara --profile dev
# Build the binary with coverage instrumentation
cargo build --bin madara --profile dev
export COVERAGE_BIN=$(realpath target/debug/madara)

export COVERAGE_BIN=$(realpath target/debug/madara)
export ETH_FORK_URL=https://eth.merkle.io
# Run tests with coverage collection
cargo test --profile dev "${@:-"--workspace"}"

# wait for anvil
while ! nc -z localhost 8545; do
sleep 1
done


ARGS=$@
export PROPTEST_CASES=5
cargo test --profile dev ${ARGS:=--workspace}

cargo llvm-cov report --lcov --output-path lcov.info
cargo llvm-cov report
}

(subshell $@ && r=$?) || r=$?
pkill -P $$
exit $r
# Generate coverage reports
cargo llvm-cov report --lcov --output-path lcov.info # Generate LCOV report
cargo llvm-cov report # Display coverage summary in terminal
30 changes: 7 additions & 23 deletions scripts/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,13 @@
# Usage: ``./scripts/e2e-tests.sh <name of the tests to run>`
set -e

# will also launch anvil and automatically close it down on error or success

# Configuration
export PROPTEST_CASES=10
export ETH_FORK_URL=https://eth.merkle.io

anvil --fork-url https://eth.merkle.io --fork-block-number 20395662 &

subshell() {
set -e
cargo build --bin madara --profile dev

export COVERAGE_BIN=$(realpath target/debug/madara)
export ETH_FORK_URL=https://eth.merkle.io

# wait for anvil
while ! nc -z localhost 8545; do
sleep 1
done

ARGS=$@
export PROPTEST_CASES=5
cargo test --profile dev ${ARGS:=--workspace}
}
# Build the binary
cargo build --bin madara --profile dev
export BINARY_PATH=$(realpath target/debug/madara)

(subshell $@ && r=$?) || r=$?
pkill -P $$
exit $r
# Run the tests
cargo test --profile dev "${@:-"--workspace"}"

0 comments on commit 18711c2

Please sign in to comment.