All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] resulttool/manualexecution: Enhancement and fixes
@ 2019-04-04  8:48 Yeoh Ee Peng
  2019-04-04  8:48 ` [PATCH 1/4] resulttool/manualexecution: Standardize input check Yeoh Ee Peng
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Yeoh Ee Peng @ 2019-04-04  8:48 UTC (permalink / raw)
  To: openembedded-core

These series of patches include enhancement and fixes for manualexecution:
 - Enhance input check to standardize checking
 - Enhancement to display full steps without press enter 
 - Fix test steps display order
 - Refactor to simplify code and align to pythonic style

Yeoh Ee Peng (4):
  resulttool/manualexecution: Standardize input check
  resulttool/manualexecution: Enable display full steps without press
    enter
  resulttool/manualexecution: Fixed step sorted by integer
  resulttool/manualexecution: Refactor and simplify codebase

 scripts/lib/resulttool/manualexecution.py | 61 ++++++++++++-------------------
 1 file changed, 23 insertions(+), 38 deletions(-)

-- 
2.7.4



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] resulttool/manualexecution: Standardize input check
  2019-04-04  8:48 [PATCH 0/4] resulttool/manualexecution: Enhancement and fixes Yeoh Ee Peng
@ 2019-04-04  8:48 ` Yeoh Ee Peng
  2019-04-04  8:48 ` [PATCH 2/4] resulttool/manualexecution: Enable display full steps without press enter Yeoh Ee Peng
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Yeoh Ee Peng @ 2019-04-04  8:48 UTC (permalink / raw)
  To: openembedded-core

Current input checking does not match the standard input practiced
by QA team. Change the input checking to match the standard
input practiced by the QA team.

Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
---
 scripts/lib/resulttool/manualexecution.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/resulttool/manualexecution.py b/scripts/lib/resulttool/manualexecution.py
index 6487cd9..8ce7903 100755
--- a/scripts/lib/resulttool/manualexecution.py
+++ b/scripts/lib/resulttool/manualexecution.py
@@ -45,9 +45,9 @@ class ManualTestRunner(object):
     def _get_input(self, config):
         while True:
             output = input('{} = '.format(config))
-            if re.match('^[a-zA-Z0-9_-]+$', output):
+            if re.match('^[a-z0-9-.]+$', output):
                 break
-            print('Only alphanumeric and underscore/hyphen are allowed. Please try again')
+            print('Only lowercase alphanumeric, hyphen and dot are allowed. Please try again')
         return output
 
     def _create_config(self):
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] resulttool/manualexecution: Enable display full steps without press enter
  2019-04-04  8:48 [PATCH 0/4] resulttool/manualexecution: Enhancement and fixes Yeoh Ee Peng
  2019-04-04  8:48 ` [PATCH 1/4] resulttool/manualexecution: Standardize input check Yeoh Ee Peng
@ 2019-04-04  8:48 ` Yeoh Ee Peng
  2019-04-04  8:48 ` [PATCH 3/4] resulttool/manualexecution: Fixed step sorted by integer Yeoh Ee Peng
  2019-04-04  8:48 ` [PATCH 4/4] resulttool/manualexecution: Refactor and simplify codebase Yeoh Ee Peng
  3 siblings, 0 replies; 5+ messages in thread
From: Yeoh Ee Peng @ 2019-04-04  8:48 UTC (permalink / raw)
  To: openembedded-core

Current manualexecution required pressing enter button to show each step
information, where this was wasting execution time. Enable display
full steps without needing to any press enter button.

Signed-off-by: Mazliana <mazliana.mohamad@intel.com>
Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
---
 scripts/lib/resulttool/manualexecution.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/resulttool/manualexecution.py b/scripts/lib/resulttool/manualexecution.py
index 8ce7903..0783540 100755
--- a/scripts/lib/resulttool/manualexecution.py
+++ b/scripts/lib/resulttool/manualexecution.py
@@ -87,8 +87,9 @@ class ManualTestRunner(object):
         print('------------------------------------------------------------------------\n')
         for step in sorted((self.jdata[test_id]['test']['execution']).keys()):
             print('Step %s: ' % step + self.jdata[test_id]['test']['execution']['%s' % step]['action'])
-            print('Expected output: ' + self.jdata[test_id]['test']['execution']['%s' % step]['expected_results'])
-            done = input('\nPlease press ENTER when you are done to proceed to next step.\n')
+            expected_output = self.jdata[test_id]['test']['execution']['%s' % step]['expected_results']
+            if expected_output:
+                print('Expected output: ' + expected_output)
         while True:
             done = input('\nPlease provide test results: (P)assed/(F)ailed/(B)locked/(S)kipped? \n')
             done = done.lower()
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] resulttool/manualexecution: Fixed step sorted by integer
  2019-04-04  8:48 [PATCH 0/4] resulttool/manualexecution: Enhancement and fixes Yeoh Ee Peng
  2019-04-04  8:48 ` [PATCH 1/4] resulttool/manualexecution: Standardize input check Yeoh Ee Peng
  2019-04-04  8:48 ` [PATCH 2/4] resulttool/manualexecution: Enable display full steps without press enter Yeoh Ee Peng
@ 2019-04-04  8:48 ` Yeoh Ee Peng
  2019-04-04  8:48 ` [PATCH 4/4] resulttool/manualexecution: Refactor and simplify codebase Yeoh Ee Peng
  3 siblings, 0 replies; 5+ messages in thread
From: Yeoh Ee Peng @ 2019-04-04  8:48 UTC (permalink / raw)
  To: openembedded-core

Currently the manual execution display step by sorting
the step as string, where steps were not being sorted
correctly when there are more than 9 steps.

Fixed the step sorting by sorting step as integer.

Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
---
 scripts/lib/resulttool/manualexecution.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/lib/resulttool/manualexecution.py b/scripts/lib/resulttool/manualexecution.py
index 0783540..9a29b0b 100755
--- a/scripts/lib/resulttool/manualexecution.py
+++ b/scripts/lib/resulttool/manualexecution.py
@@ -85,7 +85,7 @@ class ManualTestRunner(object):
         print('------------------------------------------------------------------------')
         print('You have total ' + str(total_steps) + ' test steps to be executed.')
         print('------------------------------------------------------------------------\n')
-        for step in sorted((self.jdata[test_id]['test']['execution']).keys()):
+        for step, _ in sorted(self.jdata[test_id]['test']['execution'].items(), key=lambda x: int(x[0])):
             print('Step %s: ' % step + self.jdata[test_id]['test']['execution']['%s' % step]['action'])
             expected_output = self.jdata[test_id]['test']['execution']['%s' % step]['expected_results']
             if expected_output:
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] resulttool/manualexecution: Refactor and simplify codebase
  2019-04-04  8:48 [PATCH 0/4] resulttool/manualexecution: Enhancement and fixes Yeoh Ee Peng
                   ` (2 preceding siblings ...)
  2019-04-04  8:48 ` [PATCH 3/4] resulttool/manualexecution: Fixed step sorted by integer Yeoh Ee Peng
@ 2019-04-04  8:48 ` Yeoh Ee Peng
  3 siblings, 0 replies; 5+ messages in thread
From: Yeoh Ee Peng @ 2019-04-04  8:48 UTC (permalink / raw)
  To: openembedded-core

Simplify and removed unnecessary codes.
Refactor to allow pythonic loop.

Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
---
 scripts/lib/resulttool/manualexecution.py | 56 +++++++++++--------------------
 1 file changed, 20 insertions(+), 36 deletions(-)

diff --git a/scripts/lib/resulttool/manualexecution.py b/scripts/lib/resulttool/manualexecution.py
index 9a29b0b..c94f981 100755
--- a/scripts/lib/resulttool/manualexecution.py
+++ b/scripts/lib/resulttool/manualexecution.py
@@ -24,24 +24,12 @@ def load_json_file(file):
     with open(file, "r") as f:
         return json.load(f)
 
-
 class ManualTestRunner(object):
-    def __init__(self):
-        self.jdata = ''
-        self.test_module = ''
-        self.test_cases_id = ''
-        self.configuration = ''
-        self.starttime = ''
-        self.result_id = ''
-        self.write_dir = ''
 
     def _get_testcases(self, file):
         self.jdata = load_json_file(file)
-        self.test_cases_id = []
         self.test_module = self.jdata[0]['test']['@alias'].split('.', 2)[0]
-        for i in self.jdata:
-            self.test_cases_id.append(i['test']['@alias'])
-    
+
     def _get_input(self, config):
         while True:
             output = input('{} = '.format(config))
@@ -67,45 +55,42 @@ class ManualTestRunner(object):
         extra_config = set(store_map['manual']) - set(self.configuration)
         for config in sorted(extra_config):
             print('---------------------------------------------')
-            print('This is configuration #%s. Please provide configuration value(use "None" if not applicable).'
-                  % config)
+            print('This is configuration #%s. Please provide configuration value(use "None" if not applicable).' % config)
             print('---------------------------------------------')
             value_conf = self._get_input('Configuration Value')
             print('---------------------------------------------\n')
             self.configuration[config] = value_conf
 
     def _create_result_id(self):
-        self.result_id = 'manual_' + self.test_module + '_' + self.starttime
+        self.result_id = 'manual_%s_%s' % (self.test_module, self.starttime)
 
-    def _execute_test_steps(self, test_id):
+    def _execute_test_steps(self, test):
         test_result = {}
-        total_steps = len(self.jdata[test_id]['test']['execution'].keys())
         print('------------------------------------------------------------------------')
-        print('Executing test case:' + '' '' + self.test_cases_id[test_id])
+        print('Executing test case: %s' % test['test']['@alias'])
         print('------------------------------------------------------------------------')
-        print('You have total ' + str(total_steps) + ' test steps to be executed.')
+        print('You have total %s test steps to be executed.' % len(test['test']['execution']))
         print('------------------------------------------------------------------------\n')
-        for step, _ in sorted(self.jdata[test_id]['test']['execution'].items(), key=lambda x: int(x[0])):
-            print('Step %s: ' % step + self.jdata[test_id]['test']['execution']['%s' % step]['action'])
-            expected_output = self.jdata[test_id]['test']['execution']['%s' % step]['expected_results']
+        for step, _ in sorted(test['test']['execution'].items(), key=lambda x: int(x[0])):
+            print('Step %s: %s' % (step, test['test']['execution'][step]['action']))
+            expected_output = test['test']['execution'][step]['expected_results']
             if expected_output:
-                print('Expected output: ' + expected_output)
+                print('Expected output: %s' % expected_output)
         while True:
-            done = input('\nPlease provide test results: (P)assed/(F)ailed/(B)locked/(S)kipped? \n')
-            done = done.lower()
+            done = input('\nPlease provide test results: (P)assed/(F)ailed/(B)locked/(S)kipped? \n').lower()
             result_types = {'p':'PASSED',
-                                'f':'FAILED',
-                                'b':'BLOCKED',
-                                's':'SKIPPED'}
+                            'f':'FAILED',
+                            'b':'BLOCKED',
+                            's':'SKIPPED'}
             if done in result_types:
                 for r in result_types:
                     if done == r:
                         res = result_types[r]
                         if res == 'FAILED':
                             log_input = input('\nPlease enter the error and the description of the log: (Ex:log:211 Error Bitbake)\n')
-                            test_result.update({self.test_cases_id[test_id]: {'status': '%s' % res, 'log': '%s' % log_input}})
+                            test_result.update({test['test']['@alias']: {'status': '%s' % res, 'log': '%s' % log_input}})
                         else:
-                            test_result.update({self.test_cases_id[test_id]: {'status': '%s' % res}})
+                            test_result.update({test['test']['@alias']: {'status': '%s' % res}})
                 break
             print('Invalid input!')
         return test_result
@@ -120,9 +105,9 @@ class ManualTestRunner(object):
         self._create_result_id()
         self._create_write_dir()
         test_results = {}
-        print('\nTotal number of test cases in this test suite: ' + '%s\n' % len(self.jdata))
-        for i in range(0, len(self.jdata)):
-            test_result = self._execute_test_steps(i)
+        print('\nTotal number of test cases in this test suite: %s\n' % len(self.jdata))
+        for t in self.jdata:
+            test_result = self._execute_test_steps(t)
             test_results.update(test_result)
         return self.configuration, self.result_id, self.write_dir, test_results
 
@@ -130,8 +115,7 @@ def manualexecution(args, logger):
     testrunner = ManualTestRunner()
     get_configuration, get_result_id, get_write_dir, get_test_results = testrunner.run_test(args.file)
     resultjsonhelper = OETestResultJSONHelper()
-    resultjsonhelper.dump_testresult_file(get_write_dir, get_configuration, get_result_id,
-                                          get_test_results)
+    resultjsonhelper.dump_testresult_file(get_write_dir, get_configuration, get_result_id, get_test_results)
     return 0
 
 def register_commands(subparsers):
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-04  9:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-04  8:48 [PATCH 0/4] resulttool/manualexecution: Enhancement and fixes Yeoh Ee Peng
2019-04-04  8:48 ` [PATCH 1/4] resulttool/manualexecution: Standardize input check Yeoh Ee Peng
2019-04-04  8:48 ` [PATCH 2/4] resulttool/manualexecution: Enable display full steps without press enter Yeoh Ee Peng
2019-04-04  8:48 ` [PATCH 3/4] resulttool/manualexecution: Fixed step sorted by integer Yeoh Ee Peng
2019-04-04  8:48 ` [PATCH 4/4] resulttool/manualexecution: Refactor and simplify codebase Yeoh Ee Peng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.