소스 검색

Unittest adaptions to improve project structure

master
Dirk Alders 5 년 전
부모
커밋
279a524eb6
4개의 변경된 파일75개의 추가작업 그리고 43개의 파일을 삭제
  1. 8
    4
      run.py
  2. 20
    0
      scripts/unittest.py
  3. 47
    0
      scripts/unittest.sh
  4. 0
    39
      unittest_flow.sh

+ 8
- 4
run.py 파일 보기

@@ -273,7 +273,7 @@ def unittest_run(unittest_folder, options):
273 273
     execution_level = report.TCEL_REVERSE_NAMED.get(options.execution_level, report.TCEL_FULL)
274 274
     #
275 275
     if sys.version_info.major in config.lib.__INTERPRETER__:
276
-        print_header("Running Unittest with %s" % interpreter_version)
276
+        print_header("Running \"%s\" Unittest with %s" % (options.execution_level, interpreter_version))
277 277
         print_action('Loading Testrun data from %s' % unittest_filename(unittest_folder, FILES['data-collection']))
278 278
         with open(unittest_filename(unittest_folder, FILES['data-collection']), 'r') as fh:
279 279
             data_collection = json.loads(fh.read())
@@ -456,11 +456,15 @@ def unittest_copy(unittest_folder):
456 456
 
457 457
 
458 458
 def unittest_release(unittest_folder):
459
-    with open(os.path.join(unittest_folder, 'src', 'config.py'), 'r') as fh:
459
+    unittest_uid = module_uid(os.path.join(unittest_folder, 'src', 'tests'))
460
+    config_file = os.path.join(unittest_folder, 'src', 'config.py')
461
+    print_header('Releasing unittest')
462
+    with open(config_file, 'r') as fh:
460 463
         conf_file = fh.read()
461
-    with open(os.path.join(unittest_folder, 'src', 'config.py'), 'w') as fh:
464
+    print_action('Setting release_unittest_version = %s in %s' % (unittest_uid, config_file))
465
+    with open(config_file, 'w') as fh:
462 466
         for line in conf_file.splitlines():
463 467
             if line.startswith('release_unittest_version'):
464
-                fh.write("release_unittest_version = '%s'\n" % module_uid(os.path.join(unittest_folder, 'src', 'tests')))
468
+                fh.write("release_unittest_version = '%s'\n" % unittest_uid)
465 469
             else:
466 470
                 fh.write(line + '\n')

+ 20
- 0
scripts/unittest.py 파일 보기

@@ -0,0 +1,20 @@
1
+#!/usr/bin/env python
2
+# -*- coding: utf-8 -*-
3
+#
4
+import sys
5
+sys.path.insert(0, 'src')
6
+
7
+import optparse
8
+import os
9
+import report
10
+import tests
11
+import unittest
12
+
13
+parser = optparse.OptionParser("usage: %prog [clean|run|coverage|pdf|copy|release]")
14
+parser.add_option("-e", "--execution-level", dest="execution_level", default="full", help="sets the execution level [full | short | smoke | single]")
15
+(options, args) = parser.parse_args()
16
+
17
+if report.TCEL_REVERSE_NAMED.get(tests.execution_level, report.TCEL_FULL) < report.TCEL_REVERSE_NAMED.get(options.execution_level, report.TCEL_FULL):
18
+    options.execution_level = tests.execution_level
19
+
20
+unittest.run.unittest(options, args, os.path.abspath(os.path.join(os.path.dirname(__file__))))

+ 47
- 0
scripts/unittest.sh 파일 보기

@@ -0,0 +1,47 @@
1
+#!/bin/bash
2
+
3
+#
4
+# Set commands depending on distribution
5
+#
6
+. /etc/os-release
7
+# python2
8
+if [[ "$ID" == "arch" || "$ID" == "manjaro" || "$ID_LIKE" == *"opensuse"*  || "$ID" == "solus" ]]; then
9
+    COV2_CMD="coverage2"
10
+    PYT2_CMD="python2"
11
+else
12
+    COV2_CMD="python2-coverage"
13
+    PYT2_CMD="python2"
14
+fi
15
+# python3
16
+if [[ "$ID" == "arch" || "$ID" == "manjaro" || "$ID_LIKE" == *"opensuse"* || "$ID" == "solus" ]]; then
17
+    COV3_CMD="coverage3"
18
+    PYT3_CMD="python3"
19
+else
20
+    COV3_CMD="python3-coverage"
21
+    PYT3_CMD="python3"
22
+fi
23
+# pdf viewer
24
+PDF_CMD="xdg-open"
25
+
26
+if [[ $# -eq 0 || ($# -eq 2 && $1 == '-e') ]]; then
27
+	#
28
+	# Unittest Flow
29
+	#
30
+	$PYT3_CMD unittest.py clean
31
+	echo -e "\e[1m  * Erasing collected coverage information\e[0m"
32
+	$COV2_CMD erase
33
+	$COV2_CMD run -a --branch --source=$($PYT3_CMD src/config.py -p) unittest.py run $*
34
+	$COV3_CMD run -a --branch --source=$($PYT3_CMD src/config.py -p) unittest.py run $*
35
+	echo -e "\e[1m\e[93mCreating Coverage-XML-File: $(pwd)/testresults/coverage.xml\e[0m"
36
+	$COV3_CMD xml -o testresults/coverage.xml
37
+	$PYT3_CMD unittest.py finalise
38
+	$PYT3_CMD unittest.py status
39
+	$PYT3_CMD unittest.py pdf
40
+	$PDF_CMD testresults/unittest.pdf
41
+else
42
+	$PYT3_CMD unittest.py $*
43
+fi
44
+
45
+
46
+exit 0
47
+

+ 0
- 39
unittest_flow.sh 파일 보기

@@ -1,39 +0,0 @@
1
-#!/bin/bash
2
-
3
-#
4
-# Set commands depending on distribution
5
-#
6
-. /etc/os-release
7
-# python2
8
-if [[ "$ID" == "arch" || "$ID" == "manjaro" || "$ID_LIKE" == *"opensuse"*  || "$ID" == "solus" ]]; then
9
-    COV2_CMD="coverage2"
10
-    PYT2_CMD="python2"
11
-else
12
-    COV2_CMD="python2-coverage"
13
-    PYT2_CMD="python2"
14
-fi
15
-# python3
16
-if [[ "$ID" == "arch" || "$ID" == "manjaro" || "$ID_LIKE" == *"opensuse"* || "$ID" == "solus" ]]; then
17
-    COV3_CMD="coverage3"
18
-    PYT3_CMD="python3"
19
-else
20
-    COV3_CMD="python3-coverage"
21
-    PYT3_CMD="python3"
22
-fi
23
-# pdf viewer
24
-PDF_CMD="xdg-open"
25
-
26
-#
27
-# Unittest Flow
28
-#
29
-$PYT3_CMD src/unittest.py clean
30
-echo -e "\e[1m  * Erasing collected coverage information\e[0m"
31
-$COV2_CMD erase
32
-$COV2_CMD run -a --branch --source=$($PYT3_CMD src/config.py -p) src/unittest.py run $*
33
-$COV3_CMD run -a --branch --source=$($PYT3_CMD src/config.py -p) src/unittest.py run $*
34
-echo -e "\e[1m\e[93mCreating Coverage-XML-File: $(pwd)/testresults/coverage.xml\e[0m"
35
-$COV3_CMD xml -o testresults/coverage.xml
36
-$PYT3_CMD src/unittest.py finalise
37
-$PYT3_CMD src/unittest.py status
38
-$PYT3_CMD src/unittest.py pdf
39
-$PDF_CMD testresults/unittest.pdf

Loading…
취소
저장