Skip to content

Commit

Permalink
Merge branch 'refactor_host_test' into 'master'
Browse files Browse the repository at this point in the history
refactor: convert host test to pytest

Closes IDF-8219

See merge request espressif/esp-idf-monitor!42
  • Loading branch information
dobairoland committed Nov 10, 2023
2 parents be54507 + 1a04d75 commit 9dc98c6
Show file tree
Hide file tree
Showing 16 changed files with 344 additions and 256 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# IDF monitor test
test/outputs
test/host_test/outputs
test/test_apps/*/build
test/test_apps/**/build_*/
test/test_apps/**/build_*_*/
test/test_apps/**/sdkconfig
test/test_apps/**/sdkconfig.old
Expand Down
16 changes: 7 additions & 9 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ workflow:
- build
- internet
before_script:
- pip install -e .[dev] --prefer-binary
- pip install -e .[dev,host_test] --prefer-binary

.build_template:
stage: build
Expand All @@ -68,7 +68,7 @@ workflow:
#
.before_script_build_jobs:
before_script:
- pip install .[dev,test] --prefer-binary
- pip install .[dev,target_test] --prefer-binary

.build_pytest_template:
stage: build
Expand Down Expand Up @@ -113,14 +113,10 @@ workflow:
build_idf_latest:
extends: .build_pytest_template
image: espressif/idf:latest
variables:
TEST_TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 esp32h2"

build_idf_v5.1:
extends: .build_pytest_template
image: espressif/idf:release-v5.1
variables:
TEST_TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3"
# ------------------------------------------------------------------------------------------------------


Expand Down Expand Up @@ -149,14 +145,16 @@ test_idf_monitor:
# save artifacts always in order to access results which were retried without consequent failure
when: always
paths:
- test/outputs/*
- test/host_test/outputs/*
expire_in: 1 week
script:
- cd test
- ./run_test_idf_monitor.py
- cd test/host_test
# don't use the configuration file
- pytest -c /dev/null test_monitor.py

.before_script_pytest_jobs:
before_script:
- pip install .[target_test] --prefer-binary
# Get ESP-IDF and install the tools (such as addr2line). We don't need the whole ESP-IDF, but it is easier for downloading required tools.
# Dowloading just the tools would require recreating the directory structure and downloading dependencies one by one.
- cd /opt/
Expand Down
2 changes: 1 addition & 1 deletion esp_idf_monitor/idf_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __init__(

if isinstance(self, SerialMonitor):
# testing hook: when running tests, input from console is ignored
socket_test_mode = serial_instance.port.startswith('socket://') and os.environ.get('ESP_IDF_MONITOR_TEST') == '1'
socket_test_mode = os.environ.get('ESP_IDF_MONITOR_TEST') == '1'
self.serial = serial_instance
self.serial_reader = SerialReader(self.serial, self.event_queue, reset) # type: Reader

Expand Down
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,20 @@ def get_long_description():
'ide': [
'websocket-client'
],
'test': [
'target_test': [
'SimpleWebSocketServer',
'pytest',
'pytest_embedded',
'pytest_embedded_idf',
'pytest_embedded_serial_esp',
'idf_build_apps~=1.0.1',
'idf-component-manager',
]
],
'host_test': [
'pytest',
'pytest-rerunfailures',
'esptool', # for RFC2217 script
],
},
keywords=['espressif', 'embedded', 'monitor', 'serial'],
classifiers=[
Expand Down
6 changes: 0 additions & 6 deletions test/README.md

This file was deleted.

12 changes: 12 additions & 0 deletions test/host_test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
out_dir = ''


def pytest_addoption(parser):
parser.addoption('--output', action='store', default='./outputs/', help='Output directory for writing STDOUT and STDERR from tests')


def pytest_configure(config):
global out_dir
out_dir = config.getoption('--output')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 9dc98c6

Please sign in to comment.