Преглед изворни кода

Tools: Added test_idf_tools_python_env output log file

Marek Fiala пре 3 година
родитељ
комит
24fc499b6c
2 измењених фајлова са 8 додато и 1 уклоњено
  1. 1 0
      .gitlab/ci/host-test.yml
  2. 7 1
      tools/test_idf_tools/test_idf_tools_python_env.py

+ 1 - 0
.gitlab/ci/host-test.yml

@@ -210,6 +210,7 @@ test_idf_tools:
     when: on_failure
     paths:
       - tools/tools.new.json
+      - tools/test_idf_tools/test_python_env_logs.txt
     expire_in: 1 week
   script:
     # Remove Xtensa and ULP toolchains from the PATH, tests will expect a clean environment

+ 7 - 1
tools/test_idf_tools/test_idf_tools_python_env.py

@@ -1,6 +1,7 @@
 # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
 # SPDX-License-Identifier: Apache-2.0
 
+import inspect
 import os
 import shutil
 import subprocess
@@ -34,7 +35,12 @@ class TestPythonInstall(unittest.TestCase):
     def run_idf_tools(self, extra_args):  # type: (List[str]) -> str
         args = [sys.executable, '../idf_tools.py'] + extra_args
         ret = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=120)
-        return ret.stdout.decode('utf-8', 'ignore')
+        decoded_output = ret.stdout.decode('utf-8', 'ignore')
+        with open(os.path.join(IDF_PATH, 'tools', 'test_idf_tools', 'test_python_env_logs.txt'), 'a+') as w:
+            # stack() returns list of callers frame records. [1] represent caller of this function
+            w.write('============================= ' + inspect.stack()[1].function + ' =============================\n')
+            w.write(decoded_output)
+        return decoded_output
 
     def test_default_arguments(self):  # type: () -> None
         output = self.run_idf_tools(['check-python-dependencies'])