It is improve build scheme based on efl-test-suite path and error handling.
Change-Id: I4c82b2daab26b066bc6bba5aa475b262f258910a
from logger import Logger
from gbsbuild import GBSBuild
from setup import Setup
-from selector import Selector
-import os
+from execute import ExecuteRun
import readline
class app:
- """ This class takes care of user input and use other modules to do everything"""
+ """
+ This class takes care of user input and use other modules to do everything
+ """
- srcpath = ''
dstpath = '/tmp/'
- tcs_list = list()
- """We setup the working directory by using Setup object."""
-
- def setupworkingenvironment(self):
- Setup.start(self.srcpath, self.dstpath)
def showhelp(self):
print('\nCommands:')
- print('\n\tbuild To do gbs build')
- print('\tbuild clean To do clean gbs build')
- print('\tbuild custom To do custom gbs build')
- print('\thelp To show the help commands')
- print('\texit Exit from the program')
+ print('\n\tbuild To do gbs build')
+ print('\tbuild clean To do clean gbs build')
+ print('\tbuild custom To do custom gbs build')
+ print('\trun <device name> To execute TCs on device(mobile,wear,rpi), e.g. run mobile')
+ print('\thelp/? To show the help commands')
+ print('\tquit/q Exit from the program')
print('\n')
- def processuserinput(self):
- self.srcpath = input('Enter the path of efl-test-suite: ')
- while not os.path.isdir(self.srcpath):
- self.srcpath = input("Path not found!!.. Re-Enter the source path: ")
-
- self.srcpath = self.srcpath.strip()
- Logger.warning('path entered: ' + self.srcpath)
- tclist = input(
- 'Enter the list of TCs to be built(separated by comma, e.g. utc_elm_panes_content_left_size_get_set.c, '
- 'utc_edje_edit_part_exist.c): ')
- Logger.warning('TCs selected: ' + tclist)
- self.tcs_list = tclist.split(',')
-
- self.setupworkingenvironment()
- index = 0
- for tc in self.tcs_list:
- self.tcs_list[index] = tc.strip()
- index = index + 1
-
- tmp_list = self.tcs_list
- for tc in tmp_list:
- index = tmp_list.index(tc)
- if Selector.does_tc_exist(tc, self.dstpath):
- Logger.info(tc + ': added.')
- else:
- while True:
- testcase = tc
- Logger.critical(testcase + ': does not exist')
- testcase = input('Enter the incorrect/empty TC again: ')
- testcase = testcase.strip()
- Logger.warning('TC selected: ' + testcase)
- if Selector.does_tc_exist(testcase, self.dstpath):
- Logger.info(testcase + ': added.')
- self.tcs_list[index] = testcase
- break
-
- self.showhelp()
+ showhelp_again = False
while True:
commandentered = commandentered.strip()
if commandentered == 'build':
+ Setup.verifyInputPath(self.dstpath)
GBSBuild.build(self.dstpath + 'efl-test-suite/')
elif commandentered == 'build clean':
+ Setup.verifyInputPath(self.dstpath)
GBSBuild.buildclean(self.dstpath + 'efl-test-suite/')
elif commandentered == 'build custom':
+ Setup.verifyInputPath(self.dstpath)
GBSBuild.buildcustom(self.dstpath + 'efl-test-suite/')
- elif commandentered == 'help':
- self.showhelp()
- elif commandentered == 'exit':
+ elif commandentered == 'run mobile':
+ ExecuteRun.run('mobile')
+ elif commandentered == 'run wear':
+ ExecuteRun.run('wear')
+ elif commandentered == 'run rpi':
+ ExecuteRun.run('rpi')
+ elif commandentered == 'help' or commandentered == '?':
+ showhelp_again = True
+ break
+ elif commandentered == 'q' or commandentered == 'quit':
break
+ else:
+ Logger.error('Enter the valid command')
+
+ if showhelp_again == True:
+ self.showhelp()
if __name__ == '__main__':
App = app()
-
- App.processuserinput()
+ App.showhelp()
class selector:
- tc_name = ''
+
path_elements_list = list()
path = ''
+ tcs_list = list()
+
+ def inputTcFromUser(self, dst_path):
+ tclist = input(
+ 'Enter the list of TCs to be built(separated by comma, e.g. utc_elm_panes_content_left_size_get_set.c, '
+ 'utc_edje_edit_part_exist.c): ')
+ Logger.warning('TCs selected: ' + tclist)
+ self.tcs_list = tclist.split(',')
+ index = 0
+ for tc in self.tcs_list:
+ self.tcs_list[index] = tc.strip()
+ index = index + 1
+
+ tmp_list = self.tcs_list
+ for tc in tmp_list:
+ index = tmp_list.index(tc)
+ if self.does_tc_exist(tc, dst_path):
+ Logger.info(tc + ': added.')
+ else:
+ testcase = tc
+ while True:
+ Logger.critical(testcase + ': does not exist')
+ testcase = input('Enter the incorrect/empty TC again: ')
+ testcase = testcase.strip()
+ Logger.warning('TC selected: ' + testcase)
+ if self.does_tc_exist(testcase, dst_path):
+ Logger.info(testcase + ': added.')
+ self.tcs_list[index] = testcase
+ break
def does_tc_exist(self, testcase, dst_path):
- self.tc_name = testcase
- os.chdir(dst_path + "/efl-test-suite")
- stream = os.popen("find . -name " + self.tc_name)
+ os.chdir(dst_path)
+ stream = os.popen("find . -name " + testcase)
output = stream.read().strip()
if len(output) != 0:
self.set_tslist_path(testcase, output)
def set_tslist_path(self, testcase, output):
self.path_elements_list = output.split('/')
- index = self.path_elements_list.index(self.tc_name)
+ index = self.path_elements_list.index(testcase)
self.path = "/".join(self.path_elements_list[1:index])
os.chdir(os.getcwd() + "/" + self.path)
- Logger.info("TC " + self.tc_name + " added into tslist ")
- self.tslist_entry(self.tc_name)
+ Logger.info("TC " + testcase + " added into tslist ")
+ self.tslist_entry(testcase)
def tslist_entry(self, testcase):
file = open('tslist', 'a')
import os
from logger import Logger
+from util import util
+from selector import Selector
class setup:
- def start(self, src_path, dest_path):
- if os.path.isfile('/tmp/tslist'):
- os.system('rm -rf /tmp/tslist')
- if os.path.isdir(dest_path + '/efl-test-suite'):
- os.system('rm -rf ' + dest_path + '/efl-test-suite')
+ def verifyInputPath(self, dest_path):
+ src_path = input('Enter the path of efl-test-suite: ')
+ while True:
+ src_path = util.expanduser(src_path)
+ if not os.path.isdir(src_path):
+ src_path = input("Path not found!!.. Re-Enter the source path: ")
+ else:
+ Logger.warning('path entered: ' + src_path)
+ break
+ self.start(src_path, dest_path)
- os.system("touch /tmp/tslist")
+ def start(self, src_path, dest_path):
+ if os.path.isfile('/tmp/tslist'):
+ os.system('rm -rf /tmp/tslist')
+ if os.path.isdir(dest_path + '/efl-test-suite'):
+ os.system('rm -rf ' + dest_path + '/efl-test-suite')
- Logger.info('Copying... ' + src_path + ' to ' + dest_path)
+ os.system("touch /tmp/tslist")
- os.system("cp " + src_path + " " + dest_path + " -rf")
- dest_path += 'efl-test-suite/'
- os.chdir(dest_path)
+ Logger.info('Copying... ' + src_path + ' to ' + dest_path)
- os.system("find . -name tslist | xargs -n 1 cp -v /tmp/tslist > /dev/null")
- Logger.info('Copying done to ' + dest_path)
+ os.system("cp " + src_path + " " + dest_path + " -rf")
+ dest_path += 'efl-test-suite/'
+ os.chdir(dest_path)
+ os.system("find . -name tslist | xargs -n 1 cp -v /tmp/tslist > /dev/null")
+ Logger.info('Copying done to ' + dest_path)
+ Selector.inputTcFromUser(dest_path)
-Setup = setup()
+Setup = setup()
if __name__ == '__main__':
- src_path = input("Enter the source path: ")
- while os.path.isdir(src_path) == False:
- src_path = input("Path not found!!.. Re-Enter the source path: ")
-
- #Setup.start(src_path, dest_path)
+ Setup.start(src_path, dest_path)