#181 append test status to test case log
Merged 6 years ago by astepano. Opened 6 years ago by bgoncalv.
bgoncalv/standard-test-roles result-prefix  into  master

@@ -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`

@@ -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 }}"

  

related to https://pagure.io/standard-test-roles/issue/177

note that on beakerlib I've replaced UNKNOWN by FAIL.

If we want to continue to have UNKNOWN I think we should update shell: grep "^FAIL" {{ remote_artifacts }}/test.log to also grep for UNKNOWN result.

Hi, I see at least 2 lines with code: $(echo $TEST | sed -e 's/\//-/g').log

Could we introduce log_file_name = $(echo $TEST | sed -e 's/\//-/g').log

It will improve readibility

rebased onto 4d161c6

6 years ago

Thanks, I've updated it.

Commit 039bef9 fixes this pull-request

Pull-Request has been merged by astepano

6 years ago

Pull-Request has been merged by astepano

6 years ago