Skip to content
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

Handle recent python versions in device tests #8623

Merged
merged 2 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tests/device/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ $(TEST_LIST):
ifeq ("$(MOCK)", "1")
@echo Compiling $(notdir $@)
(cd ../host; make D=$(V) ULIBDIRS=../device/libraries/BSTest ../device/$(@:%.ino=%))
$(SILENT)source $(BS_DIR)/virtualenv/bin/activate && \
$(PYTHON) $(BS_DIR)/runner.py \
$(SILENT)$(BS_DIR)/virtualenv/bin/python \
$(BS_DIR)/runner.py \
$(RUNNER_DEBUG_FLAG) \
-e "$(ESP8266_CORE_PATH)/tests/host/bin/$(@:%.ino=%)" \
-n $(basename $(notdir $@)) \
Expand Down Expand Up @@ -120,8 +120,8 @@ ifneq ("$(NO_RUN)","1")
--port $(UPLOAD_PORT) \
--baud $(UPLOAD_BAUD) \
read_flash_status $(REDIR) # reset
$(SILENT)source $(BS_DIR)/virtualenv/bin/activate && \
$(PYTHON) $(BS_DIR)/runner.py \
$(SILENT)$(BS_DIR)/virtualenv/bin/python \
$(BS_DIR)/runner.py \
$(RUNNER_DEBUG_FLAG) \
-p $(UPLOAD_PORT) \
-n $(basename $(notdir $@)) \
Expand Down
6 changes: 3 additions & 3 deletions tests/device/libraries/BSTest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ clean:
rm -rf $(TEST_EXECUTABLE)

$(PYTHON_ENV_DIR):
virtualenv --python=$(PYTHON) --no-site-packages $(PYTHON_ENV_DIR)
. $(PYTHON_ENV_DIR)/bin/activate && pip install -r requirements.txt
$(PYTHON) -mvenv $(PYTHON_ENV_DIR)
$(PYTHON_ENV_DIR)/bin/pip install -r requirements.txt

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
g++ -std=c++11 -Isrc -o $@ test/test.cpp
Expand Down
10 changes: 6 additions & 4 deletions tests/device/libraries/BSTest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import argparse
import serial
import subprocess
import imp

from importlib.machinery import SourceFileLoader

try:
from configparser import ConfigParser
except:
Expand Down Expand Up @@ -278,12 +280,12 @@ def main():
if args.env_file is not None:
cfg = ConfigParser()
cfg.optionxform = str
with args.env_file as fp:
cfg.readfp(fp)
with args.env_file as env:
cfg.read_file(env)
env_vars = cfg.items('global')
mocks = {}
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
with spawn_func(spawn_arg) as sp:
ts = run_tests(sp, name, mocks, env_vars)
Expand Down