From 65714b45556f7caabea88064bee36ece2f586c72 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 4 Oct 2023 18:11:42 +0200 Subject: [PATCH] better verbosity for integration tests --- .forgejo/workflows/integration.yml | 40 ++++++++++++++++++---------- testdata/example-if-fail/run.sh | 5 +--- testdata/example-pull-request/run.sh | 2 -- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.forgejo/workflows/integration.yml b/.forgejo/workflows/integration.yml index 883625b..798e275 100644 --- a/.forgejo/workflows/integration.yml +++ b/.forgejo/workflows/integration.yml @@ -16,8 +16,8 @@ jobs: steps: - uses: actions/checkout@v3 - if: matrix.info.tests != 'none' + shell: bash run: | - set -x LXC_IP_PREFIX=10.0.10 ./forgejo-dependencies.sh export PATH=$(pwd):$PATH forgejo.sh setup root admin1234 ${{ matrix.info.image }} ${{ matrix.info.version }} @@ -32,29 +32,41 @@ jobs: forgejo-runner.sh setup export FORGEJO_RUNNER_LOGS=forgejo-runner.log - for example in ${{ matrix.info.tests }} ; do + echo "============================ demo ===================" + ./forgejo-test-helper.sh run_workflow testdata/demo http://root:admin1234@$(cat forgejo-ip):3000 root demo setup-forgejo $(cat forgejo-token) > /tmp/output + grep '^sha=' /tmp/output + + function run() { + local example=$1 + export example export EXAMPLE_DIR=$(pwd)/testdata/example-$example if test -f $EXAMPLE_DIR/setup.sh ; then - $EXAMPLE_DIR/setup.sh + echo "============================ SETUP example-$example ===================" + bash -ex $EXAMPLE_DIR/setup.sh || return 1 fi - echo "============================ BEGIN example-$example ===================" if test -f $EXAMPLE_DIR/run.sh ; then - $EXAMPLE_DIR/run.sh + echo "============================ RUN example-$example ===================" + bash -ex $EXAMPLE_DIR/run.sh || return 1 else - if ! forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token) >& /tmp/run.out ; then - cat /tmp/run.out - false - fi + forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token) || return 1 fi - echo "============================ END example-$example ===================" if test -f $EXAMPLE_DIR/teardown.sh ; then - $EXAMPLE_DIR/teardown.sh + echo "============================ TEARDOWN example-$example ===================" + bash -ex $EXAMPLE_DIR/teardown.sh || return 1 fi + } + + for example in ${{ matrix.info.tests }} ; do + echo "============================ BEGIN example-$example ===================" + if ! time run $example >& /tmp/run.out ; then + cat /tmp/run.out + echo "============================ FAIL example-$example ===================" + sleep 5 # hack for Forgejo v1.21 to workaround a but by which the last lines of the output are moved to the next step + false + fi + echo "============================ END example-$example ===================" done - echo "============================ demo ===================" - ./forgejo-test-helper.sh run_workflow testdata/demo http://root:admin1234@$(cat forgejo-ip):3000 root demo setup-forgejo $(cat forgejo-token) > /tmp/output - grep '^sha=' /tmp/output diff --git a/testdata/example-if-fail/run.sh b/testdata/example-if-fail/run.sh index a077ee2..7aff124 100755 --- a/testdata/example-if-fail/run.sh +++ b/testdata/example-if-fail/run.sh @@ -1,7 +1,4 @@ -if forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token) >& /tmp/run.out ; then - cat /tmp/run.out - false -fi +! forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token) grep --quiet 'IF TEST FAILURE' $FORGEJO_RUNNER_LOGS grep --quiet 'IF TEST ALWAYS' $FORGEJO_RUNNER_LOGS diff --git a/testdata/example-pull-request/run.sh b/testdata/example-pull-request/run.sh index 9bb119a..59022ff 100755 --- a/testdata/example-pull-request/run.sh +++ b/testdata/example-pull-request/run.sh @@ -1,5 +1,3 @@ -set -e - url=http://root:admin1234@$(cat forgejo-ip):3000 api=$url/api/v1 export d=/srv/example-pull-request