unittests: linuxliketests: check run_command with ExternalProgram

Without previous commit, the test fails with:

        Build machine cpu family: aarch64
        Build machine cpu: aarch64
        Host machine cpu family: aarch64
        Host machine cpu: aarch64
        Target machine cpu family: aarch64
        Target machine cpu: aarch64
        Program foo found: YES
        Running command: /bin/echo baz --version
        --- stdout ---
        baz --version

        --- stderr ---

        test cases/unit/125 command list run_command/meson.build:12:0: ERROR: Assert failed: result.stdout() == 'bar baz --version
        '
pull/14295/head
Alexandre Janniaux 1 week ago
parent 21279a2e30
commit c55fde6125
  1. 12
      test cases/unit/125 command list run_command/meson.build
  2. 2
      test cases/unit/125 command list run_command/nativefile.toml
  3. 4
      unittests/linuxliketests.py

@ -0,0 +1,12 @@
project('compiler_object_in_run_command', 'c')
foo = find_program('foo', required: true)
# This test only checks that the compiler object can be passed to
# run_command(). If the compiler has been launched, it is expected
# to output something either to stdout or to stderr.
result = run_command('echo', foo, '--version', check: false)
if result.stdout() == '' and result.stderr() == ''
error('No output in stdout and stderr. Did the compiler run at all?')
endif
assert(result.stdout() == 'bar baz --version\n')

@ -1920,3 +1920,7 @@ class LinuxlikeTests(BasePlatformTests):
self.check_has_flag(compdb, mainsrc, '-O3')
self.check_has_flag(compdb, sub1src, '-O2')
self.check_has_flag(compdb, sub2src, '-O2')
def test_run_command_external_program(self):
testdir = os.path.join(self.unit_test_dir, '125 command list run_command')
self.init(testdir, extra_args=['--native-file=' + testdir + '/nativefile.toml'])

Loading…
Cancel
Save