From 4d161c69fab1068db0f6d58944b129ab5199d40c Mon Sep 17 00:00:00 2001 From: Bruno Goncalves Date: Apr 20 2018 08:45:14 +0000 Subject: append test status to test case log --- diff --git a/roles/standard-test-basic/tasks/main.yml b/roles/standard-test-basic/tasks/main.yml index ff9c555..354ac99 100644 --- a/roles/standard-test-basic/tasks/main.yml +++ b/roles/standard-test-basic/tasks/main.yml @@ -15,7 +15,8 @@ echo "FAIL: Does not know how to run $TEST" >> {{ remote_artifacts }}/test.log exit fi - logfile={{ remote_artifacts }}/test.$(echo $TEST | sed -e 's/\//-/g').log + log_file_name=$(echo $TEST | sed -e 's/\//-/g').log + logfile={{ remote_artifacts }}/${log_file_name} exec 2>>$logfile 1>>$logfile cd $TEST_DIR #if command is a file make it executable @@ -23,13 +24,15 @@ if [ -f "$cmd" ]; then chmod 0775 "$cmd" fi + status="FAIL" #execute the test eval $TEST_CMD if [ $? -eq 0 ]; then - echo "PASS $TEST" >> {{ remote_artifacts }}/test.log - else - echo "FAIL $TEST" >> {{ remote_artifacts }}/test.log + status="PASS" fi + echo "${status} $TEST" >> {{ remote_artifacts }}/test.log + # Add test status as prefix to test case log + mv ${logfile} {{ remote_artifacts }}/${status}_${log_file_name} environment: #Allow to use tests as a simple string which means the test is expected #to be in a directory with same name and test script `runtest.sh` diff --git a/roles/standard-test-beakerlib/tasks/main.yml b/roles/standard-test-beakerlib/tasks/main.yml index 92222ca..97b1bb2 100644 --- a/roles/standard-test-beakerlib/tasks/main.yml +++ b/roles/standard-test-beakerlib/tasks/main.yml @@ -81,7 +81,7 @@ shell: | export OUTPUTFILE=/dev/stdout TEST={{ item }} export PATH="$PATH:{{ tenv_workdir }}" - logfile={{ remote_artifacts }}/test.$(echo {{ item }} | sed -e 's/\//-/g').log + logfile={{ remote_artifacts }}/$(echo {{ item }} | sed -e 's/\//-/g').log exec 2>>$logfile 1>>$logfile cd {{ tenv_workdir }} if [ -f {{ item }} ]; then @@ -105,18 +105,22 @@ always: - name: Make the master tests summary log artifact shell: | - logfile={{ remote_artifacts }}/test.$(echo {{ item }} | sed -e 's/\//-/g').log + log_file_name=$(echo {{ item }} | sed -e 's/\//-/g').log + logfile={{ remote_artifacts }}/${log_file_name} + status="FAIL" if grep -q '\[ *FAIL *\]' "$logfile"; then - echo "FAIL {{ item }}" >> {{ remote_artifacts }}/test.log + status="FAIL" elif grep -q '\[ *PASS *\]' "$logfile"; then - echo "PASS {{ item }}" >> {{ remote_artifacts }}/test.log + status="PASS" elif grep -q FAIL "$logfile"; then - echo "FAIL {{ item }}" >> {{ remote_artifacts }}/test.log + status="FAIL" elif grep -q PASS "$logfile"; then - echo "PASS {{ item }}" >> {{ remote_artifacts }}/test.log + status="PASS" else - echo "UNKNOWN {{ item }}" >> {{ remote_artifacts }}/test.log + status="FAIL" fi + echo "${status} {{ item }}" >> {{ remote_artifacts }}/test.log + mv ${logfile} {{ remote_artifacts }}/${status}_${log_file_name} with_items: - "{{ tests }}"