tiny-test-fw: move to tools/esp_python_packages:

make `tiny_test_fw` as a package and move to root path of idf python
packages
This commit is contained in:
He Yin Ling 2019-11-27 11:21:33 +08:00 committed by Angus Gratton
parent d3e0301aee
commit 7a5d17e1b7
29 changed files with 49 additions and 40 deletions

View File

@ -44,8 +44,12 @@ import re
import json
import yaml
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader as Loader
from Utility import (CaseConfig, SearchCases, GitlabCIJob, console_log)
from . import (CaseConfig, SearchCases, GitlabCIJob, console_log)
class Group(object):
@ -164,7 +168,7 @@ class AssignTest(object):
def _parse_gitlab_ci_config(self, ci_config_file):
with open(ci_config_file, "r") as f:
ci_config = yaml.load(f)
ci_config = yaml.load(f, Loader=Loader)
job_list = list()
for job_name in ci_config:

View File

@ -20,7 +20,7 @@ Template Config File::
TestConfig:
app:
path: Users/Test/TinyTestFW/IDF/IDFApp.py
package: ttfw_idf
class: Example
dut:
path:
@ -38,16 +38,19 @@ 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
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader as Loader
import TestCase
from Utility import load_source
from . import TestCase
def _convert_to_lower_case_bytes(item):
@ -154,7 +157,7 @@ class Parser(object):
configs = cls.DEFAULT_CONFIG.copy()
if config_file:
with open(config_file, "r") as f:
configs.update(yaml.load(f))
configs.update(yaml.load(f, Loader=Loader))
return configs
@classmethod
@ -167,9 +170,8 @@ class Parser(object):
"""
output = dict()
for key in overwrite:
_path = overwrite[key]["path"]
_module = load_source(str(hash(_path)), overwrite[key]["path"])
output[key] = _module.__getattribute__(overwrite[key]["class"])
module = importlib.import_module(overwrite[key]["package"])
output[key] = module.__getattribute__(overwrite[key]["class"])
return output
@classmethod

View File

@ -17,7 +17,8 @@ import os
import fnmatch
import types
import copy
from Utility import load_source
from . import load_source
class Search(object):

View File

@ -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):

View File

@ -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",

View File

@ -3,19 +3,16 @@ Command line tool to assign unit tests to CI test jobs.
"""
import re
import os
import sys
import argparse
import yaml
try:
from Utility import CIAssignTest
from yaml import CLoader as Loader
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 yaml import Loader as Loader
from tiny_test_fw.Utility import CIAssignTest
class Group(CIAssignTest.Group):
@ -133,7 +130,7 @@ class UnitTestAssignTest(CIAssignTest.AssignTest):
try:
with open(test_case_path, "r") as f:
raw_data = yaml.load(f)
raw_data = yaml.load(f, Loader=Loader)
test_cases = raw_data["test cases"]
for case in test_cases:
case["tags"] = set(case["tags"])

View File

@ -17,7 +17,7 @@ import subprocess
import os
import json
import App
from tiny_test_fw import App
class IDFApp(App.BaseApp):

View File

@ -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

View File

@ -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
def format_case_id(chip, case_name):

View File

@ -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"