Skip to content

Device test scripts not Python 3 compatable #6660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
6 tasks done
johnm545 opened this issue Oct 22, 2019 · 2 comments · Fixed by #6670
Closed
6 tasks done

Device test scripts not Python 3 compatable #6660

johnm545 opened this issue Oct 22, 2019 · 2 comments · Fixed by #6670
Assignees

Comments

@johnm545
Copy link
Contributor

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ESP-12E
  • Core Version: latest git
  • Development Env: Arduino IDE
  • Operating System: Ubuntu on WSL

Settings in IDE

  • Module: NodeMCU
  • Flash Mode: [qio|dio|other]
  • Flash Size: 4MB
  • lwip Variant: |v2 Lower Memory
  • Reset Method: [ck|nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz
  • Upload Using: Serial
  • Upload Speed: [115200|

Problem Description

The on-device test scripts are not working since #6378 due to some Python 3 incompatibilities

But I went down the road of trying to get them working with python 3 and found a few problems which were easily fixed:
Poster lib not python 3 compatible: use poster3 instead
Some of the usual python 2-3 dramas, bytes/strings, print statements, urllib imports

I can't, however, see an easy fix to the below, short of hacking the xmerge.py file (getting rid of the encode() on line 68 does the job). It looks like xunitmerge is a bit broken with python3.

I can post a WIP of what I've done so far if someone wants to take a crack at fixing it.

:/usr/share/arduino-1.8.9/hardware/esp8266com/esp8266/tests/device$ make test_report
make[1]: Entering directory '/usr/share/arduino-1.8.9/hardware/esp8266com/esp8266/tests/device/libraries/BSTest'
make[1]: 'virtualenv' is up to date.
make[1]: Leaving directory '/usr/share/arduino-1.8.9/hardware/esp8266com/esp8266/tests/device/libraries/BSTest'
Traceback (most recent call last):
  File "libraries/BSTest/virtualenv/bin/xunitmerge", line 26, in <module>
    merge_xunit(args.report, args.output)
  File "/usr/share/arduino-1.8.9/hardware/esp8266com/esp8266/tests/device/libraries/BSTest/virtualenv/lib/python3.6/site-packages/xunitmerge/xmerge.py", line 130, in merge_xunit
    merged.write(output, encoding='utf-8', xml_declaration=True)
  File "/usr/lib/python3.6/xml/etree/ElementTree.py", line 776, in write
    short_empty_elements=short_empty_elements)
  File "/usr/share/arduino-1.8.9/hardware/esp8266com/esp8266/tests/device/libraries/BSTest/virtualenv/lib/python3.6/site-packages/xunitmerge/xmerge.py", line 70, in _serialize_xml
    original_serialize(write, elem, *args, **kwargs)
  File "/usr/lib/python3.6/xml/etree/ElementTree.py", line 941, in _serialize_xml
    short_empty_elements=short_empty_elements)
  File "/usr/share/arduino-1.8.9/hardware/esp8266com/esp8266/tests/device/libraries/BSTest/virtualenv/lib/python3.6/site-packages/xunitmerge/xmerge.py", line 70, in _serialize_xml
    original_serialize(write, elem, *args, **kwargs)
  File "/usr/lib/python3.6/xml/etree/ElementTree.py", line 941, in _serialize_xml
    short_empty_elements=short_empty_elements)
  File "/usr/share/arduino-1.8.9/hardware/esp8266com/esp8266/tests/device/libraries/BSTest/virtualenv/lib/python3.6/site-packages/xunitmerge/xmerge.py", line 70, in _serialize_xml
    original_serialize(write, elem, *args, **kwargs)
  File "/usr/lib/python3.6/xml/etree/ElementTree.py", line 941, in _serialize_xml
    short_empty_elements=short_empty_elements)
  File "/usr/share/arduino-1.8.9/hardware/esp8266com/esp8266/tests/device/libraries/BSTest/virtualenv/lib/python3.6/site-packages/xunitmerge/xmerge.py", line 68, in _serialize_xml
    ).encode('utf-8'))
TypeError: write() argument must be str, not bytes
Makefile:107: recipe for target 'test_report.xml' failed
make: *** [test_report.xml] Error 1
@earlephilhower earlephilhower self-assigned this Oct 26, 2019
@earlephilhower
Copy link
Collaborator

I broke it, so I'll try and fix it.

Separately, we're glad to see people running device tests outside the core team!

earlephilhower added a commit to earlephilhower/Arduino that referenced this issue Oct 26, 2019
The Python3 migration didn't include fixes for local scripts in the
device test tree.

Fatal build and run Python errors fixed.

The last update to xunitmerge is ~5 years ago, so it looks to be
unsupported now.

Use a local copy of the two components to allow patching to work with
Python3.

The serial test seems to send garbage chars (non-ASCII/etc.), so use a
codepage 437 which supports all 255 chars.

Fixes: esp8266#6660
@earlephilhower
Copy link
Collaborator

Can you please take a look at #6670, @johnm545, and see if you had a better way of handling the changes than I came up with?

earlephilhower added a commit that referenced this issue Oct 26, 2019
* Fix Python3 errors for device tests

The Python3 migration didn't include fixes for local scripts in the
device test tree.

Fatal build and run Python errors fixed.

The last update to xunitmerge is ~5 years ago, so it looks to be
unsupported now.

Use a local copy of the two components to allow patching to work with
Python3.

The serial test seems to send garbage chars (non-ASCII/etc.), so use a
codepage 437 which supports all 255 chars.

Fixes: #6660

* Run tests at 160MHz (req'd for some SSL connections)

* Fix debuglevel options for builder

* Fix Python3 interpreter path in xunitmerge

* Remove virtualenv on "make clean"

* Add appropriate attribution, license to xunitmerge

Add like to the original sources with the author's license to the
copied/fixed xunitmerge files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants