1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import subprocess
import fable
def _run_echo(ctx, args):
cmd = '/bin/echo'
p = subprocess.Popen(
[cmd] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
text=True)
out, err = p.communicate()
ctx["stdout"] = out
ctx["stderr"] = err
ctx["exit_code"] = p.returncode
def run_echo_without_args(ctx):
_run_echo(ctx, [])
def run_echo_with_args(ctx, args=None):
_run_echo(ctx, args.split())
def exit_code_is_zero(ctx, exit_code=None):
exit_code = int(exit_code)
fable.assertEqual(ctx['exit_code'], exit_code)
def stdout_is_a_newline(ctx):
fable.assertEqual(ctx['stdout'], '\n')
def stdout_is_text(ctx, text=None):
fable.assertEqual(ctx['stdout'], text + '\n')
def stderr_is_empty(ctx):
fable.assertEqual(ctx['stderr'], '')
|