diff --git a/elm_code/lib/Elm_Code.h b/elm_code/lib/Elm_Code.h index 3ed59fb..eadf59d 100644 --- a/elm_code/lib/Elm_Code.h +++ b/elm_code/lib/Elm_Code.h @@ -7,6 +7,7 @@ #include #include +#include #include #ifdef EAPI diff --git a/elm_code/lib/elm_code_common.h b/elm_code/lib/elm_code_common.h index 3dc00ed..79f5d6c 100644 --- a/elm_code/lib/elm_code_common.h +++ b/elm_code/lib/elm_code_common.h @@ -17,6 +17,9 @@ typedef enum { ELM_CODE_STATUS_TYPE_REMOVED, ELM_CODE_STATUS_TYPE_CHANGED, + ELM_CODE_STATUS_TYPE_PASSED, + ELM_CODE_STATUS_TYPE_FAILED, + ELM_CODE_STATUS_TYPE_COUNT } Elm_Code_Status_Type; diff --git a/elm_code/lib/elm_code_file.c b/elm_code/lib/elm_code_file.c index 07ae9e2..e2d9daa 100644 --- a/elm_code/lib/elm_code_file.c +++ b/elm_code/lib/elm_code_file.c @@ -119,6 +119,21 @@ EAPI const char *elm_code_file_path_get(Elm_Code_File *file) return eina_file_filename_get(file->file); } +EAPI void elm_code_file_clear(Elm_Code_File *file) +{ + Elm_Code_Line *l; + + EINA_LIST_FREE(file->lines, l) + { + if (l->content) + free(l->content); + free(l); + } + + if (file->parent) + elm_code_callback_fire(file->parent, &ELM_CODE_EVENT_FILE_LOAD_DONE, file); +} + EAPI unsigned int elm_code_file_lines_get(Elm_Code_File *file) { return eina_list_count(file->lines); diff --git a/elm_code/lib/elm_code_file.h b/elm_code/lib/elm_code_file.h index 19a4725..c3ebfb9 100644 --- a/elm_code/lib/elm_code_file.h +++ b/elm_code/lib/elm_code_file.h @@ -76,6 +76,8 @@ EAPI const char *elm_code_file_path_get(Elm_Code_File *file); * */ +EAPI void elm_code_file_clear(Elm_Code_File *file); + EAPI unsigned int elm_code_file_lines_get(Elm_Code_File *file); EAPI void elm_code_file_line_append(Elm_Code_File *file, const char *line); diff --git a/elm_code/lib/elm_code_widget.c b/elm_code/lib/elm_code_widget.c index ba096e4..e555468 100644 --- a/elm_code/lib/elm_code_widget.c +++ b/elm_code/lib/elm_code_widget.c @@ -176,6 +176,11 @@ EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code) evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_CHANGED, 36, 36, 96, 255); + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_PASSED, + 54, 96, 54, 255); + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_FAILED, + 96, 54, 54, 255); + // setup token colors evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_DEFAULT, 205, 205, 205, 255); diff --git a/src/bin/edi_consolepanel.c b/src/bin/edi_consolepanel.c index 20fe7c1..f790d58 100644 --- a/src/bin/edi_consolepanel.c +++ b/src/bin/edi_consolepanel.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -18,6 +19,13 @@ static Evas_Object *_console_box; static const char *_current_dir = NULL; +static int _edi_test_count; +static int _edi_test_pass; +static int _edi_test_fail; + +static Elm_Code *_edi_test_code; +static void _edi_test_line_callback(const char *content); + static const char *_edi_consolepanel_icon_for_line(const char *line) { if (strstr(line, " error:") != NULL) @@ -153,6 +161,8 @@ static void _edi_consolepanel_append_line_type(const char *line, Eina_Bool err) elm_box_pack_end(_console_box, box); _edi_consolepanel_scroll_to_bottom(); + + _edi_test_line_callback(line); } void edi_consolepanel_append_line(const char *line) @@ -168,6 +178,11 @@ void edi_consolepanel_append_error_line(const char *line) void edi_consolepanel_clear() { elm_box_clear(_console_box); + + elm_code_file_clear(_edi_test_code->file); + _edi_test_count = 0; + _edi_test_pass = 0; + _edi_test_fail = 0; } static Eina_Bool @@ -196,6 +211,87 @@ _exe_error(void *d EINA_UNUSED, int t EINA_UNUSED, void *event_info) return ECORE_CALLBACK_RENEW; } +static void _edi_test_append(const char *content, Elm_Code_Status_Type type) +{ + elm_code_file_line_append(_edi_test_code->file, content); + elm_code_file_line_status_set(_edi_test_code->file, elm_code_file_lines_get(_edi_test_code->file), type); +} + +static void _edi_test_line_parse_suite(const char *path) +{ + Eina_File *file; + Eina_File_Line *line; + Eina_Iterator *it; + char logfile[PATH_MAX], *tmp; + int pathlength; + Elm_Code_Status_Type status; + + pathlength = strlen(path); + snprintf(logfile, pathlength + 4 + 1, "%s.log", path); + + file = eina_file_open(logfile, EINA_FALSE); + + it = eina_file_map_lines(file); + EINA_ITERATOR_FOREACH(it, line) + { + status = ELM_CODE_STATUS_TYPE_DEFAULT; + tmp = malloc(line->length + 1); + strncpy(tmp, line->start, line->length); + tmp[line->length] = 0; + + if (strstr(tmp, ":P:")) + status = ELM_CODE_STATUS_TYPE_PASSED; + else if (strstr(tmp, ":F:")) + status = ELM_CODE_STATUS_TYPE_FAILED; + + _edi_test_append(tmp, status); + free(tmp); + } + eina_iterator_free(it); +} + +static void _edi_test_line_parse_suite_pass_line(const char *line) +{ + _edi_test_line_parse_suite(line); + _edi_test_append("Suite passed", ELM_CODE_STATUS_TYPE_DEFAULT); +} + +static void _edi_test_line_parse_suite_fail_line(const char *line) +{ + _edi_test_line_parse_suite(line); + _edi_test_append("Suite failed", ELM_CODE_STATUS_TYPE_DEFAULT); +} + +static void _edi_test_line_parse_summary_line(const char *line) +{ + _edi_test_append(line, ELM_CODE_STATUS_TYPE_DEFAULT); +} + +static void _edi_test_line_callback(const char *content) +{ + if (!content) + return; + + if (content[0] == '#') + { + _edi_test_line_parse_summary_line(content + 2); + return; + } + + if (!strncmp(content, "PASS:", 5)) + { + _edi_test_count++; + _edi_test_pass++; + _edi_test_line_parse_suite_pass_line(content + 6); + } + else if (!strncmp(content, "FAIL:", 5)) + { + _edi_test_count++; + _edi_test_fail++; + _edi_test_line_parse_suite_fail_line(content + 6); + } +} + void edi_consolepanel_add(Evas_Object *parent) { Evas_Object *scroll, *vbx; @@ -217,3 +313,22 @@ void edi_consolepanel_add(Evas_Object *parent) ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _exe_data, NULL); ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, _exe_error, NULL); } + +void edi_testpanel_add(Evas_Object *parent) +{ + Elm_Code *code; + Evas_Object *widget; + + code = elm_code_create(); + _edi_test_code = code; + elm_code_file_new(code); + + widget = elm_code_widget_add(parent, code); + + evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(widget); + + elm_object_content_set(parent, widget); +} + diff --git a/src/bin/edi_consolepanel.h b/src/bin/edi_consolepanel.h index bd51a8b..37cf1fc 100644 --- a/src/bin/edi_consolepanel.h +++ b/src/bin/edi_consolepanel.h @@ -38,6 +38,10 @@ EAPI void edi_consolepanel_add(Evas_Object *parent); */ EAPI void edi_consolepanel_show(); +EAPI void edi_testpanel_add(Evas_Object *parent); + +EAPI void edi_testpanel_show(); + /** * @} */ diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c index b475512..07c9f03 100644 --- a/src/bin/edi_main.c +++ b/src/bin/edi_main.c @@ -23,7 +23,7 @@ #define COPYRIGHT "Copyright © 2014 Andy Williams and various contributors (see AUTHORS)." -static Evas_Object *_edi_filepanel, *_edi_logpanel, *_edi_consolepanel; +static Evas_Object *_edi_filepanel, *_edi_logpanel, *_edi_consolepanel, *_edi_testpanel; static Evas_Object *_edi_main_win, *_edi_new_popup, *_edi_goto_popup; static void @@ -58,6 +58,11 @@ void edi_consolepanel_show() elm_panel_hidden_set(_edi_consolepanel, EINA_FALSE); } +void edi_testpanel_show() +{ + elm_panel_hidden_set(_edi_testpanel, EINA_FALSE); +} + static Evas_Object * edi_content_setup(Evas_Object *win, const char *path) { @@ -69,6 +74,7 @@ edi_content_setup(Evas_Object *win, const char *path) _edi_filepanel = elm_panel_add(win); _edi_logpanel = elm_panel_add(win); _edi_consolepanel = elm_panel_add(win); + _edi_testpanel = elm_panel_add(win); // add main content content_out = elm_box_add(win); @@ -119,6 +125,7 @@ edi_content_setup(Evas_Object *win, const char *path) elm_toolbar_item_append(tb, NULL, "Logs", _edi_toggle_panel, _edi_logpanel); elm_toolbar_item_append(tb, NULL, "Console", _edi_toggle_panel, _edi_consolepanel); + elm_toolbar_item_append(tb, NULL, "Tests", _edi_toggle_panel, _edi_testpanel); elm_panel_orient_set(_edi_logpanel, ELM_PANEL_ORIENT_BOTTOM); evas_object_size_hint_weight_set(_edi_logpanel, EVAS_HINT_EXPAND, 0.15); @@ -142,6 +149,17 @@ edi_content_setup(Evas_Object *win, const char *path) elm_table_pack(panes, _edi_consolepanel, 0, 4, 6, 1); evas_object_show(_edi_consolepanel); + elm_panel_orient_set(_edi_testpanel, ELM_PANEL_ORIENT_BOTTOM); + evas_object_size_hint_weight_set(_edi_testpanel, EVAS_HINT_EXPAND, 0.15); + evas_object_size_hint_align_set(_edi_testpanel, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(_edi_testpanel); + + elm_panel_hidden_set(_edi_testpanel, EINA_FALSE); + elm_panel_hidden_set(_edi_testpanel, EINA_TRUE); + edi_testpanel_add(_edi_testpanel); + elm_table_pack(panes, _edi_testpanel, 0, 4, 6, 1); + evas_object_show(_edi_testpanel); + evas_object_show(panes); return panes; } @@ -331,7 +349,11 @@ static void _tb_test_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) { if (_edi_build_prep(obj)) - edi_builder_test(); + { + elm_panel_hidden_set(_edi_consolepanel, EINA_TRUE); + edi_testpanel_show(); + edi_builder_test(); + } } /* static void diff --git a/src/lib/edi_builder.c b/src/lib/edi_builder.c index 017e63f..eebeedc 100644 --- a/src/lib/edi_builder.c +++ b/src/lib/edi_builder.c @@ -54,7 +54,7 @@ EAPI void edi_builder_test(void) { chdir(edi_project_get()); - ecore_exe_pipe_run("make check", ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_READ | + ecore_exe_pipe_run("CK_VERBOSITY=verbose make check", ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR_LINE_BUFFERED | ECORE_EXE_PIPE_ERROR, NULL); }