Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HyperLoom
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
ADAS
HyperLoom
Commits
e9bd2f8e
Commit
e9bd2f8e
authored
Oct 12, 2016
by
Stanislav Bohm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: Reporting non-zero exit code from loom/run task
parent
8a1d192c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
4 deletions
+31
-4
src/libloom/tasks/runtask.cpp
src/libloom/tasks/runtask.cpp
+22
-2
tests/client/fail_test.py
tests/client/fail_test.py
+9
-2
No files found.
src/libloom/tasks/runtask.cpp
View file @
e9bd2f8e
...
...
@@ -8,6 +8,7 @@
#include "loomrun.pb.h"
#include <sstream>
#include <fstream>
using
namespace
loom
;
...
...
@@ -108,7 +109,8 @@ void RunTask::start(DataVector &inputs)
if
(
stderr_fd
<
0
)
{
log_errno_abort
(
"open +err:"
);
}
stdio
[
2
].
flags
=
UV_IGNORE
;
stdio
[
2
].
flags
=
UV_INHERIT_FD
;
stdio
[
2
].
data
.
fd
=
stderr_fd
;
int
r
;
...
...
@@ -147,7 +149,25 @@ void RunTask::_on_close(uv_handle_t *handle)
{
RunTask
*
task
=
static_cast
<
RunTask
*>
(
handle
->
data
);
llog
->
debug
(
"Process id={} finished (exit_status={})"
,
task
->
get_id
(),
task
->
exit_status
);
assert
(
task
->
exit_status
==
0
);
if
(
task
->
exit_status
)
{
std
::
stringstream
s
;
s
<<
"Program terminated with status "
<<
task
->
exit_status
;
s
<<
"
\n
Stderr:
\n
"
;
std
::
ifstream
err
(
task
->
get_path
(
"+err"
).
c_str
());
assert
(
err
.
is_open
());
int
max_buffer_size
=
128
*
1024
;
auto
buffer
=
std
::
make_unique
<
char
[]
>
(
max_buffer_size
);
err
.
read
(
buffer
.
get
(),
max_buffer_size
);
s
.
write
(
buffer
.
get
(),
err
.
gcount
());
if
(
err
.
gcount
()
==
max_buffer_size
)
{
s
<<
"
\n
... stderr truncated by Loom"
;
}
task
->
fail
(
s
.
str
());
return
;
}
loomrun
::
Run
msg
;
msg
.
ParseFromString
(
task
->
task
->
get_config
());
std
::
unique_ptr
<
Data
>
result
;
...
...
tests/client/fail_test.py
View file @
e9bd2f8e
from
loomenv
import
loom_env
,
LOOM_TESTPROG
,
LOOM_TEST_DATA_DIR
# noqa
from
datetime
import
datetime
import
os
import
client
import
pytest
...
...
@@ -15,3 +13,12 @@ def test_invalid_program(loom_env):
with
pytest
.
raises
(
client
.
TaskFailed
):
loom_env
.
submit
(
p
,
a
)
def
test_program_failed
(
loom_env
):
loom_env
.
start
(
1
)
p
=
loom_env
.
plan
()
a
=
p
.
task_run
(
"ls /non-existing-dictionary"
)
with
pytest
.
raises
(
client
.
TaskFailed
):
loom_env
.
submit
(
p
,
a
)
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