-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathconanfile.py
48 lines (37 loc) · 1.68 KB
/
conanfile.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import subprocess
import os
from conan import ConanFile
from conan.errors import ConanException
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run
from conan.tools.env import VirtualRunEnv
class viamCppSdkTest(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def layout(self):
cmake_layout(self, src_folder="../src/viam/examples/project/cmake")
def test(self):
if can_run(self):
sock = "fake-socket-path"
cmd = os.path.join(self.cpp.build.bindir, "example_module")
# the ConanFile run method is a wrapper around Popen, but it only returns the retcode.
# A properly intialized module waits indefinitely on a signal, so we have to use Popen manually.
# Use VirtualRunEnv to perform the equivalent of passing env="conanrun" to self.run, so that
# shared builds have a properly set LD_LIBRARY_PATH among other things.
env = VirtualRunEnv(self).vars()
proc = subprocess.Popen([cmd, sock], stdout=subprocess.PIPE, text=True, env=env)
out = None
try:
out = proc.communicate(timeout=2)[0]
except subprocess.TimeoutExpired:
proc.terminate()
out = proc.communicate()[0]
pass
if f"Module listening on {sock}" not in out:
raise ConanException(f"Simple example failed to start module listening")