-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mosq): Remove temp modification of IDF files
1 parent
2bd0f28
commit 741c894
Showing
3 changed files
with
54 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# ESP32 mosquitto tests | ||
|
||
Mosquitto component doesn't have any tests yet, but we upcycle IDF mqtt tests and run them with the current version of mosquitto. | ||
For that we need to update the IDF test project's `idf_component.yml` file to reference this actual version of mosquitto. | ||
We also need to update some pytest decorators to run only relevant test cases. See the [replacement](./replace_decorators.py) script. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: Unlicense OR CC0-1.0 | ||
|
||
# This script replaces the `@pytest` decorators in the test files | ||
# based on the value of the `config` parameter in the `@pytest` decorator. | ||
# to reuse mqtt test cases for mosquitto broker. | ||
|
||
import re | ||
import sys | ||
|
||
|
||
def replace_decorators(in_file: str, out_file: str) -> None: | ||
with open(in_file, 'r') as file: | ||
content = file.read() | ||
|
||
# we replace config decorators to differentiate between local mosquitto based tests | ||
pattern = r"@pytest\.mark\.parametrize\(\s*'config'\s*,\s*\[\s*'(.*?)'\s*\]\s*,.*\)" | ||
|
||
def replacement(match): | ||
config_value = match.group(1) | ||
if config_value == 'local_broker': | ||
return '@pytest.mark.test_mosquitto' | ||
else: | ||
return '@pytest.mark.test_mqtt' | ||
|
||
# Replace occurrences | ||
updated_content = re.sub(pattern, replacement, content) | ||
|
||
with open(out_file, 'w') as file: | ||
file.write(updated_content) | ||
|
||
|
||
# Main function to handle arguments | ||
if __name__ == '__main__': | ||
if len(sys.argv) != 3: | ||
print('Usage: python replace_decorators.py <in_file> <out_file>') | ||
sys.exit(1) | ||
|
||
in_file = sys.argv[1] | ||
out_file = sys.argv[2] | ||
replace_decorators(in_file, out_file) | ||
print(f'Replacements completed') |