aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-06-23 07:53:17 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2019-06-23 17:53:17 +0300
commit56f7e5c74f54d31b405fe1c4289a406ef826b757 (patch)
tree2ebe24ae3ca1c62d3d3ebc6275a67a89d2bd34fa /run_unittests.py
parentd61116efc116845d32cd56b82089addd6b9327cc (diff)
downloadmeson-56f7e5c74f54d31b405fe1c4289a406ef826b757.zip
meson-56f7e5c74f54d31b405fe1c4289a406ef826b757.tar.gz
meson-56f7e5c74f54d31b405fe1c4289a406ef826b757.tar.bz2
coredata: Correctly handle receiving a pipe for native/cross files
* coredata: Correctly handle receiving a pipe for native/cross files In some cases a cross/native file may be a pipe, such as when using bash process replacement `meson --native-file <([binaries]llvm-config='/opt/bin/llvm-config')`, for example. In this case we copy the contents of the pipe into a file in the meson-private directory so we can create a proper ninja dependency, and be able to reload the file on --wipe/--reconfigure. This requires some extra negotiation to preserve these native/cross files. Fixes #5505 * run_unitests: Add a unit test for native files that are pipes Using mkfifo.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 36f7f39..29ab1b7 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -29,6 +29,7 @@ import pickle
import functools
import io
import operator
+import threading
from itertools import chain
from unittest import mock
from configparser import ConfigParser
@@ -5742,9 +5743,9 @@ class NativeFileTests(BasePlatformTests):
f.write("{}='{}'\n".format(k, v))
return filename
- def helper_create_binary_wrapper(self, binary, **kwargs):
+ def helper_create_binary_wrapper(self, binary, dir_=None, **kwargs):
"""Creates a wrapper around a binary that overrides specific values."""
- filename = os.path.join(self.builddir, 'binary_wrapper{}.py'.format(self.current_wrapper))
+ filename = os.path.join(dir_ or self.builddir, 'binary_wrapper{}.py'.format(self.current_wrapper))
self.current_wrapper += 1
if is_haiku():
chbang = '#!/bin/env python3'
@@ -5818,6 +5819,28 @@ class NativeFileTests(BasePlatformTests):
'--native-file', config, '--native-file', config2,
'-Dcase=find_program'])
+ @unittest.skipIf(os.name != 'posix', 'Uses fifos, which are not available on non Unix OSes.')
+ def test_native_file_is_pipe(self):
+ fifo = os.path.join(self.builddir, 'native.file')
+ os.mkfifo(fifo)
+ with tempfile.TemporaryDirectory() as d:
+ wrapper = self.helper_create_binary_wrapper('bash', d, version='12345')
+
+ def filler():
+ with open(fifo, 'w') as f:
+ f.write('[binaries]\n')
+ f.write("bash = '{}'\n".format(wrapper))
+
+ thread = threading.Thread(target=filler)
+ thread.start()
+
+ self.init(self.testcase, extra_args=['--native-file', fifo, '-Dcase=find_program'])
+
+ thread.join()
+ os.unlink(fifo)
+
+ self.init(self.testcase, extra_args=['--wipe'])
+
def test_multiple_native_files(self):
wrapper = self.helper_create_binary_wrapper('bash', version='12345')
config = self.helper_create_native_file({'binaries': {'bash': wrapper}})