Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
4c4c978a
Commit
4c4c978a
authored
Feb 16, 2021
by
Bogdan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed --append bug in testing.py
parent
f77add48
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
16 deletions
+22
-16
testing.py
bin/testing.py
+22
-16
.coverage
src/data-hub/role-stage-discovery-microservice/app/.coverage
+0
-0
.coverage
...hub/role-stage-discovery-microservice/app/tests/.coverage
+0
-0
.coverage
...ata-hub/semantic-linking-microservice/app/tests/.coverage
+0
-0
No files found.
bin/testing.py
View file @
4c4c978a
...
...
@@ -12,13 +12,13 @@ It additionally installs all dependencies from a '../requirements.txt' via pip.
Use command line argument '-w' to run on windows.
'''
PY
=
sys
.
argv
[
2
]
if
(
len
(
sys
.
argv
)
>
1
and
sys
.
argv
[
1
]
==
'-py'
)
else
'python3.7'
# use -py to use your own python command
COVERAGE
=
"python3.7 -m coverage"
PY
=
sys
.
argv
[
2
]
if
(
len
(
sys
.
argv
)
>
1
and
sys
.
argv
[
1
]
==
'-py'
)
else
'python'
# use -py to use your own python command
ROOT
=
pathlib
.
Path
(
__file__
)
.
parent
.
parent
.
absolute
()
REPORTS
=
ROOT
/
'reports'
TESTS_FOLDER_NAME
=
os
.
path
.
normpath
(
"/tests"
)
print
(
"
\n
Searching for tests at the path: "
+
str
(
ROOT
)
+
"
\n
"
)
print
(
"
\n
Searching for tests at the path: "
+
str
(
ROOT
))
count
=
0
resultCodeList
=
[]
coverage_paths_set
=
set
()
...
...
@@ -31,13 +31,15 @@ for (dirname, dirs, files) in os.walk(ROOT):
and
not
(
"venv"
in
str
(
dirname
))
\
and
not
(
"Lib"
in
str
(
dirname
)):
try
:
print
(
f
"Executing tests in {dirname}
\n
"
)
print
(
f
"Executing tests in {dirname}"
)
os
.
chdir
(
os
.
path
.
normpath
(
dirname
))
# TODO do this during docker image setup
exit_val
=
os
.
system
(
f
"{PY} -m pip install -r ../requirements.txt"
)
# install pip dependencies
#exit_val = os.system(f"{PY} -m unittest discover") # OLD execute the tests
exit_val
=
os
.
system
(
f
"{COVERAGE} --append --omit=*/site-packages*,*/dist-packages* -m unittest discover"
)
#TEST CODE COVERAGE
coverage_paths_set
.
add
(
os
.
path
.
normpath
(
dirname
))
#resultCodeList.append(exit_val)
#exit_val = os.system(f"{PY} -m unittest discover") # execute the tests
exit_val
=
os
.
system
(
f
"python3.7 -m coverage run --append --omit=*/site-packages*,*/dist-packages* -m unittest discover"
)
#TEST CODE COVERAGE
coverage_paths_set
.
add
(
os
.
path
.
normpath
(
dirname
))
resultCodeList
.
append
(
exit_val
)
#once per folder i.e if 3 tests are in a folder and crash, there will be just one exit val
except
Exception
as
e
:
print
(
e
)
...
...
@@ -50,28 +52,31 @@ for (dirname, dirs, files) in os.walk(ROOT):
for
filename
in
os
.
listdir
(
cur_dir
):
if
filename_regular_expresion
.
match
(
filename
):
#gets here only if there is a test file which matches the regular expression in the app folder,
#cur_dir = os.path(dirname).parent()
os
.
chdir
(
cur_dir
)
print
(
f
"Executing coverage test in {cur_dir}
\n
"
)
exit_val
=
os
.
system
(
f
"
{COVERAGE}
run --append --omit=*/site-packages* -m unittest discover"
)
print
(
f
"Executing coverage test in {cur_dir}"
)
exit_val
=
os
.
system
(
f
"
python3.7 -m coverage
run --append --omit=*/site-packages* -m unittest discover"
)
coverage_paths_set
.
add
(
os
.
path
.
normpath
(
cur_dir
))
except
Exception
as
e
:
print
(
e
)
continue
#CHANGE FOLDER TO REPORTS, in order to combine the coverage
try
:
if
not
os
.
path
.
exists
(
REPORTS
):
os
.
makedirs
(
REPORTS
)
except
:
pass
try
:
os
.
chdir
(
REPORTS
)
target
=
REPORTS
target
=
os
.
path
.
normpath
(
str
(
target
)
+
f
'/.coverage'
)
except
:
pass
try
:
os
.
remove
(
target
)
#Try to Remove old coverage file, if exists
except
Exception
as
e
:
pass
...
...
@@ -85,6 +90,7 @@ for path in coverage_paths_set:
target
=
REPORTS
target
=
os
.
path
.
normpath
(
str
(
target
)
+
f
'/.coverage.{counter}'
)
counter
+=
1
shutil
.
copyfile
(
original
,
target
)
#copy new generated coverage files
os
.
remove
(
original
)
except
Exception
as
e
:
...
...
@@ -92,15 +98,15 @@ for path in coverage_paths_set:
continue
print
(
"Generating Combined report"
)
os
.
system
(
f
"{COVERAGE}
combine"
)
os
.
system
(
f
"{COVERAGE}
xml"
)
os
.
system
(
f
"{COVERAGE} html"
)
os
.
system
(
"python3.7 -m coverage
combine"
)
os
.
system
(
"python3.7 -m coverage
xml"
)
os
.
system
(
"python3.7 -m coverage html"
)
#if you want to generate the html as well
firstError
=
-
1
i
=
0
while
i
<
len
(
resultCodeList
):
if
resultCodeList
[
i
]
!=
0
:
print
(
"
\n
A test failed with code: "
+
str
(
resultCodeList
[
i
]))
#
print("\nA test failed with code: "+ str(resultCodeList[i]))
if
(
firstError
<
0
):
firstError
=
i
i
+=
1
...
...
src/data-hub/role-stage-discovery-microservice/app/.coverage
0 → 100644
View file @
4c4c978a
File added
src/data-hub/role-stage-discovery-microservice/app/tests/.coverage
0 → 100644
View file @
4c4c978a
File added
src/data-hub/semantic-linking-microservice/app/tests/.coverage
0 → 100644
View file @
4c4c978a
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment