浏览代码

publish conditions implemented

master
Dirk Alders 3 年前
父节点
当前提交
5417bf1cba
共有 3 个文件被更改,包括 38 次插入18 次删除
  1. 8
    4
      jsonlog.py
  2. 2
    0
      output.py
  3. 28
    14
      run.py

+ 8
- 4
jsonlog.py 查看文件

4
 
4
 
5
 import json
5
 import json
6
 import os
6
 import os
7
+import report
7
 import subprocess
8
 import subprocess
8
 
9
 
9
 import fstools
10
 import fstools
10
-from unittest.output import STATUS_AVAILABLE, STATUS_CHANGED, STATUS_CLEAN, STATUS_EXISTS, STATUS_FAILED, STATUS_IN_WORK, STATUS_MISSING, STATUS_OLD, STATUS_RELEASED, STATUS_UNKNOWN
11
+from unittest.output import STATUS_AVAILABLE, STATUS_CHANGED, STATUS_CLEAN, STATUS_EXISTS, STATUS_FAILED, STATUS_IN_WORK, STATUS_MISSING, STATUS_OLD, STATUS_RELEASED, STATUS_UNKNOWN, STATUS_INCOMPLETE
11
 
12
 
12
 JSONLOG_FNAME = 'unittest.json'
13
 JSONLOG_FNAME = 'unittest.json'
13
 
14
 
65
 # SUBKEYS FOR MAIN_KEY_TESTRUNS
66
 # SUBKEYS FOR MAIN_KEY_TESTRUNS
66
 #
67
 #
67
 TRUN_TESTCASES = 'testcases'
68
 TRUN_TESTCASES = 'testcases'
69
+TRUN_EXEC_LVL = 'testcase_execution_level'
68
 #
70
 #
69
 # SUBKEYS FOR MAIN_KEY_UNITTEST_INFO
71
 # SUBKEYS FOR MAIN_KEY_UNITTEST_INFO
70
 #
72
 #
123
         return STATUS_MISSING
125
         return STATUS_MISSING
124
     else:
126
     else:
125
         ut_status = ut_data.get(MAIN_KEY_TESTOBJECT_INFO, {}).get(TOBI_STATE, 'unknown')
127
         ut_status = ut_data.get(MAIN_KEY_TESTOBJECT_INFO, {}).get(TOBI_STATE, 'unknown')
126
-        if ut_status == TOBI_STATE_RELEASED:
128
+        ut_level = ut_data.get(MAIN_KEY_TESTRUNS, [{}, {}])[0].get(TRUN_EXEC_LVL, report.TCEL_SINGLE)
129
+        if ut_status == TOBI_STATE_RELEASED and ut_level == report.TCEL_FULL:
127
             return STATUS_RELEASED
130
             return STATUS_RELEASED
128
-        elif ut_status == TOBI_STATE_IN_DEVELOPMENT:
131
+        elif ut_status != TOBI_STATE_RELEASED:
129
             return STATUS_IN_WORK
132
             return STATUS_IN_WORK
133
+        elif ut_level != report.TCEL_FULL:
134
+            return STATUS_INCOMPLETE
130
         else:
135
         else:
131
-            print(ut_status)
132
             return STATUS_UNKNOWN
136
             return STATUS_UNKNOWN
133
 
137
 
134
 
138
 

+ 2
- 0
output.py 查看文件

14
 STATUS_EXISTS = 'EXISTS'
14
 STATUS_EXISTS = 'EXISTS'
15
 STATUS_IN_WORK = 'IN_WORK'
15
 STATUS_IN_WORK = 'IN_WORK'
16
 STATUS_OLD = 'OLD'
16
 STATUS_OLD = 'OLD'
17
+STATUS_INCOMPLETE = 'INCOMPLETE'
17
 #
18
 #
18
 STATUS_FAILED = 'FAILED'
19
 STATUS_FAILED = 'FAILED'
19
 STATUS_MISSING = 'MISSING'
20
 STATUS_MISSING = 'MISSING'
41
     STATUS_EXISTS: termcolors.WARNING,
42
     STATUS_EXISTS: termcolors.WARNING,
42
     STATUS_IN_WORK: termcolors.WARNING,
43
     STATUS_IN_WORK: termcolors.WARNING,
43
     STATUS_OLD: termcolors.WARNING,
44
     STATUS_OLD: termcolors.WARNING,
45
+    STATUS_INCOMPLETE: termcolors.WARNING,
44
     #
46
     #
45
     STATUS_FAILED: termcolors.FAIL,
47
     STATUS_FAILED: termcolors.FAIL,
46
     STATUS_MISSING: termcolors.FAIL,
48
     STATUS_MISSING: termcolors.FAIL,

+ 28
- 14
run.py 查看文件

325
 
325
 
326
 def unittest_publish(ut_folder):
326
 def unittest_publish(ut_folder):
327
     config = imp.load_source('', jsonlog.get_ut_config(ut_folder))
327
     config = imp.load_source('', jsonlog.get_ut_config(ut_folder))
328
-    #
329
-    output.print_header('Copy unittest files to library')
330
-    target_folder = os.path.join(config.lib_path, '_testresults_')
331
-    output.print_action('Copying Unittest Files to  %s' % target_folder)
332
-    if not os.path.exists(target_folder):
333
-        output.print_info('Creating folder %s' % target_folder)
334
-        fstools.mkdir(target_folder)
328
+    output.print_header('Checking testrun state')
329
+    output.print_action('Release State...')
330
+    rs = jsonlog.get_ut_release_state(ut_folder)
331
+    output.print_info(rs)
332
+    output.print_action('Testcase Integrity...')
333
+    tci = jsonlog.get_ut_testcase_integrity(ut_folder)
334
+    output.print_info(tci)
335
+    output.print_action('Source Integrity...')
336
+    sri = jsonlog.get_ut_src_integrity(ut_folder)
337
+    output.print_info(sri)
338
+
339
+    if rs == jsonlog.STATUS_RELEASED and tci == jsonlog.STATUS_CLEAN and sri == jsonlog.STATUS_CLEAN:
340
+        output.print_header('Copy unittest files to library')
341
+        target_folder = os.path.join(config.lib_path, '_testresults_')
342
+        output.print_action('Copying Unittest Files to  %s' % target_folder)
343
+        if not os.path.exists(target_folder):
344
+            output.print_info('Creating folder %s' % target_folder)
345
+            fstools.mkdir(target_folder)
346
+        else:
347
+            for fn in os.listdir(target_folder):
348
+                remove_file(os.path.join(target_folder, fn))
349
+        for fn in REPORT_FILES:
350
+            src = testresults_filename(ut_folder, fn)
351
+            dst = os.path.join(target_folder, fn)
352
+            output.print_info('copying %s -> %s' % (src, dst))
353
+            shutil.copyfile(src, dst)
335
     else:
354
     else:
336
-        for fn in os.listdir(target_folder):
337
-            remove_file(os.path.join(target_folder, fn))
338
-    for fn in REPORT_FILES:
339
-        src = testresults_filename(ut_folder, fn)
340
-        dst = os.path.join(target_folder, fn)
341
-        output.print_info('copying %s -> %s' % (src, dst))
342
-        shutil.copyfile(src, dst)
355
+        output.print_action('Proceed Conditions...')
356
+        output.print_info(output.STATUS_FAILED)
343
 
357
 
344
 
358
 
345
 def unittest_status(ut_folder):
359
 def unittest_status(ut_folder):

正在加载...
取消
保存