Explorar el Código

Close files after writing.

martin.gano hace 5 años
padre
commit
978b5308e8
Se han modificado 2 ficheros con 36 adiciones y 26 borrados
  1. 1 1
      tools/ci/config/host-test.yml
  2. 35 25
      tools/ci/test_autocomplete.py

+ 1 - 1
tools/ci/config/host-test.yml

@@ -291,7 +291,7 @@ test_docs:
     - ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh -p 3.6.10 ./test_docs.py
     - ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh -p 3.6.10 ./test_sphinx_idf_extensions.py
 
-.test_autocomplete:
+test_autocomplete:
   extends: .host_test_template
   image: $CI_DOCKER_REGISTRY/linux-shells:1
   artifacts:

+ 35 - 25
tools/ci/test_autocomplete.py

@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 import os
+import sys
 import pexpect
 import unittest
 
@@ -8,38 +9,47 @@ class Test(unittest.TestCase):
     def test_fish(self):
         os.environ["TERM"] = "vt100"
         child = pexpect.spawn("fish -i")
-        child.logfile = open(os.environ["IDF_PATH"] + "/fish.out", "wb")
-        child.sendline(
-            '. {$IDF_PATH}/export.fish >> {$IDF_PATH}/debug.out')
-        child.send("idf.py \t\t")
-        result = child.expect(["all.*app.*app-flash.*bootloader.*", pexpect.EOF, pexpect.TIMEOUT], timeout=5)
-        self.assertEqual(result, 0, "Autocompletion for idf.py failed in fish!")
-        result = child.expect(["bootloader-flash.*build-system-targets.*clean.*", pexpect.EOF, pexpect.TIMEOUT],
-                              timeout=5)
-        self.assertEqual(result, 0, "Autocompletion for idf.py failed in fish!")
+        with open(os.environ["IDF_PATH"] + "/fish" + str(sys.version_info.major) + ".out", "wb") as output:
+            child.logfile = output
+            child.sendline('. ./export.fish')
+            result = child.expect(
+                ["Go to the project directory and run.*idf\\.py build", pexpect.EOF,
+                 pexpect.TIMEOUT], timeout=40)
+            self.assertEqual(result, 0, "Export was not successful!")
+            child.send("idf.py \t\t")
+            result = child.expect(["all.*app.*app-flash.*bootloader.*", pexpect.EOF, pexpect.TIMEOUT], timeout=40)
+            self.assertEqual(result, 0, "Autocompletion for idf.py failed in fish!")
 
     def test_bash(self):
         os.environ["TERM"] = "xterm-256color"
         child = pexpect.spawn("bash -i")
-        child.logfile = open(os.environ["IDF_PATH"] + "/bash.out", "wb")
-        child.sendline(
-            '. ${IDF_PATH}/export.sh >> ${IDF_PATH}/debug.out')
-        child.send("idf.py \t\t")
-        result = child.expect(
-            ["all.*app.*app-flash.*bootloader.*bootloader-flash.*build-system-targets.*clean.*", pexpect.EOF,
-             pexpect.TIMEOUT], timeout=5)
-        self.assertEqual(result, 0, "Autocompletion for idf.py failed in bash!")
+        with open(os.environ["IDF_PATH"] + "/bash" + str(sys.version_info.major) + ".out", "wb") as output:
+            child.logfile = output
+            child.sendline('. ./export.sh')
+            child.send("idf.py \t\t")
+            result = child.expect(
+                ["Go to the project directory and run.*idf\\.py build", pexpect.EOF,
+                 pexpect.TIMEOUT], timeout=40)
+            self.assertEqual(result, 0, "Export was not successful!")
+            result = child.expect(
+                ["all.*app.*app-flash.*bootloader.*bootloader-flash.*build-system-targets.*clean.*", pexpect.EOF,
+                 pexpect.TIMEOUT], timeout=40)
+            self.assertEqual(result, 0, "Autocompletion for idf.py failed in bash!")
 
     def test_zsh(self):
         child = pexpect.spawn("zsh -i")
-        child.logfile = open(os.environ["IDF_PATH"] + "/zsh.out", "wb")
-        child.sendline(
-            '. ${IDF_PATH}/export.sh >> ${IDF_PATH}/debug.out ')
-        child.send("idf.py \t")
-        result = child.expect(
-            ["all.*app.*app-flash.*bootloader.*bootloader-flash.*build-system-targets.*clean.*", pexpect.EOF,
-             pexpect.TIMEOUT], timeout=5)
-        self.assertEqual(result, 0, "Autocompletion for idf.py failed in zsh!")
+        with open(os.environ["IDF_PATH"] + "/zsh" + str(sys.version_info.major) + ".out", "wb") as output:
+            child.logfile = output
+            child.sendline('. ./export.sh')
+            result = child.expect(
+                ["Go to the project directory and run.*idf\\.py build", pexpect.EOF,
+                 pexpect.TIMEOUT], timeout=40)
+            self.assertEqual(result, 0, "Export was not successful!")
+            child.send("idf.py \t\t")
+            result = child.expect(
+                ["all.*app.*app-flash.*bootloader.*bootloader-flash.*build-system-targets.*clean.*", pexpect.EOF,
+                 pexpect.TIMEOUT], timeout=40)
+            self.assertEqual(result, 0, "Autocompletion for idf.py failed in zsh!")
 
 
 if __name__ == '__main__':