Skip to content

Commit 55246e9

Browse files
committed
new: add test for empty input from stdin
1 parent c8902c7 commit 55246e9

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

tests/test_empty_input.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
try:
2+
from cStringIO import StringIO
3+
except ImportError:
4+
from io import StringIO
5+
6+
from cwltool.main import main
7+
from .util import get_data, temp_dir, windows_needs_docker
8+
9+
@windows_needs_docker
10+
def test_empty_input():
11+
empty_json = '{}'
12+
empty_input = StringIO(empty_json)
13+
14+
with temp_dir() as tmpdir:
15+
params = ['--outdir', tmpdir, get_data('tests/wf/no-parameters-echo.cwl'), '-']
16+
17+
try:
18+
assert main(params, stdin=empty_input) == 0
19+
except SystemExit as err:
20+
assert err.code == 0

tests/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import shutil
88
import contextlib
99
import tempfile
10+
import shutil
1011
from typing import Text
1112

1213
from pkg_resources import (Requirement, ResolutionError, # type: ignore

tests/wf/no-parameters-echo.cwl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env cwl-runner
2+
cwlVersion: v1.0
3+
class: CommandLineTool
4+
doc: "This is a tool that can be launched without parameters"
5+
baseCommand: [echo]
6+
inputs:
7+
in:
8+
type: string
9+
default: "foo"
10+
outputs:
11+
e_out:
12+
type: stdout

0 commit comments

Comments
 (0)