test_autocomplete.py 2.5 KB

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