mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Fix python warnings and update device tests runner (#8623)
Update soon-to-be deprecated code in the runner.py https://docs.python.org/3/library/imp.html is deprecated since 3.4, will be removed in 3.12 https://docs.python.org/3/library/configparser.html readfp() is replaced with read_file() since 3.2, will be removed in 3.12 Use venv instead of virtualenv. We don't really use any of the extended features, and might as well simplify installation requirements. virtualenv/bin/python can execute runner.py inside of venv, no need to activate beforehand.
This commit is contained in:
parent
a2c8a63360
commit
601da8e933
@ -65,8 +65,8 @@ $(TEST_LIST):
|
|||||||
ifeq ("$(MOCK)", "1")
|
ifeq ("$(MOCK)", "1")
|
||||||
@echo Compiling $(notdir $@)
|
@echo Compiling $(notdir $@)
|
||||||
(cd ../host; make D=$(V) ULIBDIRS=../device/libraries/BSTest ../device/$(@:%.ino=%))
|
(cd ../host; make D=$(V) ULIBDIRS=../device/libraries/BSTest ../device/$(@:%.ino=%))
|
||||||
$(SILENT)source $(BS_DIR)/virtualenv/bin/activate && \
|
$(SILENT)$(BS_DIR)/virtualenv/bin/python \
|
||||||
$(PYTHON) $(BS_DIR)/runner.py \
|
$(BS_DIR)/runner.py \
|
||||||
$(RUNNER_DEBUG_FLAG) \
|
$(RUNNER_DEBUG_FLAG) \
|
||||||
-e "$(ESP8266_CORE_PATH)/tests/host/bin/$(@:%.ino=%)" \
|
-e "$(ESP8266_CORE_PATH)/tests/host/bin/$(@:%.ino=%)" \
|
||||||
-n $(basename $(notdir $@)) \
|
-n $(basename $(notdir $@)) \
|
||||||
@ -120,8 +120,8 @@ ifneq ("$(NO_RUN)","1")
|
|||||||
--port $(UPLOAD_PORT) \
|
--port $(UPLOAD_PORT) \
|
||||||
--baud $(UPLOAD_BAUD) \
|
--baud $(UPLOAD_BAUD) \
|
||||||
read_flash_status $(REDIR) # reset
|
read_flash_status $(REDIR) # reset
|
||||||
$(SILENT)source $(BS_DIR)/virtualenv/bin/activate && \
|
$(SILENT)$(BS_DIR)/virtualenv/bin/python \
|
||||||
$(PYTHON) $(BS_DIR)/runner.py \
|
$(BS_DIR)/runner.py \
|
||||||
$(RUNNER_DEBUG_FLAG) \
|
$(RUNNER_DEBUG_FLAG) \
|
||||||
-p $(UPLOAD_PORT) \
|
-p $(UPLOAD_PORT) \
|
||||||
-n $(basename $(notdir $@)) \
|
-n $(basename $(notdir $@)) \
|
||||||
|
@ -11,11 +11,11 @@ clean:
|
|||||||
rm -rf $(TEST_EXECUTABLE)
|
rm -rf $(TEST_EXECUTABLE)
|
||||||
|
|
||||||
$(PYTHON_ENV_DIR):
|
$(PYTHON_ENV_DIR):
|
||||||
virtualenv --python=$(PYTHON) --no-site-packages $(PYTHON_ENV_DIR)
|
$(PYTHON) -mvenv $(PYTHON_ENV_DIR)
|
||||||
. $(PYTHON_ENV_DIR)/bin/activate && pip install -r requirements.txt
|
$(PYTHON_ENV_DIR)/bin/pip install -r requirements.txt
|
||||||
|
|
||||||
test: $(TEST_EXECUTABLE) $(PYTHON_ENV_DIR)
|
test: $(TEST_EXECUTABLE) $(PYTHON_ENV_DIR)
|
||||||
. $(PYTHON_ENV_DIR)/bin/activate && $(PYTHON) runner.py -e $(TEST_EXECUTABLE) -m test/test.py
|
$(PYTHON_ENV_DIR)/bin/python runner.py -e $(TEST_EXECUTABLE) -m test/test.py
|
||||||
|
|
||||||
$(TEST_EXECUTABLE): test/test.cpp
|
$(TEST_EXECUTABLE): test/test.cpp
|
||||||
g++ -std=c++11 -Isrc -o $@ test/test.cpp
|
g++ -std=c++11 -Isrc -o $@ test/test.cpp
|
||||||
|
@ -8,7 +8,9 @@ import time
|
|||||||
import argparse
|
import argparse
|
||||||
import serial
|
import serial
|
||||||
import subprocess
|
import subprocess
|
||||||
import imp
|
|
||||||
|
from importlib.machinery import SourceFileLoader
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
except:
|
except:
|
||||||
@ -278,12 +280,12 @@ def main():
|
|||||||
if args.env_file is not None:
|
if args.env_file is not None:
|
||||||
cfg = ConfigParser()
|
cfg = ConfigParser()
|
||||||
cfg.optionxform = str
|
cfg.optionxform = str
|
||||||
with args.env_file as fp:
|
with args.env_file as env:
|
||||||
cfg.readfp(fp)
|
cfg.read_file(env)
|
||||||
env_vars = cfg.items('global')
|
env_vars = cfg.items('global')
|
||||||
mocks = {}
|
mocks = {}
|
||||||
if args.mock is not None:
|
if args.mock is not None:
|
||||||
mocks_mod = imp.load_source('mocks', args.mock)
|
mocks_mod = SourceFileLoader('mocks', args.mock).load_module()
|
||||||
mocks = mock_decorators.env
|
mocks = mock_decorators.env
|
||||||
with spawn_func(spawn_arg) as sp:
|
with spawn_func(spawn_arg) as sp:
|
||||||
ts = run_tests(sp, name, mocks, env_vars)
|
ts = run_tests(sp, name, mocks, env_vars)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user