Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OS-SWEB-SWET
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ostermayer, Markus
OS-SWEB-SWET
Commits
3656e8fa
Commit
3656e8fa
authored
Oct 26, 2022
by
Ostermayer, Markus
Browse files
Options
Downloads
Patches
Plain Diff
reworked the follow-methode
parent
cf044dc8
No related branches found
No related tags found
1 merge request
!7
reworked the follow-methode
Pipeline
#199553
waiting for manual action
Stage: test
Stage: deploy
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
swet/_testutils.py
+28
-11
28 additions, 11 deletions
swet/_testutils.py
with
28 additions
and
11 deletions
swet/_testutils.py
+
28
−
11
View file @
3656e8fa
...
@@ -67,20 +67,42 @@ def _print_testresult(
...
@@ -67,20 +67,42 @@ def _print_testresult(
print
(
f
'
{
testname
}{
result
}
'
)
print
(
f
'
{
testname
}{
result
}
'
)
def
follow
(
file
,
sleep_sec
=
0.1
)
->
Iterator
[
str
]:
def
follow
(
"""
Yield each line from a file as they are written.
file
,
`sleep_sec` is the time to sleep after empty reads.
"""
sleep_sec
:
float
=
0.5
,
timeout
:
int
=
10
,
use_color
:
bool
=
True
,
)
->
Iterator
[
str
]:
# SRC: https://stackoverflow.com/a/54263201
# SRC: https://stackoverflow.com/a/54263201
line
=
''
line
=
''
idle_time
:
float
=
0.0
sys
.
stdout
.
write
(
'
Executing test ...........
'
)
sys
.
stdout
.
flush
()
while
True
:
while
True
:
tmp
=
file
.
readline
()
tmp
=
file
.
readline
()
if
tmp
is
not
None
:
if
tmp
!=
''
:
line
+=
tmp
line
+=
tmp
if
line
.
endswith
(
'
\n
'
):
if
line
.
endswith
(
'
\n
'
):
yield
line
yield
line
line
=
''
line
=
''
elif
sleep_sec
:
idle_time
=
0
else
:
time
.
sleep
(
sleep_sec
)
time
.
sleep
(
sleep_sec
)
idle_time
+=
sleep_sec
if
idle_time
>
timeout
:
if
use_color
:
sys
.
stdout
.
write
(
(
f
'
{
Colors
.
green
.
value
}
Executed!
'
f
'
{
Colors
.
normal
.
value
}
\n
'
),
)
else
:
sys
.
stdout
.
write
(
'
Executed!
\n
'
)
return
def
execute_test
(
def
execute_test
(
...
@@ -116,17 +138,12 @@ def execute_test(
...
@@ -116,17 +138,12 @@ def execute_test(
with
open
(
with
open
(
f
'
{
build_path
}
/
{
testname
.
filename_without_ending
}
.log
'
,
f
'
{
build_path
}
/
{
testname
.
filename_without_ending
}
.log
'
,
)
as
logfile
:
)
as
logfile
:
for
logline
in
follow
(
logfile
):
for
logline
in
follow
(
logfile
,
use_color
=
True
):
if
'
Assertion failed
'
in
logline
:
if
'
Assertion failed
'
in
logline
:
test_result
=
Result
.
failed
test_result
=
Result
.
failed
break
elif
'
KERNEL PANIC
'
in
logline
:
elif
'
KERNEL PANIC
'
in
logline
:
test_result
=
Result
.
failed
test_result
=
Result
.
failed
break
elif
'
cleanupDeadThreads: done
'
in
logline
:
break
qemu_prozess
.
terminate
()
qemu_prozess
.
terminate
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment