diff --git a/tools/tiny-test-fw/App.py b/tools/ci/python_packages/tiny_test_fw/App.py similarity index 100% rename from tools/tiny-test-fw/App.py rename to tools/ci/python_packages/tiny_test_fw/App.py diff --git a/tools/tiny-test-fw/DUT.py b/tools/ci/python_packages/tiny_test_fw/DUT.py similarity index 100% rename from tools/tiny-test-fw/DUT.py rename to tools/ci/python_packages/tiny_test_fw/DUT.py diff --git a/tools/tiny-test-fw/Env.py b/tools/ci/python_packages/tiny_test_fw/Env.py similarity index 100% rename from tools/tiny-test-fw/Env.py rename to tools/ci/python_packages/tiny_test_fw/Env.py diff --git a/tools/tiny-test-fw/EnvConfig.py b/tools/ci/python_packages/tiny_test_fw/EnvConfig.py similarity index 100% rename from tools/tiny-test-fw/EnvConfig.py rename to tools/ci/python_packages/tiny_test_fw/EnvConfig.py diff --git a/tools/tiny-test-fw/EnvConfigTemplate.yml b/tools/ci/python_packages/tiny_test_fw/EnvConfigTemplate.yml similarity index 100% rename from tools/tiny-test-fw/EnvConfigTemplate.yml rename to tools/ci/python_packages/tiny_test_fw/EnvConfigTemplate.yml diff --git a/tools/tiny-test-fw/TinyFW.py b/tools/ci/python_packages/tiny_test_fw/TinyFW.py similarity index 100% rename from tools/tiny-test-fw/TinyFW.py rename to tools/ci/python_packages/tiny_test_fw/TinyFW.py diff --git a/tools/tiny-test-fw/Utility/CIAssignTest.py b/tools/ci/python_packages/tiny_test_fw/Utility/CIAssignTest.py similarity index 99% rename from tools/tiny-test-fw/Utility/CIAssignTest.py rename to tools/ci/python_packages/tiny_test_fw/Utility/CIAssignTest.py index ddc0ac1a6b..056d75f1c9 100644 --- a/tools/tiny-test-fw/Utility/CIAssignTest.py +++ b/tools/ci/python_packages/tiny_test_fw/Utility/CIAssignTest.py @@ -44,14 +44,13 @@ import re import json import yaml - -from Utility import (CaseConfig, SearchCases, GitlabCIJob, console_log) - try: from yaml import CLoader as Loader except ImportError: from yaml import Loader as Loader +from . import (CaseConfig, SearchCases, GitlabCIJob, console_log) + class Group(object): diff --git a/tools/tiny-test-fw/Utility/CaseConfig.py b/tools/ci/python_packages/tiny_test_fw/Utility/CaseConfig.py similarity index 97% rename from tools/tiny-test-fw/Utility/CaseConfig.py rename to tools/ci/python_packages/tiny_test_fw/Utility/CaseConfig.py index cf5d42f19c..8f373bce9f 100644 --- a/tools/tiny-test-fw/Utility/CaseConfig.py +++ b/tools/ci/python_packages/tiny_test_fw/Utility/CaseConfig.py @@ -20,7 +20,7 @@ Template Config File:: TestConfig: app: - path: Users/Test/TinyTestFW/IDF/IDFApp.py + package: ttfw_idf class: Example dut: path: @@ -38,22 +38,20 @@ Template Config File:: extra_data: some extra data passed to case with kwarg extra_data overwrite: # overwrite test configs app: - path: Users/Test/TinyTestFW/IDF/IDFApp.py + package: ttfw_idf class: Example - name: xxx """ +import importlib import yaml - -import TestCase - -from Utility import load_source - try: from yaml import CLoader as Loader except ImportError: from yaml import Loader as Loader +from . import TestCase + def _convert_to_lower_case_bytes(item): """ @@ -172,8 +170,7 @@ class Parser(object): """ output = dict() for key in overwrite: - path = overwrite[key]["path"] - module = load_source(path) + module = importlib.import_module(overwrite[key]["package"]) output[key] = module.__getattribute__(overwrite[key]["class"]) return output diff --git a/tools/tiny-test-fw/Utility/GitlabCIJob.py b/tools/ci/python_packages/tiny_test_fw/Utility/GitlabCIJob.py similarity index 100% rename from tools/tiny-test-fw/Utility/GitlabCIJob.py rename to tools/ci/python_packages/tiny_test_fw/Utility/GitlabCIJob.py diff --git a/tools/tiny-test-fw/Utility/SearchCases.py b/tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py similarity index 99% rename from tools/tiny-test-fw/Utility/SearchCases.py rename to tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py index 3ce98a07e1..b5e0762839 100644 --- a/tools/tiny-test-fw/Utility/SearchCases.py +++ b/tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py @@ -17,7 +17,8 @@ import os import fnmatch import types import copy -from Utility import load_source + +from . import load_source class Search(object): diff --git a/tools/tiny-test-fw/TestCase.py b/tools/ci/python_packages/tiny_test_fw/Utility/TestCase.py similarity index 100% rename from tools/tiny-test-fw/TestCase.py rename to tools/ci/python_packages/tiny_test_fw/Utility/TestCase.py diff --git a/tools/tiny-test-fw/Utility/__init__.py b/tools/ci/python_packages/tiny_test_fw/Utility/__init__.py similarity index 100% rename from tools/tiny-test-fw/Utility/__init__.py rename to tools/ci/python_packages/tiny_test_fw/Utility/__init__.py diff --git a/tools/tiny-test-fw/docs/_static/.keep b/tools/ci/python_packages/tiny_test_fw/__init__.py similarity index 100% rename from tools/tiny-test-fw/docs/_static/.keep rename to tools/ci/python_packages/tiny_test_fw/__init__.py diff --git a/tools/tiny-test-fw/Runner.py b/tools/ci/python_packages/tiny_test_fw/bin/Runner.py similarity index 96% rename from tools/tiny-test-fw/Runner.py rename to tools/ci/python_packages/tiny_test_fw/bin/Runner.py index ea124c1489..a233de64f5 100644 --- a/tools/tiny-test-fw/Runner.py +++ b/tools/ci/python_packages/tiny_test_fw/bin/Runner.py @@ -26,8 +26,8 @@ import sys import argparse import threading -import TinyFW -from Utility import SearchCases, CaseConfig +from tiny_test_fw import TinyFW +from tiny_test_fw.Utility import SearchCases, CaseConfig class Runner(threading.Thread): diff --git a/tools/tiny-test-fw/example.py b/tools/ci/python_packages/tiny_test_fw/bin/example.py similarity index 100% rename from tools/tiny-test-fw/example.py rename to tools/ci/python_packages/tiny_test_fw/bin/example.py diff --git a/tools/tiny-test-fw/docs/Makefile b/tools/ci/python_packages/tiny_test_fw/docs/Makefile similarity index 100% rename from tools/tiny-test-fw/docs/Makefile rename to tools/ci/python_packages/tiny_test_fw/docs/Makefile diff --git a/tools/ci/python_packages/tiny_test_fw/docs/_static/.keep b/tools/ci/python_packages/tiny_test_fw/docs/_static/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/tiny-test-fw/docs/conf.py b/tools/ci/python_packages/tiny_test_fw/docs/conf.py similarity index 100% rename from tools/tiny-test-fw/docs/conf.py rename to tools/ci/python_packages/tiny_test_fw/docs/conf.py diff --git a/tools/tiny-test-fw/docs/index.rst b/tools/ci/python_packages/tiny_test_fw/docs/index.rst similarity index 100% rename from tools/tiny-test-fw/docs/index.rst rename to tools/ci/python_packages/tiny_test_fw/docs/index.rst diff --git a/tools/tiny-test-fw/requirements.txt b/tools/ci/python_packages/tiny_test_fw/requirements.txt similarity index 100% rename from tools/tiny-test-fw/requirements.txt rename to tools/ci/python_packages/tiny_test_fw/requirements.txt diff --git a/tools/tiny-test-fw/CIAssignExampleTest.py b/tools/ci/python_packages/ttfw_idf/CIAssignExampleTest.py similarity index 79% rename from tools/tiny-test-fw/CIAssignExampleTest.py rename to tools/ci/python_packages/ttfw_idf/CIAssignExampleTest.py index bd6bdaf3b8..85beb1f086 100644 --- a/tools/tiny-test-fw/CIAssignExampleTest.py +++ b/tools/ci/python_packages/ttfw_idf/CIAssignExampleTest.py @@ -22,25 +22,29 @@ import sys import re import argparse -try: - from Utility.CIAssignTest import AssignTest -except ImportError: - test_fw_path = os.getenv("TEST_FW_PATH") - if test_fw_path: - sys.path.insert(0, test_fw_path) - from Utility.CIAssignTest import AssignTest - -from Utility.CIAssignTest import Group +import gitlab_api +from tiny_test_fw.Utility import CIAssignTest -class ExampleGroup(Group): +class ExampleGroup(CIAssignTest.Group): SORT_KEYS = CI_JOB_MATCH_KEYS = ["env_tag", "chip"] -class CIExampleAssignTest(AssignTest): +class CIExampleAssignTest(CIAssignTest.AssignTest): CI_TEST_JOB_PATTERN = re.compile(r"^example_test_.+") +class ArtifactFile(object): + def __init__(self, project_id, job_name, artifact_file_path): + self.gitlab_api = gitlab_api.Gitlab(project_id) + + def process(self): + pass + + def output(self): + pass + + if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("test_case", diff --git a/tools/tiny-test-fw/CIAssignUnitTest.py b/tools/ci/python_packages/ttfw_idf/CIAssignUnitTest.py similarity index 96% rename from tools/tiny-test-fw/CIAssignUnitTest.py rename to tools/ci/python_packages/ttfw_idf/CIAssignUnitTest.py index e3c96b4f98..ef84103bdb 100644 --- a/tools/tiny-test-fw/CIAssignUnitTest.py +++ b/tools/ci/python_packages/ttfw_idf/CIAssignUnitTest.py @@ -3,8 +3,6 @@ Command line tool to assign unit tests to CI test jobs. """ import re -import os -import sys import argparse import yaml @@ -14,13 +12,7 @@ try: except ImportError: from yaml import Loader as Loader -try: - from Utility import CIAssignTest -except ImportError: - test_fw_path = os.getenv("TEST_FW_PATH") - if test_fw_path: - sys.path.insert(0, test_fw_path) - from Utility import CIAssignTest +from tiny_test_fw.Utility import CIAssignTest class Group(CIAssignTest.Group): @@ -119,7 +111,7 @@ class Group(CIAssignTest.Group): if target: overwrite = { "dut": { - "path": "IDF/IDFDUT.py", + "package": "ttfw_idf", "class": self.DUT_CLS_NAME[target], } } diff --git a/tools/tiny-test-fw/IDF/IDFApp.py b/tools/ci/python_packages/ttfw_idf/IDFApp.py similarity index 99% rename from tools/tiny-test-fw/IDF/IDFApp.py rename to tools/ci/python_packages/ttfw_idf/IDFApp.py index 0018f7bef8..eff8c14584 100644 --- a/tools/tiny-test-fw/IDF/IDFApp.py +++ b/tools/ci/python_packages/ttfw_idf/IDFApp.py @@ -17,7 +17,7 @@ import subprocess import os import json -import App +from tiny_test_fw import App class IDFApp(App.BaseApp): diff --git a/tools/tiny-test-fw/IDF/IDFDUT.py b/tools/ci/python_packages/ttfw_idf/IDFDUT.py similarity index 99% rename from tools/tiny-test-fw/IDF/IDFDUT.py rename to tools/ci/python_packages/ttfw_idf/IDFDUT.py index 13838153f9..874d89273f 100644 --- a/tools/tiny-test-fw/IDF/IDFDUT.py +++ b/tools/ci/python_packages/ttfw_idf/IDFDUT.py @@ -30,8 +30,7 @@ except ImportError: from serial.tools import list_ports -import DUT -import Utility +from tiny_test_fw import DUT, Utility try: import esptool diff --git a/tools/tiny-test-fw/IDF/__init__.py b/tools/ci/python_packages/ttfw_idf/__init__.py similarity index 97% rename from tools/tiny-test-fw/IDF/__init__.py rename to tools/ci/python_packages/ttfw_idf/__init__.py index 56db1b2872..d7aed38571 100644 --- a/tools/tiny-test-fw/IDF/__init__.py +++ b/tools/ci/python_packages/ttfw_idf/__init__.py @@ -14,10 +14,9 @@ import os import re -import TinyFW -import Utility -from IDF.IDFApp import IDFApp, Example, UT -from IDF.IDFDUT import IDFDUT +from tiny_test_fw import TinyFW, Utility +from IDFApp import IDFApp, Example, UT +from IDFDUT import IDFDUT, ESP32DUT, ESP32S2DUT, ESP8266DUT def format_case_id(chip, case_name): diff --git a/tools/ci/setup_python.sh b/tools/ci/setup_python.sh index c134ba816b..a0e1723be0 100644 --- a/tools/ci/setup_python.sh +++ b/tools/ci/setup_python.sh @@ -51,3 +51,6 @@ else echo 'No /opt/pyenv/activate exists and no Python interpreter is found!' exit 1 fi + +# add esp-idf local package path to PYTHONPATH so it can be imported directly +export PYTHONPATH="$IDF_PATH/tools:$IDF_PATH/tools/ci/python_packages:$PYTHONPATH" diff --git a/tools/tiny-test-fw/Utility/Attenuator.py b/tools/esp_python_packages/tiny_test_fw/Utility/Attenuator.py similarity index 100% rename from tools/tiny-test-fw/Utility/Attenuator.py rename to tools/esp_python_packages/tiny_test_fw/Utility/Attenuator.py diff --git a/tools/tiny-test-fw/Utility/LineChart.py b/tools/esp_python_packages/tiny_test_fw/Utility/LineChart.py similarity index 100% rename from tools/tiny-test-fw/Utility/LineChart.py rename to tools/esp_python_packages/tiny_test_fw/Utility/LineChart.py diff --git a/tools/tiny-test-fw/Utility/PowerControl.py b/tools/esp_python_packages/tiny_test_fw/Utility/PowerControl.py similarity index 100% rename from tools/tiny-test-fw/Utility/PowerControl.py rename to tools/esp_python_packages/tiny_test_fw/Utility/PowerControl.py