2020-11-02 13:11:14 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import os
|
2020-11-12 10:52:45 +00:00
|
|
|
import sys
|
2020-11-02 13:11:14 +00:00
|
|
|
import unittest
|
|
|
|
|
2021-01-26 02:49:01 +00:00
|
|
|
import pexpect
|
|
|
|
|
2020-11-02 13:11:14 +00:00
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
def test_fish(self):
|
2021-01-26 02:49:01 +00:00
|
|
|
os.environ['TERM'] = 'vt100'
|
|
|
|
child = pexpect.spawn('fish -i')
|
|
|
|
with open(os.environ['IDF_PATH'] + '/fish' + str(sys.version_info.major) + '.out', 'wb') as output:
|
2020-11-12 10:52:45 +00:00
|
|
|
child.logfile = output
|
|
|
|
child.sendline('. ./export.fish')
|
|
|
|
result = child.expect(
|
2021-01-26 02:49:01 +00:00
|
|
|
['Go to the project directory and run.*idf\\.py build', pexpect.EOF,
|
2020-11-12 10:52:45 +00:00
|
|
|
pexpect.TIMEOUT], timeout=40)
|
2021-01-26 02:49:01 +00:00
|
|
|
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!')
|
2020-11-02 13:11:14 +00:00
|
|
|
|
|
|
|
def test_bash(self):
|
2021-01-26 02:49:01 +00:00
|
|
|
os.environ['TERM'] = 'xterm-256color'
|
|
|
|
child = pexpect.spawn('bash -i')
|
|
|
|
with open(os.environ['IDF_PATH'] + '/bash' + str(sys.version_info.major) + '.out', 'wb') as output:
|
2020-11-12 10:52:45 +00:00
|
|
|
child.logfile = output
|
|
|
|
child.sendline('. ./export.sh')
|
2021-01-26 02:49:01 +00:00
|
|
|
child.send('idf.py \t\t')
|
2020-11-12 10:52:45 +00:00
|
|
|
result = child.expect(
|
2021-01-26 02:49:01 +00:00
|
|
|
['Go to the project directory and run.*idf\\.py build', pexpect.EOF,
|
2020-11-12 10:52:45 +00:00
|
|
|
pexpect.TIMEOUT], timeout=40)
|
2021-01-26 02:49:01 +00:00
|
|
|
self.assertEqual(result, 0, 'Export was not successful!')
|
2020-11-12 10:52:45 +00:00
|
|
|
result = child.expect(
|
2021-01-26 02:49:01 +00:00
|
|
|
['all.*app.*app-flash.*bootloader.*bootloader-flash.*build-system-targets.*clean.*', pexpect.EOF,
|
2020-11-12 10:52:45 +00:00
|
|
|
pexpect.TIMEOUT], timeout=40)
|
2021-01-26 02:49:01 +00:00
|
|
|
self.assertEqual(result, 0, 'Autocompletion for idf.py failed in bash!')
|
2020-11-02 13:11:14 +00:00
|
|
|
|
|
|
|
def test_zsh(self):
|
2021-01-26 02:49:01 +00:00
|
|
|
child = pexpect.spawn('zsh -i')
|
|
|
|
with open(os.environ['IDF_PATH'] + '/zsh' + str(sys.version_info.major) + '.out', 'wb') as output:
|
2020-11-12 10:52:45 +00:00
|
|
|
child.logfile = output
|
|
|
|
child.sendline('. ./export.sh')
|
|
|
|
result = child.expect(
|
2021-01-26 02:49:01 +00:00
|
|
|
['Go to the project directory and run.*idf\\.py build', pexpect.EOF,
|
2020-11-12 10:52:45 +00:00
|
|
|
pexpect.TIMEOUT], timeout=40)
|
2021-01-26 02:49:01 +00:00
|
|
|
self.assertEqual(result, 0, 'Export was not successful!')
|
|
|
|
child.send('idf.py \t\t')
|
2020-11-12 10:52:45 +00:00
|
|
|
result = child.expect(
|
2021-01-26 02:49:01 +00:00
|
|
|
['all.*app.*app-flash.*bootloader.*bootloader-flash.*build-system-targets.*clean.*', pexpect.EOF,
|
2020-11-12 10:52:45 +00:00
|
|
|
pexpect.TIMEOUT], timeout=40)
|
2021-01-26 02:49:01 +00:00
|
|
|
self.assertEqual(result, 0, 'Autocompletion for idf.py failed in zsh!')
|
2020-11-02 13:11:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|