From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- .../test cases/common/33 run program/check-env.py | 6 ++ .../common/33 run program/get-version.py | 3 + meson/test cases/common/33 run program/meson.build | 85 ++++++++++++++++++++++ .../common/33 run program/scripts/hello.bat | 2 + .../common/33 run program/scripts/hello.sh | 3 + 5 files changed, 99 insertions(+) create mode 100644 meson/test cases/common/33 run program/check-env.py create mode 100644 meson/test cases/common/33 run program/get-version.py create mode 100644 meson/test cases/common/33 run program/meson.build create mode 100644 meson/test cases/common/33 run program/scripts/hello.bat create mode 100755 meson/test cases/common/33 run program/scripts/hello.sh (limited to 'meson/test cases/common/33 run program') diff --git a/meson/test cases/common/33 run program/check-env.py b/meson/test cases/common/33 run program/check-env.py new file mode 100644 index 000000000..7f106c633 --- /dev/null +++ b/meson/test cases/common/33 run program/check-env.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +import os + +assert os.environ['MY_PATH'] == os.pathsep.join(['0', '1', '2']) + diff --git a/meson/test cases/common/33 run program/get-version.py b/meson/test cases/common/33 run program/get-version.py new file mode 100644 index 000000000..a22d55998 --- /dev/null +++ b/meson/test cases/common/33 run program/get-version.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +print('1.2') diff --git a/meson/test cases/common/33 run program/meson.build b/meson/test cases/common/33 run program/meson.build new file mode 100644 index 000000000..8e472fd64 --- /dev/null +++ b/meson/test cases/common/33 run program/meson.build @@ -0,0 +1,85 @@ +project('run command', version : run_command('get-version.py', check : true).stdout().strip()) + +if build_machine.system() == 'windows' + c = run_command('cmd', '/c', 'echo', 'hello') +else + c = run_command('echo', 'hello') +endif + +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. + +if build_machine.system() == 'windows' + cs = run_command('scripts/hello.bat') +else + cs = run_command('scripts/hello.sh') +endif + +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 + +# We should be able to have files() in argument +f = files('meson.build') + +if build_machine.system() == 'windows' + c = run_command('cmd', '/c', 'echo', f) +else + c = run_command('echo', f) +endif + +if c.returncode() != 0 + error('Using files() in argument failed.') +endif + +py3 = import('python3').find_python() + +ret = run_command(py3, '-c', 'print("some output")') +assert(ret.returncode() == 0, 'failed to run python3: ' + ret.stderr()) +assert(ret.stdout() == 'some output\n', 'failed to run python3') + +ret = run_command(py3, '-c', 'print("some output")', capture : false) +assert(ret.returncode() == 0, 'failed to run python3: ' + ret.stderr()) +assert(ret.stdout() == '', 'stdout is "@0@" instead of empty'.format(ret.stdout())) + +c_env = environment() +c_env.append('CUSTOM_ENV_VAR', 'FOOBAR') +ret = run_command(py3, '-c', 'import os; print(os.environ.get("CUSTOM_ENV_VAR"))', env : c_env) +assert(ret.returncode() == 0, 'failed to run python3: ' + ret.stderr()) +assert(ret.stdout() == 'FOOBAR\n', 'stdout is "@0@" instead of FOOBAR'.format(ret.stdout())) + +dd = find_program('dd', required : false) +if dd.found() + ret = run_command(dd, 'if=/dev/urandom', 'bs=10', 'count=1', capture: false) + assert(ret.returncode() == 0, 'failed to run dd: ' + ret.stderr()) + assert(ret.stdout() == '', 'stdout is "@0@" instead of empty'.format(ret.stdout())) +endif + +env = environment() +env.append('MY_PATH', '1') +env.append('MY_PATH', '2') +env.prepend('MY_PATH', '0') +run_command('check-env.py', env: env, check: true) diff --git a/meson/test cases/common/33 run program/scripts/hello.bat b/meson/test cases/common/33 run program/scripts/hello.bat new file mode 100644 index 000000000..cbc346bf7 --- /dev/null +++ b/meson/test cases/common/33 run program/scripts/hello.bat @@ -0,0 +1,2 @@ +@ECHO OFF +ECHO hello diff --git a/meson/test cases/common/33 run program/scripts/hello.sh b/meson/test cases/common/33 run program/scripts/hello.sh new file mode 100755 index 000000000..2a22daa88 --- /dev/null +++ b/meson/test cases/common/33 run program/scripts/hello.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo hello -- cgit 1.2.3-korg