You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
project('run command', 'c')
|
|
|
|
|
|
|
|
c = run_command('echo', 'hello')
|
|
|
|
correct = 'hello'
|
|
|
|
|
|
|
|
if c.returncode() != 0
|
|
|
|
error('Executing echo failed.')
|
|
|
|
endif
|
|
|
|
|
|
|
|
result = c.stdout().strip()
|
|
|
|
|
|
|
|
if result != correct
|
|
|
|
error('Getting stdout failed.')
|
|
|
|
endif
|
|
|
|
|
|
|
|
if c.stderr() != ''
|
|
|
|
error('Extra text in stderr.')
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Now the same with a script.
|
|
|
|
|
|
|
|
cs = run_command('scripts/hello.sh')
|
|
|
|
correct = 'hello'
|
|
|
|
|
|
|
|
if cs.returncode() != 0
|
|
|
|
error('Executing script failed.')
|
|
|
|
endif
|
|
|
|
|
|
|
|
if cs.stdout().strip() != correct
|
|
|
|
error('Getting stdout failed (script).')
|
|
|
|
endif
|
|
|
|
|
|
|
|
if cs.stderr() != ''
|
|
|
|
error('Extra text in stderr (script).')
|
|
|
|
endif
|