conanfile.py 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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("bin", "test_package")
  18. run_vars = RunEnvironment(self).vars
  19. with tools.environment_append(run_vars):
  20. if self.settings.os == "Macos" or self.settings.os == "Linux":
  21. run_vars["DYLD_LIBRARY_PATH"] = os.environ.get('DYLD_LIBRARY_PATH', '')
  22. process = subprocess.Popen([bin_path], shell=True, env=run_vars)
  23. else:
  24. process = subprocess.Popen([bin_path], shell=True)
  25. time.sleep(3)
  26. response = requests.get("http://localhost:8080/example")
  27. assert response.ok
  28. process.kill()
  29. print("Finish Conan test package - SUCCESS!")