asadmansr / android-test-report-action

GitHub Action that prints Android test reports.
https://github.com/marketplace/actions/android-test-report-action
37 stars 8 forks source link

Report action returns error when filename has space #13

Open wottrichwarren opened 3 years ago

wottrichwarren commented 3 years ago

I tried to read a report that the name is TEST-Pixel_2_API_27(AVD) - 8.1.0-featureauth-debugAndroidTest.xml but script not identify space and trying to get slots TEST-Pixel_2_API_27(AVD), - and 8.1.0-featureauth-debugAndroidTest.xml. To fix it i use a script to rename my test archive and remove spaces: find . -depth -name "TEST-*.xml" -exec sh -c 'f="{}"; mv -- "$f" "${f// /}"' \;

With this you could try to read instrumental test reports too.

Log error:

Traceback (most recent call last):
  File "/usr/bin/extractReport.py", line 51, in <module>
./featurehelp/connected/flavors/debugAndroidTest/TEST-test(AVD)
    main()

  File "/usr/bin/extractReport.py", line 48, in main
    parseXML(path)
  File "/usr/bin/extractReport.py", line 7, in parseXML
    tree = ET.parse(xmlfile)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1182, in parse
    tree.parse(source, parser)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 647, in parse
    source = open(source, "rb")
IOError: [Errno 2] No such file or directory: './featurehelp/connected/flavors/debugAndroidTest/TEST-test(AVD)'

Traceback (most recent call last):
-
  File "/usr/bin/extractReport.py", line 51, in <module>

    main()
  File "/usr/bin/extractReport.py", line 48, in main
    parseXML(path)
  File "/usr/bin/extractReport.py", line 7, in parseXML
    tree = ET.parse(xmlfile)

  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1182, in parse
    tree.parse(source, parser)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 647, in parse
    source = open(source, "rb")
IOError: [Errno 2] No such file or directory: '-'
Traceback (most recent call last):
  File "/usr/bin/extractReport.py", line 51, in <module>
    main()
  File "/usr/bin/extractReport.py", line 48, in main
    parseXML(path)
  File "/usr/bin/extractReport.py", line 7, in parseXML
    tree = ET.parse(xmlfile)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1182, in parse
    tree.parse(source, parser)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 647, in parse
    source = open(source, "rb")
IOError: [Errno 2] No such file or directory: '10-featurehelp-debugAndroidTest.xml'
10-featurehelp-debugAndroidTest.xml

After fix:

./featurehelp/connected/flavors/debugAndroidTest/TEST-test(AVD)-10-featurehelp-debugAndroidTest.xml

Tests           4
Errors          0
Name            br.com.xxxx.featurehelp.HelpCenterFragmentTest
Timestamp       2021-05-17T16:57:43
Hostname        localhost
Skipped         0
Time            44.686
Failures        0

My action:

name: Run instrumental tests

on:
  push:
    branches: [ feature/github_action_instrumental_test ]

jobs:
  test:
    runs-on: macos-latest
    strategy:
      matrix:
        api-level: [29]
        target: [default]
        devices: [ Nexus 6 ]
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Set Java 11
        uses: actions/setup-java@v1
        with:
          java-version: 11

      - name: Run Emulator with Instrumental Test - connectedAndroidTest script
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ matrix.api-level }}
          target: ${{ matrix.target }}
          arch: x86_64
          profile: ${{ matrix.devices }}
          script: ./gradlew cAT --stacktrace
        env:
          GIT_USER_ID: ${{ secrets.GIT_USER_ID }}
          GIT_USER_PAT: ${{ secrets.GIT_USER_PAT }}

      - name: Upload Test Reports Folder
        uses: actions/upload-artifact@v2
        if: ${{ always() }}
        with:
          name: reports
          path: reports

      - name: Change Result Folder Name
        run: | 
          find . -depth -name "TEST-*.xml" -exec sh -c 'f="{}"; mv -- "$f" "${f// /}"' \;

      - name: Upload Test Results Folder
        uses: actions/upload-artifact@v2
        if: ${{ always() }}
        with:
          name: results
          path: results

  results:
    runs-on: ubuntu-latest
    needs: test
    if: ${{ always() }}
    steps:
      - name: Download Test Results Folder
        uses: actions/download-artifact@v2
        with:
          name: results

      - name: Android Test Report
        uses: asadmansr/android-test-report-action@v1.2.0