Przeglądaj źródła

#712 Only execute server for test package

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Uilian Ries 6 lat temu
rodzic
commit
c4df6339bf
2 zmienionych plików z 12 dodań i 17 usunięć
  1. 2 16
      conan/test_package/conanfile.py
  2. 10 1
      conan/test_package/test_package.cpp

+ 2 - 16
conan/test_package/conanfile.py

@@ -1,10 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 import os
-import subprocess
-import requests
-import time
-from conans import ConanFile, CMake, tools, RunEnvironment
+from conans import ConanFile, CMake
 
 
 class TestPackageConan(ConanFile):
@@ -19,15 +16,4 @@ class TestPackageConan(ConanFile):
     def test(self):
         assert os.path.isfile(os.path.join(self.deps_cpp_info["civetweb"].rootpath, "licenses", "LICENSE.md"))
         bin_path = os.path.join("bin", "test_package")
-        run_vars = RunEnvironment(self).vars
-        with tools.environment_append(run_vars):
-            if self.settings.os == "Macos" or self.settings.os == "Linux":
-                run_vars["DYLD_LIBRARY_PATH"] = os.environ.get('DYLD_LIBRARY_PATH', '')
-                process = subprocess.Popen([bin_path], shell=True, env=run_vars)
-            else:
-                process = subprocess.Popen([bin_path], shell=True)
-            time.sleep(3)
-            response = requests.get("http://localhost:8080/example")
-            assert response.ok
-            process.kill()
-            print("Finish Conan test package - SUCCESS!")
+        self.run(bin_path, run_environment=True)

+ 10 - 1
conan/test_package/test_package.cpp

@@ -20,7 +20,7 @@
 #define HOST_INFO "http://localhost:8080"
 #define EXAMPLE_URI "/example"
 
-int exitNow = 0;
+static int exitNow = 0;
 
 static int
 ExampleGET(struct mg_connection* conn)
@@ -54,6 +54,9 @@ main(int argc, char *argv[])
 {
 	struct mg_callbacks callbacks;
 	struct mg_context *ctx;
+	time_t start_t;
+	time_t end_t;
+	double diff_t;
 	int err = 0;
 
 	mg_init_library(0);
@@ -79,12 +82,18 @@ main(int argc, char *argv[])
 
 
 	/* Wait until the server should be closed */
+	time(&start_t);
 	while (!exitNow) {
 #ifdef _WIN32
 		Sleep(1000);
 #else
 		sleep(1);
 #endif
+        time(&end_t);
+		diff_t = difftime(end_t, start_t);
+		if (diff_t > 3.0) {
+			break;
+		}
 	}
 
 	/* Stop the server */