ryuan pushed a commit to branch master.

commit 2a5579b6ecd721a3e49ff12384524379fc70bae6
Author: Ryuan Choi <[email protected]>
Date:   Sat Jul 6 15:10:50 2013 +0900

    elementary_test: elementary_test should be more kind to execute specific 
test
    
    I frequently mistake test name because of spaces like "fileselector"
    In this case, nothing appeared and nothing is complained.
    
    For lazy developer like me, this patch makes elementary_test ignore spaces.
    In addition, elementary_test will complain and exit if wrong test name is 
given.
---
 src/bin/test.c | 42 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/bin/test.c b/src/bin/test.c
index 339610a..21a15fa 100644
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -345,13 +345,35 @@ _btn_clicked_cb(void *data, Evas_Object *obj __UNUSED__, 
void *event_info __UNUS
 }
 #endif
 
+static char *
+_space_removed_string_get(const char *name)
+{
+   int i = 0, j = 0, len;
+   char *ret;
+
+   len = strlen(name);
+   ret = calloc(sizeof(char), len);
+
+   while (name[i])
+     {
+        if (name[i] != ' ')
+          {
+             ret[j] = name[i];
+             j++;
+          }
+        i++;
+     }
+
+   return ret;
+}
+
 static void
-my_win_main(char *autorun, Eina_Bool test_win_only)
+my_win_main(const char *autorun, Eina_Bool test_win_only)
 {
    Evas_Object *bg = NULL, *bx0 = NULL, *bx1 = NULL, *lb = NULL;
    Evas_Object *fr = NULL, *tg = NULL, *sc = NULL, *en = NULL;
    //Evas_Object *btn = NULL;
-   Eina_List *l;
+   Eina_List *l = NULL;
    struct elm_test *t = NULL;
 
    if (test_win_only) goto add_tests;
@@ -771,15 +793,26 @@ add_tests:
 
    if (autorun)
      {
+        char *tmp = _space_removed_string_get(autorun);
         EINA_LIST_FOREACH(tests, l, t)
           {
-             if ((t->name) && (t->cb) && (!strcasecmp(t->name, autorun)))
+             char *name;
+
+             if (!t->name || !t->cb) continue;
+
+             name = _space_removed_string_get(t->name);
+             if (!strcasecmp(name, tmp))
                {
                   t->cb(NULL, NULL, NULL);
+                  free(name);
                   break;
                }
+             free(name);
           }
+        free(tmp);
 
+        if (!l)
+          ERR("'%s' is not valid test case name\n", autorun);
      }
    tt = t;
 
@@ -788,6 +821,9 @@ add_tests:
         EINA_LIST_FREE(tests, t)
           free(t);
 
+        if (!l)
+          elm_exit();
+
         return;
      }
 

-- 

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Reply via email to