Merge branch 'bugfix/fix-autocomplete-tests' into 'master'

Add waiting for export script finish

Closes IDFCI-218

See merge request espressif/esp-idf!11216
This commit is contained in:
Angus Gratton 2020-11-17 07:33:16 +08:00
commit c9fdc8a167
2 changed files with 36 additions and 26 deletions

View File

@ -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_docs.py
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh -p 3.6.10 ./test_sphinx_idf_extensions.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 extends: .host_test_template
image: $CI_DOCKER_REGISTRY/linux-shells:1 image: $CI_DOCKER_REGISTRY/linux-shells:1
artifacts: artifacts:

View File

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