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
e99eeb19
Commit
e99eeb19
authored
Mar 03, 2021
by
Bogdan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created venv for testing.py
parent
f6af0a8e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
11 deletions
+24
-11
testing.py
bin/testing.py
+24
-11
.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 @
e99eeb19
...
@@ -4,7 +4,6 @@ import importlib.util
...
@@ -4,7 +4,6 @@ import importlib.util
import
pathlib
import
pathlib
import
shutil
import
shutil
import
re
import
re
'''
'''
This script searches for all 'tests/' directories and executes all tests
This script searches for all 'tests/' directories and executes all tests
by cd'ing into the dir and executing unittest discover.
by cd'ing into the dir and executing unittest discover.
...
@@ -12,16 +11,21 @@ It additionally installs all dependencies from a '../requirements.txt' via pip.
...
@@ -12,16 +11,21 @@ It additionally installs all dependencies from a '../requirements.txt' via pip.
Use command line argument '-w' to run on windows.
Use command line argument '-w' to run on windows.
'''
'''
PY
=
sys
.
argv
[
2
]
if
(
len
(
sys
.
argv
)
>
1
and
sys
.
argv
[
1
]
==
'-py'
)
else
'python'
# use -py to use your own python command
PY
=
sys
.
argv
[
2
]
if
(
len
(
sys
.
argv
)
>
1
and
sys
.
argv
[
1
]
==
'-py'
)
else
'python
3.7
'
# use -py to use your own python command
ROOT
=
pathlib
.
Path
(
__file__
)
.
parent
.
parent
.
absolute
()
ROOT
=
pathlib
.
Path
(
__file__
)
.
parent
.
parent
.
absolute
()
REPORTS
=
ROOT
/
'reports'
REPORTS
=
ROOT
/
'reports'
TESTS_FOLDER_NAME
=
os
.
path
.
normpath
(
"/tests"
)
TESTS_FOLDER_NAME
=
os
.
path
.
normpath
(
"/tests"
)
print
(
"Creating VENV"
)
os
.
system
(
f
"{PY} -m venv venv"
)
PY
=
f
"~/smart/venv/bin/{PY}"
print
(
"
\n
Searching for tests at the path: "
+
str
(
ROOT
))
print
(
"
\n
Searching for tests at the path: "
+
str
(
ROOT
))
count
=
0
count
=
0
resultCodeList
=
[]
resultCodeList
=
[]
coverage_paths_set
=
set
()
microservice_
coverage_paths_set
=
set
()
for
(
dirname
,
dirs
,
files
)
in
os
.
walk
(
ROOT
):
for
(
dirname
,
dirs
,
files
)
in
os
.
walk
(
ROOT
):
#I assume all the tests are placed in a folder named "tests"
#I assume all the tests are placed in a folder named "tests"
...
@@ -37,8 +41,8 @@ for (dirname, dirs, files) in os.walk(ROOT):
...
@@ -37,8 +41,8 @@ for (dirname, dirs, files) in os.walk(ROOT):
exit_val
=
os
.
system
(
f
"{PY} -m pip install -r ../requirements.txt"
)
# install pip dependencies
exit_val
=
os
.
system
(
f
"{PY} -m pip install -r ../requirements.txt"
)
# install pip dependencies
#resultCodeList.append(exit_val)
#resultCodeList.append(exit_val)
#exit_val = os.system(f"{PY} -m unittest discover") # execute the tests
#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
exit_val
=
os
.
system
(
f
"
{PY}
-m coverage run --append --omit=*/site-packages*,*/dist-packages* -m unittest discover"
)
#TEST CODE COVERAGE
coverage_paths_set
.
add
(
os
.
path
.
normpath
(
dirname
))
microservice_
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
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
:
except
Exception
as
e
:
...
@@ -56,8 +60,8 @@ for (dirname, dirs, files) in os.walk(ROOT):
...
@@ -56,8 +60,8 @@ for (dirname, dirs, files) in os.walk(ROOT):
#cur_dir = os.path(dirname).parent()
#cur_dir = os.path(dirname).parent()
os
.
chdir
(
cur_dir
)
os
.
chdir
(
cur_dir
)
print
(
f
"Executing coverage test in {cur_dir}"
)
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"
)
exit_val
=
os
.
system
(
f
"
{PY}
-m coverage run --append --omit=*/site-packages* -m unittest discover"
)
coverage_paths_set
.
add
(
os
.
path
.
normpath
(
cur_dir
))
microservice_
coverage_paths_set
.
add
(
os
.
path
.
normpath
(
cur_dir
))
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
print
(
e
)
...
@@ -83,7 +87,7 @@ except Exception as e:
...
@@ -83,7 +87,7 @@ except Exception as e:
print
(
"Combinging coverages"
)
print
(
"Combinging coverages"
)
counter
=
0
counter
=
0
for
path
in
coverage_paths_set
:
for
path
in
microservice_
coverage_paths_set
:
try
:
try
:
path
+=
'/.coverage'
path
+=
'/.coverage'
original
=
os
.
path
.
normpath
(
path
)
original
=
os
.
path
.
normpath
(
path
)
...
@@ -96,11 +100,20 @@ for path in coverage_paths_set:
...
@@ -96,11 +100,20 @@ for path in coverage_paths_set:
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
print
(
e
)
continue
continue
try
:
coverage_xml_path
=
os
.
path
.
normpah
(
str
(
REPORTS
)
+
'/coverage.xml'
)
os
.
remove
(
coverage_xml_path
)
coverage_html_path
=
os
.
path
.
normpah
(
str
(
REPORTS
)
+
'/htmlcov'
)
os
.
rmdir
(
coverage_html_path
)
except
Exception
as
e
:
print
(
e
)
print
(
"Generating Combined report"
)
print
(
"Generating Combined report"
)
os
.
system
(
"python3.7
-m coverage combine"
)
os
.
system
(
f
"{PY}
-m coverage combine"
)
os
.
system
(
"python3.7
-m coverage xml"
)
os
.
system
(
f
"{PY}
-m coverage xml"
)
os
.
system
(
"python3.7
-m coverage html"
)
#if you want to generate the html as well
os
.
system
(
f
"{PY}
-m coverage html"
)
#if you want to generate the html as well
firstError
=
-
1
firstError
=
-
1
i
=
0
i
=
0
...
...
src/data-hub/role-stage-discovery-microservice/app/.coverage
deleted
100644 → 0
View file @
f6af0a8e
File deleted
src/data-hub/role-stage-discovery-microservice/app/tests/.coverage
deleted
100644 → 0
View file @
f6af0a8e
File deleted
src/data-hub/semantic-linking-microservice/app/tests/.coverage
deleted
100644 → 0
View file @
f6af0a8e
File deleted
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