]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - test.cpp
Delete .travis.yml
[xonotic/gmqcc.git] / test.cpp
index 840e6b68942f29e1eda7fd5e38d9c94bb0a2be90..2614c7f1dd78a5ae525c835a103c80e15ef57926 100644 (file)
--- a/test.cpp
+++ b/test.cpp
@@ -76,7 +76,7 @@ static FILE **task_popen(const char *command, const char *mode) {
         dup2(errhandle[1], 2);
 
         execvp(argv[0], &argv[0]);
-        exit(EXIT_FAILURE);
+        exit(95);
     } else {
         /* fork failed */
         goto task_popen_error_3;
@@ -98,11 +98,17 @@ static int task_pclose(FILE **handles) {
     close(data->pipes[1]); /* stdout */
     close(data->pipes[2]); /* stderr */
 
-    waitpid(data->pid, &status, 0);
+    if (data->pid != waitpid(data->pid, &status, 0)) {
+      abort();
+    }
+    if (!WIFEXITED(status))
+      return -1;
+    if (WIFSIGNALED(status))
+      con_out("got signaled!\n");
 
     mem_d(data);
 
-    return status;
+    return status ? 1 : 0;
 }
 
 #define TASK_COMPILE    0
@@ -632,6 +638,8 @@ static bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
                 const char      *qcflags = nullptr;
                 task_t           task;
 
+                memset(&task, 0, sizeof(task));
+
                 found ++;
                 if (!tmpl) {
                     con_err("error compiling task template: %s\n", files->d_name);
@@ -997,6 +1005,10 @@ static size_t task_schedualize(size_t *pad) {
         util_snprintf(space[1], sizeof(space[1]), "%d", (int)(i));
 
         con_out("test #%u %*s", i, strlen(space[0]) - strlen(space[1]), "");
+            //con_out("[[%*s]]",
+            //    (pad[0] + pad[1] - strlen(it.tmpl->description)) + (strlen(it.tmpl->rulesfile) - pad[1]),
+            //    it.tmpl->rulesfile);
+            //fflush(stdout);
 
         /*
          * Generate a task from thin air if it requires execution in
@@ -1057,6 +1069,16 @@ static size_t task_schedualize(size_t *pad) {
         }
 
         status = task_pclose(it.runhandles);
+        if (status != 0 && status != 1) {
+            con_out("compiler failure (returned: %i):   `%s` %*s\n",
+                status,
+                it.tmpl->description,
+                (pad[0] + pad[1] - strlen(it.tmpl->description)) + (strlen(it.tmpl->rulesfile) - pad[1]),
+                it.tmpl->rulesfile
+            );
+            failed++;
+            continue;
+        }
         if ((!strcmp(it.tmpl->proceduretype, "-fail") && status == EXIT_SUCCESS)
         ||  ( strcmp(it.tmpl->proceduretype, "-fail") && status == EXIT_FAILURE)) {
             con_out("failure:   `%s` %*s %*s\n",