From cf1a86ed13c3041e780fbd3cb578c605a24c3886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Budiseli=C4=87?= Date: Thu, 15 Jun 2023 23:10:52 +0200 Subject: [PATCH] Refactor tests/integration/run.sh (#1016) --- .github/workflows/diff.yaml | 17 +------- .github/workflows/release_centos8.yaml | 17 +------- .github/workflows/release_debian10.yaml | 17 +------- .github/workflows/release_ubuntu2004.yaml | 17 +------- tests/integration/audit/.gitignore | 1 + tests/integration/run.sh | 47 +++++++++++++++++++++++ 6 files changed, 52 insertions(+), 64 deletions(-) create mode 100644 tests/integration/audit/.gitignore create mode 100755 tests/integration/run.sh diff --git a/.github/workflows/diff.yaml b/.github/workflows/diff.yaml index 170f91edf..f5814d958 100644 --- a/.github/workflows/diff.yaml +++ b/.github/workflows/diff.yaml @@ -196,22 +196,7 @@ jobs: - name: Run integration tests run: | - cd tests/integration - for name in *; do - if [ ! -d $name ]; then continue; fi - pushd $name >/dev/null - echo "Running: $name" - if [ -x prepare.sh ]; then - ./prepare.sh - fi - if [ -x runner.py ]; then - ./runner.py - elif [ -x runner.sh ]; then - ./runner.sh - fi - echo - popd >/dev/null - done + tests/integration/run.sh - name: Run cppcheck and clang-format run: | diff --git a/.github/workflows/release_centos8.yaml b/.github/workflows/release_centos8.yaml index ae5c176d0..a80d72a0e 100644 --- a/.github/workflows/release_centos8.yaml +++ b/.github/workflows/release_centos8.yaml @@ -146,22 +146,7 @@ jobs: - name: Run integration tests run: | - cd tests/integration - for name in *; do - if [ ! -d $name ]; then continue; fi - pushd $name >/dev/null - echo "Running: $name" - if [ -x prepare.sh ]; then - ./prepare.sh - fi - if [ -x runner.py ]; then - ./runner.py - elif [ -x runner.sh ]; then - ./runner.sh - fi - echo - popd >/dev/null - done + tests/integration/run.sh - name: Run cppcheck and clang-format run: | diff --git a/.github/workflows/release_debian10.yaml b/.github/workflows/release_debian10.yaml index 2bcd2560e..faf868e21 100644 --- a/.github/workflows/release_debian10.yaml +++ b/.github/workflows/release_debian10.yaml @@ -146,22 +146,7 @@ jobs: - name: Run integration tests run: | - cd tests/integration - for name in *; do - if [ ! -d $name ]; then continue; fi - pushd $name >/dev/null - echo "Running: $name" - if [ -x prepare.sh ]; then - ./prepare.sh - fi - if [ -x runner.py ]; then - ./runner.py - elif [ -x runner.sh ]; then - ./runner.sh - fi - echo - popd >/dev/null - done + tests/integration/run.sh - name: Run cppcheck and clang-format run: | diff --git a/.github/workflows/release_ubuntu2004.yaml b/.github/workflows/release_ubuntu2004.yaml index b92ddf58e..18b9a8326 100644 --- a/.github/workflows/release_ubuntu2004.yaml +++ b/.github/workflows/release_ubuntu2004.yaml @@ -146,22 +146,7 @@ jobs: - name: Run integration tests run: | - cd tests/integration - for name in *; do - if [ ! -d $name ]; then continue; fi - pushd $name >/dev/null - echo "Running: $name" - if [ -x prepare.sh ]; then - ./prepare.sh - fi - if [ -x runner.py ]; then - ./runner.py - elif [ -x runner.sh ]; then - ./runner.sh - fi - echo - popd >/dev/null - done + tests/integration/run.sh - name: Run cppcheck and clang-format run: | diff --git a/tests/integration/audit/.gitignore b/tests/integration/audit/.gitignore new file mode 100644 index 000000000..397b4a762 --- /dev/null +++ b/tests/integration/audit/.gitignore @@ -0,0 +1 @@ +*.log diff --git a/tests/integration/run.sh b/tests/integration/run.sh new file mode 100755 index 000000000..07d54cce8 --- /dev/null +++ b/tests/integration/run.sh @@ -0,0 +1,47 @@ +#!/bin/bash -e +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +print_help() { + echo -e "$0 => run all under tests/integration" + echo -e "$0 folder_name => run single test under tests/integration" + exit 1 +} + +test_one() { + cd "$DIR" + integration_test_folder_name="$1" + pushd "$integration_test_folder_name" >/dev/null + echo "Running: $integration_test_folder_name" + if [ -x prepare.sh ]; then + ./prepare.sh + fi + if [ -x runner.py ]; then + ./runner.py + elif [ -x runner.sh ]; then + ./runner.sh + fi + echo + popd >/dev/null +} + +test_all() { + cd "$DIR" + for name in *; do + if [ ! -d "$name" ]; then continue; fi + test_one "$name" + done +} + +if [ "$#" -eq 0 ]; then + test_all +else + if [ "$#" -gt 1 ]; then + print_help + else + if [ -d "$DIR/$1" ]; then + test_one "$1" + else + print_help + fi + fi +fi