test_autocomplete.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env python
  2. # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  3. # SPDX-License-Identifier: Apache-2.0
  4. import os
  5. import sys
  6. import unittest
  7. import pexpect
  8. class Test(unittest.TestCase):
  9. def test_fish(self):
  10. os.environ['TERM'] = 'vt100'
  11. child = pexpect.spawn('fish -i')
  12. with open(os.environ['IDF_PATH'] + '/fish' + str(sys.version_info.major) + '.out', 'wb') as output:
  13. child.logfile = output
  14. child.sendline('. ./export.fish')
  15. result = child.expect(
  16. ['Go to the project directory and run.*idf\\.py build', pexpect.EOF,
  17. pexpect.TIMEOUT], timeout=40)
  18. self.assertEqual(result, 0, 'Export was not successful!')
  19. child.send('idf.py \t\t')
  20. result = child.expect(['all.*app.*app-flash.*bootloader.*', pexpect.EOF, pexpect.TIMEOUT], timeout=40)
  21. self.assertEqual(result, 0, 'Autocompletion for idf.py failed in fish!')
  22. def test_bash(self):
  23. os.environ['TERM'] = 'xterm-256color'
  24. child = pexpect.spawn('bash -i')
  25. with open(os.environ['IDF_PATH'] + '/bash' + str(sys.version_info.major) + '.out', 'wb') as output:
  26. child.logfile = output
  27. child.sendline('. ./export.sh')
  28. child.send('idf.py \t\t')
  29. result = child.expect(
  30. ['Go to the project directory and run.*idf\\.py build', pexpect.EOF,
  31. pexpect.TIMEOUT], timeout=40)
  32. self.assertEqual(result, 0, 'Export was not successful!')
  33. result = child.expect(
  34. ['all.*app.*app-flash.*bootloader.*bootloader-flash.*build-system-targets.*clean.*', pexpect.EOF,
  35. pexpect.TIMEOUT], timeout=40)
  36. self.assertEqual(result, 0, 'Autocompletion for idf.py failed in bash!')
  37. def test_zsh(self):
  38. child = pexpect.spawn('zsh -i')
  39. with open(os.environ['IDF_PATH'] + '/zsh' + str(sys.version_info.major) + '.out', 'wb') as output:
  40. child.logfile = output
  41. child.sendline('. ./export.sh')
  42. result = child.expect(
  43. ['Go to the project directory and run.*idf\\.py build', pexpect.EOF,
  44. pexpect.TIMEOUT], timeout=40)
  45. self.assertEqual(result, 0, 'Export was not successful!')
  46. child.send('idf.py \t\t')
  47. result = child.expect(
  48. ['all.*app.*app-flash.*bootloader.*bootloader-flash.*build-system-targets.*clean.*', pexpect.EOF,
  49. pexpect.TIMEOUT], timeout=40)
  50. self.assertEqual(result, 0, 'Autocompletion for idf.py failed in zsh!')
  51. if __name__ == '__main__':
  52. unittest.main()