Unittest adaptions to improve project structure
This commit is contained in:
parent
547fb39ec5
commit
279a524eb6
12
run.py
12
run.py
@ -273,7 +273,7 @@ def unittest_run(unittest_folder, options):
|
||||
execution_level = report.TCEL_REVERSE_NAMED.get(options.execution_level, report.TCEL_FULL)
|
||||
#
|
||||
if sys.version_info.major in config.lib.__INTERPRETER__:
|
||||
print_header("Running Unittest with %s" % interpreter_version)
|
||||
print_header("Running \"%s\" Unittest with %s" % (options.execution_level, interpreter_version))
|
||||
print_action('Loading Testrun data from %s' % unittest_filename(unittest_folder, FILES['data-collection']))
|
||||
with open(unittest_filename(unittest_folder, FILES['data-collection']), 'r') as fh:
|
||||
data_collection = json.loads(fh.read())
|
||||
@ -456,11 +456,15 @@ def unittest_copy(unittest_folder):
|
||||
|
||||
|
||||
def unittest_release(unittest_folder):
|
||||
with open(os.path.join(unittest_folder, 'src', 'config.py'), 'r') as fh:
|
||||
unittest_uid = module_uid(os.path.join(unittest_folder, 'src', 'tests'))
|
||||
config_file = os.path.join(unittest_folder, 'src', 'config.py')
|
||||
print_header('Releasing unittest')
|
||||
with open(config_file, 'r') as fh:
|
||||
conf_file = fh.read()
|
||||
with open(os.path.join(unittest_folder, 'src', 'config.py'), 'w') as fh:
|
||||
print_action('Setting release_unittest_version = %s in %s' % (unittest_uid, config_file))
|
||||
with open(config_file, 'w') as fh:
|
||||
for line in conf_file.splitlines():
|
||||
if line.startswith('release_unittest_version'):
|
||||
fh.write("release_unittest_version = '%s'\n" % module_uid(os.path.join(unittest_folder, 'src', 'tests')))
|
||||
fh.write("release_unittest_version = '%s'\n" % unittest_uid)
|
||||
else:
|
||||
fh.write(line + '\n')
|
||||
|
20
scripts/unittest.py
Normal file
20
scripts/unittest.py
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
import sys
|
||||
sys.path.insert(0, 'src')
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import report
|
||||
import tests
|
||||
import unittest
|
||||
|
||||
parser = optparse.OptionParser("usage: %prog [clean|run|coverage|pdf|copy|release]")
|
||||
parser.add_option("-e", "--execution-level", dest="execution_level", default="full", help="sets the execution level [full | short | smoke | single]")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if report.TCEL_REVERSE_NAMED.get(tests.execution_level, report.TCEL_FULL) < report.TCEL_REVERSE_NAMED.get(options.execution_level, report.TCEL_FULL):
|
||||
options.execution_level = tests.execution_level
|
||||
|
||||
unittest.run.unittest(options, args, os.path.abspath(os.path.join(os.path.dirname(__file__))))
|
47
scripts/unittest.sh
Executable file
47
scripts/unittest.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Set commands depending on distribution
|
||||
#
|
||||
. /etc/os-release
|
||||
# python2
|
||||
if [[ "$ID" == "arch" || "$ID" == "manjaro" || "$ID_LIKE" == *"opensuse"* || "$ID" == "solus" ]]; then
|
||||
COV2_CMD="coverage2"
|
||||
PYT2_CMD="python2"
|
||||
else
|
||||
COV2_CMD="python2-coverage"
|
||||
PYT2_CMD="python2"
|
||||
fi
|
||||
# python3
|
||||
if [[ "$ID" == "arch" || "$ID" == "manjaro" || "$ID_LIKE" == *"opensuse"* || "$ID" == "solus" ]]; then
|
||||
COV3_CMD="coverage3"
|
||||
PYT3_CMD="python3"
|
||||
else
|
||||
COV3_CMD="python3-coverage"
|
||||
PYT3_CMD="python3"
|
||||
fi
|
||||
# pdf viewer
|
||||
PDF_CMD="xdg-open"
|
||||
|
||||
if [[ $# -eq 0 || ($# -eq 2 && $1 == '-e') ]]; then
|
||||
#
|
||||
# Unittest Flow
|
||||
#
|
||||
$PYT3_CMD unittest.py clean
|
||||
echo -e "\e[1m * Erasing collected coverage information\e[0m"
|
||||
$COV2_CMD erase
|
||||
$COV2_CMD run -a --branch --source=$($PYT3_CMD src/config.py -p) unittest.py run $*
|
||||
$COV3_CMD run -a --branch --source=$($PYT3_CMD src/config.py -p) unittest.py run $*
|
||||
echo -e "\e[1m\e[93mCreating Coverage-XML-File: $(pwd)/testresults/coverage.xml\e[0m"
|
||||
$COV3_CMD xml -o testresults/coverage.xml
|
||||
$PYT3_CMD unittest.py finalise
|
||||
$PYT3_CMD unittest.py status
|
||||
$PYT3_CMD unittest.py pdf
|
||||
$PDF_CMD testresults/unittest.pdf
|
||||
else
|
||||
$PYT3_CMD unittest.py $*
|
||||
fi
|
||||
|
||||
|
||||
exit 0
|
||||
|
@ -1,39 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Set commands depending on distribution
|
||||
#
|
||||
. /etc/os-release
|
||||
# python2
|
||||
if [[ "$ID" == "arch" || "$ID" == "manjaro" || "$ID_LIKE" == *"opensuse"* || "$ID" == "solus" ]]; then
|
||||
COV2_CMD="coverage2"
|
||||
PYT2_CMD="python2"
|
||||
else
|
||||
COV2_CMD="python2-coverage"
|
||||
PYT2_CMD="python2"
|
||||
fi
|
||||
# python3
|
||||
if [[ "$ID" == "arch" || "$ID" == "manjaro" || "$ID_LIKE" == *"opensuse"* || "$ID" == "solus" ]]; then
|
||||
COV3_CMD="coverage3"
|
||||
PYT3_CMD="python3"
|
||||
else
|
||||
COV3_CMD="python3-coverage"
|
||||
PYT3_CMD="python3"
|
||||
fi
|
||||
# pdf viewer
|
||||
PDF_CMD="xdg-open"
|
||||
|
||||
#
|
||||
# Unittest Flow
|
||||
#
|
||||
$PYT3_CMD src/unittest.py clean
|
||||
echo -e "\e[1m * Erasing collected coverage information\e[0m"
|
||||
$COV2_CMD erase
|
||||
$COV2_CMD run -a --branch --source=$($PYT3_CMD src/config.py -p) src/unittest.py run $*
|
||||
$COV3_CMD run -a --branch --source=$($PYT3_CMD src/config.py -p) src/unittest.py run $*
|
||||
echo -e "\e[1m\e[93mCreating Coverage-XML-File: $(pwd)/testresults/coverage.xml\e[0m"
|
||||
$COV3_CMD xml -o testresults/coverage.xml
|
||||
$PYT3_CMD src/unittest.py finalise
|
||||
$PYT3_CMD src/unittest.py status
|
||||
$PYT3_CMD src/unittest.py pdf
|
||||
$PDF_CMD testresults/unittest.pdf
|
Loading…
x
Reference in New Issue
Block a user