2018-11-16 12:45:07 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
2024-02-17 16:42:44 +01:00
|
|
|
from conan import ConanFile
|
|
|
|
from conan.tools.cmake import CMake, cmake_layout
|
|
|
|
from conan.tools.build import can_run
|
2024-03-12 22:59:28 +01:00
|
|
|
from conan.tools.files import save, load
|
2018-11-16 12:45:07 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
class TestPackageConan(ConanFile):
|
|
|
|
settings = "os", "compiler", "build_type", "arch"
|
2024-03-12 22:59:28 +01:00
|
|
|
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
|
|
|
|
test_type = "explicit"
|
2024-02-17 16:42:44 +01:00
|
|
|
|
|
|
|
def requirements(self):
|
|
|
|
self.requires(self.tested_reference_str)
|
|
|
|
|
|
|
|
def layout(self):
|
|
|
|
cmake_layout(self)
|
2018-11-16 12:45:07 +01:00
|
|
|
|
2024-03-12 22:59:28 +01:00
|
|
|
def generate(self):
|
|
|
|
save(self, os.path.join(self.build_folder, "package_folder"),
|
|
|
|
self.dependencies[self.tested_reference_str].package_folder)
|
|
|
|
save(self, os.path.join(self.build_folder, "license"),
|
|
|
|
self.dependencies[self.tested_reference_str].license)
|
|
|
|
|
2018-11-16 12:45:07 +01:00
|
|
|
def build(self):
|
|
|
|
cmake = CMake(self)
|
|
|
|
cmake.configure()
|
|
|
|
cmake.build()
|
|
|
|
|
|
|
|
def test(self):
|
2024-02-17 16:42:44 +01:00
|
|
|
if can_run(self):
|
|
|
|
cmd = os.path.join(self.cpp.build.bindir, "test_package")
|
|
|
|
self.run(cmd, env="conanrun")
|
|
|
|
|
2024-03-12 22:59:28 +01:00
|
|
|
package_folder = load(self, os.path.join(self.build_folder, "package_folder"))
|
|
|
|
license = load(self, os.path.join(self.build_folder, "license"))
|
|
|
|
assert os.path.isfile(os.path.join(package_folder, "licenses", "LICENSE.txt"))
|
|
|
|
assert license == 'BSL-1.0'
|