]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - test.c
Fix a bug in the lexer causing double-dots to double the character after the 2nd dot
[xonotic/gmqcc.git] / test.c
diff --git a/test.c b/test.c
index 442c1350ddef37d3186ef373f6384f9380deff46..e2283767822e55ca8fb7b30414da00b849410d65 100644 (file)
--- a/test.c
+++ b/test.c
@@ -571,8 +571,6 @@ void task_template_destroy(task_template_t **template) {
      * checks will fail if template pointer is reused.
      */
     mem_d(*template);
-    //task_template_nullify(*template);
-    //*template = NULL;
 }
 
 /*
@@ -595,7 +593,7 @@ task_t *task_tasks = NULL;
  * Read a directory and searches for all template files in it
  * which is later used to run all tests.
  */
-bool task_propogate(const char *curdir) {
+bool task_propagate(const char *curdir) {
     bool             success = true;
     DIR             *dir;
     struct dirent   *files;
@@ -621,9 +619,12 @@ bool task_propogate(const char *curdir) {
          * We made it here, which concludes the file/directory is not
          * actually a directory, so it must be a file :)
          */
-        if (strstr(files->d_name, ".tmpl") == &files->d_name[strlen(files->d_name) - (sizeof(".tmpl") - 1)]) {
-            util_debug("TEST", "compiling task template: %s/%s\n", curdir, files->d_name);
+        if (strcmp(files->d_name + strlen(files->d_name) - 5, ".tmpl") == 0) {
             task_template_t *template = task_template_compile(files->d_name, curdir);
+            char             buf[4096]; /* one page should be enough */
+            task_t           task;
+            
+            util_debug("TEST", "compiling task template: %s/%s\n", curdir, files->d_name);
             if (!template) {
                 con_err("error compiling task template: %s\n", files->d_name);
                 success = false;
@@ -640,7 +641,6 @@ bool task_propogate(const char *curdir) {
              * which will be refered to with a handle in the task for
              * reading the data from the pipe.
              */
-            char     buf[4096]; /* one page should be enough */
             memset  (buf,0,sizeof(buf));
             snprintf(buf,  sizeof(buf), "%s %s/%s %s -o %s",
                 task_bins[TASK_COMPILE],
@@ -652,9 +652,8 @@ bool task_propogate(const char *curdir) {
             
             /*
              * The task template was compiled, now lets create a task from
-             * the template data which has now been propogated.
+             * the template data which has now been propagated.
              */
-            task_t task;
             task.template = template;
             if (!(task.runhandles = task_popen(buf, "r"))) {
                 con_err("error opening pipe to process for test: %s\n", template->description);
@@ -874,7 +873,7 @@ bool task_execute(task_template_t *template) {
  * execution this takes more work since a task needs to be generated
  * from thin air and executed INLINE.
  */
-void task_schedualize(const char *curdir) {
+void task_schedualize() {
     bool   execute  = false;
     char  *data     = NULL;
     size_t size     = 0;
@@ -882,9 +881,9 @@ void task_schedualize(const char *curdir) {
     
     for (i = 0; i < vec_size(task_tasks); i++) {
         /*
-        * Generate a task from thin air if it requires execution in
-        * the QCVM.
-        */
+         * Generate a task from thin air if it requires execution in
+         * the QCVM.
+         */
         if (!strcmp(task_tasks[i].template->proceduretype, "-execute"))
             execute = true;
             
@@ -919,8 +918,6 @@ void task_schedualize(const char *curdir) {
             fputs(data, task_tasks[i].stderrlog);
             fflush(task_tasks[i].stdoutlog);
         }
-        //mem_d(data);
-        
         
         /*
          * If we can execute we do so after all data has been read and
@@ -944,7 +941,7 @@ void task_schedualize(const char *curdir) {
             continue;
         }
         
-        con_out("test succeed: `%s` [%s]\n",
+        con_out("test succeeded: `%s` [%s]\n",
             task_tasks[i].template->description,
             (task_tasks[i].template->successmessage) ?
             task_tasks[i].template->successmessage  : "unknown"
@@ -956,32 +953,32 @@ void task_schedualize(const char *curdir) {
 /*
  * This is the heart of the whole test-suite process.  This cleans up
  * any existing temporary files left behind as well as log files left
- * behind.  Then it propogates a list of tests from `curdir` by scaning
+ * behind.  Then it propagates a list of tests from `curdir` by scaning
  * it for template files and compiling them into tasks, in which it
  * schedualizes them (executes them) and actually reports errors and
  * what not.  It then proceeds to destroy the tasks and return memory
  * it's the engine :)
  * 
- * It returns true of tests could be propogated, otherwise it returns
+ * It returns true of tests could be propagated, otherwise it returns
  * false.
  * 
  * It expects con_init() was called before hand.
  */
 bool test_perform(const char *curdir) {
     task_precleanup(curdir);
-    if (!task_propogate(curdir)) {
-        con_err("error: failed to propogate tasks\n");
+    if (!task_propagate(curdir)) {
+        con_err("error: failed to propagate tasks\n");
         task_destroy(curdir);
         return false;
     }
     /*
-     * If we made it here all tasks where propogated from their resultant
+     * If we made it here all tasks where propagated from their resultant
      * template file.  So we can start the FILO scheduler, this has been
      * designed in the most thread-safe way possible for future threading
      * it's designed to prevent lock contention, and possible syncronization
      * issues.
      */
-    task_schedualize(curdir);
+    task_schedualize();
     task_destroy(curdir);
     
     return true;