conanfile.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os
  4. import subprocess
  5. import requests
  6. import time
  7. from conans import ConanFile, CMake, tools, RunEnvironment
  8. class TestPackageConan(ConanFile):
  9. settings = "os", "compiler", "build_type", "arch"
  10. generators = "cmake"
  11. def build(self):
  12. cmake = CMake(self)
  13. cmake.configure()
  14. cmake.build()
  15. def test(self):
  16. assert os.path.isfile(os.path.join(self.deps_cpp_info["civetweb"].rootpath, "licenses", "LICENSE.md"))
  17. bin_path = os.path.join(os.getcwd(), "bin", "test_package")
  18. run_vars = RunEnvironment(self).vars
  19. with tools.environment_append(run_vars):
  20. if self.settings.os == "Macos":
  21. run_vars["DYLD_LIBRARY_PATH"] = os.environ.get('DYLD_LIBRARY_PATH', '')
  22. process = subprocess.Popen([bin_path], shell=True, env=run_vars)
  23. time.sleep(2)
  24. response = requests.get("http://localhost:8080/example")
  25. assert response.ok
  26. process.kill()
  27. print("Finish Conan test package - SUCCESS!")