From b2ad0e127a42a6f69518dbb7a02499537ac80c74 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 13 Mar 2023 16:54:19 +0000 Subject: [PATCH] Update make e2e test so that you only need the test name (#3281) --- .../e2e-compatibility-workflow-call.yaml | 2 +- .github/workflows/e2e-fork.yml | 2 +- .github/workflows/e2e-test-workflow-call.yml | 2 +- e2e/Makefile | 2 +- e2e/README.md | 6 +++++ e2e/scripts/run-e2e.sh | 24 +++++++++++++++---- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e-compatibility-workflow-call.yaml b/.github/workflows/e2e-compatibility-workflow-call.yaml index fddf2f6ffdc..e77026d2f33 100644 --- a/.github/workflows/e2e-compatibility-workflow-call.yaml +++ b/.github/workflows/e2e-compatibility-workflow-call.yaml @@ -46,7 +46,7 @@ jobs: - name: Run e2e Test run: | cd e2e - make e2e-test entrypoint=${{ matrix.entrypoint }} test=${{ matrix.test }} + make e2e-test test=${{ matrix.test }} env: # each test has its own set of variables to specify which images are used. CHAIN_IMAGE: "${{ matrix.chain-image }}" diff --git a/.github/workflows/e2e-fork.yml b/.github/workflows/e2e-fork.yml index 1f3f691c9ae..faa18d3aca5 100644 --- a/.github/workflows/e2e-fork.yml +++ b/.github/workflows/e2e-fork.yml @@ -48,4 +48,4 @@ jobs: - name: Run e2e Test run: | cd e2e - make e2e-test entrypoint=${{ matrix.entrypoint }} test=${{ matrix.test }} + make e2e-test test=${{ matrix.test }} diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 8f45c8c1aa2..756a69b0ead 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -168,7 +168,7 @@ jobs: id: e2e_test run: | cd e2e - make e2e-test entrypoint=${{ matrix.entrypoint }} test=${{ matrix.test }} + make e2e-test test=${{ matrix.test }} - name: Upload Diagnostics uses: actions/upload-artifact@v3 if: ${{ failure() && inputs.upload-logs }} diff --git a/e2e/Makefile b/e2e/Makefile index 0b9802d06e1..0be3866abb8 100644 --- a/e2e/Makefile +++ b/e2e/Makefile @@ -8,7 +8,7 @@ cleanup-ibc-test-containers: done e2e-test: cleanup-ibc-test-containers - ./scripts/run-e2e.sh $(entrypoint) $(test) + ./scripts/run-e2e.sh $(test) $(entrypoint) compatibility-tests: ./scripts/run-compatibility-tests.sh $(release_branch) diff --git a/e2e/README.md b/e2e/README.md index d6a03e4485c..b683baf8cb4 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -72,6 +72,12 @@ export RELAYER_TAG="v2.0.0" make e2e-test entrypoint=TestInterchainAccountsTestSuite test=TestMsgSubmitTx_SuccessfulTransfer ``` +If `jq` is installed, you only need to specify the `test`. + +```sh +make e2e-test test=TestMsgSubmitTx_SuccessfulTransfer +``` + > Note: sometimes it can be useful to make changes to [ibctest](https://github.com/strangelove-ventures/interchaintest) when running tests locally. In order to do this, add the following line to e2e/go.mod diff --git a/e2e/scripts/run-e2e.sh b/e2e/scripts/run-e2e.sh index 26e8bb9102c..122b22794c1 100755 --- a/e2e/scripts/run-e2e.sh +++ b/e2e/scripts/run-e2e.sh @@ -1,12 +1,28 @@ #!/bin/bash -set -euo pipefail +set -eo pipefail -ENTRY_POINT="${1}" -TEST="${2}" +TEST="${1}" +ENTRY_POINT="${2:-}" export CHAIN_A_TAG="${CHAIN_A_TAG:-main}" export CHAIN_IMAGE="${CHAIN_IMAGE:-ghcr.io/cosmos/ibc-go-simd}" export CHAIN_BINARY="${CHAIN_BINARY:-simd}" -go test -v ./tests/... --run ${ENTRY_POINT} -testify.m ^${TEST}$ +# if jq is installed, we can automatically determine the test entrypoint. +if command -v jq > /dev/null; then + cd .. + ENTRY_POINT="$(go run -mod=readonly cmd/build_test_matrix/main.go | jq -r --arg TEST "${TEST}" '.include[] | select( .test == $TEST) | .entrypoint')" + cd - > /dev/null +fi + + +# find the name of the file that has this test in it. +test_file="$(grep --recursive --files-with-matches './' -e "${TEST}()")" + +# we run the test on the directory as specific files may reference types in other files but within the package. +test_dir="$(dirname $test_file)" + +# run the test file directly, this allows log output to be streamed directly in the terminal sessions +# without needed to wait for the test to finish. +go test -v "${test_dir}" --run ${ENTRY_POINT} -testify.m ^${TEST}$