Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildstream
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
BuildStream
buildstream
Commits
f29cd0f3
Commit
f29cd0f3
authored
6 years ago
by
Gökçen Nurlu
Browse files
Options
Downloads
Patches
Plain Diff
test
parent
9c2f9bf7
No related branches found
No related tags found
No related merge requests found
Pipeline
#35251076
failed
6 years ago
Stage: prepare
Stage: test
Stage: post
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/testutils/runcli.py
+9
-43
9 additions, 43 deletions
tests/testutils/runcli.py
with
9 additions
and
43 deletions
tests/testutils/runcli.py
+
9
−
43
View file @
f29cd0f3
...
...
@@ -7,6 +7,7 @@ import itertools
import
traceback
import
subprocess
from
contextlib
import
contextmanager
,
ExitStack
from
click.testing
import
CliRunner
from
ruamel
import
yaml
import
pytest
...
...
@@ -185,9 +186,10 @@ class Result():
return
list
(
pulled
)
class
Cli
():
class
Cli
(
CliRunner
):
def
__init__
(
self
,
directory
,
verbose
=
True
,
default_options
=
None
):
super
().
__init__
(
mix_stderr
=
False
)
self
.
directory
=
directory
self
.
config
=
None
self
.
verbose
=
verbose
...
...
@@ -297,49 +299,13 @@ class Cli():
return
result
def
invoke
(
self
,
cli
,
args
=
None
,
color
=
False
,
binary_capture
=
False
,
**
extra
):
exc_info
=
None
exception
=
None
exit_code
=
0
# Temporarily redirect sys.stdin to /dev/null to ensure that
# Popen doesn't attempt to read pytest's dummy stdin.
old_stdin
=
sys
.
stdin
with
open
(
os
.
devnull
)
as
devnull
:
sys
.
stdin
=
devnull
capture_kind
=
FDCaptureBinary
if
binary_capture
else
FDCapture
capture
=
MultiCapture
(
out
=
True
,
err
=
True
,
in_
=
False
,
Capture
=
capture_kind
)
capture
.
start_capturing
()
r
=
super
().
invoke
(
cli
,
args
,
color
=
color
)
try
:
cli
.
main
(
args
=
args
or
(),
prog_name
=
cli
.
name
,
**
extra
)
except
SystemExit
as
e
:
if
e
.
code
!=
0
:
exception
=
e
exc_info
=
sys
.
exc_info
()
exit_code
=
e
.
code
if
not
isinstance
(
exit_code
,
int
):
sys
.
stdout
.
write
(
'
Program exit code was not an integer:
'
)
sys
.
stdout
.
write
(
str
(
exit_code
))
sys
.
stdout
.
write
(
'
\n
'
)
exit_code
=
1
except
Exception
as
e
:
exception
=
e
exit_code
=
-
1
exc_info
=
sys
.
exc_info
()
finally
:
sys
.
stdout
.
flush
()
sys
.
stdin
=
old_stdin
out
,
err
=
capture
.
readouterr
()
capture
.
stop_capturing
()
return
Result
(
exit_code
=
exit_code
,
exception
=
exception
,
exc_info
=
exc_info
,
output
=
out
,
stderr
=
err
)
return
Result
(
exit_code
=
r
.
exit_code
,
exception
=
r
.
exception
,
exc_info
=
r
.
exc_info
,
output
=
r
.
stdout
,
stderr
=
r
.
stderr
)
# Fetch an element state by name by
# invoking bst show on the project with the CLI
...
...
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