From 0c3fe51799c46542b9f317d1b7cbc289125bc7b9 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Jun 2015 20:10:12 +0100 Subject: Changed assert order in rooms test --- tests/functionaltests/test_rooms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/functionaltests/test_rooms.c b/tests/functionaltests/test_rooms.c index e4fe0200..c81ded6b 100644 --- a/tests/functionaltests/test_rooms.c +++ b/tests/functionaltests/test_rooms.c @@ -27,12 +27,12 @@ rooms_query(void **state) prof_input("/rooms"); + assert_true(prof_output_exact("chatroom@conference.localhost, (A chat room)")); + assert_true(prof_output_exact("hangout@conference.localhost, (Another chat room)")); + assert_true(stbbr_last_received( "" "" "" )); - - assert_true(prof_output_exact("chatroom@conference.localhost, (A chat room)")); - assert_true(prof_output_exact("hangout@conference.localhost, (Another chat room)")); } -- cgit 1.4.1-2-gfad0 From 0fcfa65f153b585655635ec1296829d8ea62f21c Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Jun 2015 20:53:51 +0100 Subject: Use regex for multiline assert in rooms functional test --- tests/functionaltests/test_rooms.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/functionaltests/test_rooms.c b/tests/functionaltests/test_rooms.c index c81ded6b..0e53d0db 100644 --- a/tests/functionaltests/test_rooms.c +++ b/tests/functionaltests/test_rooms.c @@ -27,8 +27,11 @@ rooms_query(void **state) prof_input("/rooms"); - assert_true(prof_output_exact("chatroom@conference.localhost, (A chat room)")); - assert_true(prof_output_exact("hangout@conference.localhost, (Another chat room)")); + assert_true(prof_output_regex( + "chatroom@conference.localhost, \\(A chat room\\)" + ".+" + "hangout@conference.localhost, \\(Another chat room\\)" + )); assert_true(stbbr_last_received( "" -- cgit 1.4.1-2-gfad0 From 5c13f00e2ffee3210372c7fbf0eae575817a1297 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Jun 2015 21:13:07 +0100 Subject: Debugging travis build --- tests/functionaltests/test_rooms.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/functionaltests/test_rooms.c b/tests/functionaltests/test_rooms.c index 0e53d0db..dec8b1ec 100644 --- a/tests/functionaltests/test_rooms.c +++ b/tests/functionaltests/test_rooms.c @@ -27,11 +27,13 @@ rooms_query(void **state) prof_input("/rooms"); - assert_true(prof_output_regex( - "chatroom@conference.localhost, \\(A chat room\\)" - ".+" - "hangout@conference.localhost, \\(Another chat room\\)" - )); + assert_true(prof_output_exact("chatroom@conference.localhost, (A chat room)")); + +// assert_true(prof_output_regex( +// "chatroom@conference.localhost, \\(A chat room\\)" +// ".+" +// "hangout@conference.localhost, \\(Another chat room\\)" +// )); assert_true(stbbr_last_received( "" -- cgit 1.4.1-2-gfad0 From 5b58e2d0bc5720226eced6088d31d166800fcfd3 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Jun 2015 21:20:13 +0100 Subject: Debugging travis build --- tests/functionaltests/test_rooms.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/functionaltests/test_rooms.c b/tests/functionaltests/test_rooms.c index dec8b1ec..f8234ee1 100644 --- a/tests/functionaltests/test_rooms.c +++ b/tests/functionaltests/test_rooms.c @@ -27,7 +27,8 @@ rooms_query(void **state) prof_input("/rooms"); - assert_true(prof_output_exact("chatroom@conference.localhost, (A chat room)")); +// assert_true(prof_output_exact("chatroom@conference.localhost, (A chat room)")); + assert_true(prof_output_exact("hangout@conference.localhost, (Another chat room)")); // assert_true(prof_output_regex( // "chatroom@conference.localhost, \\(A chat room\\)" -- cgit 1.4.1-2-gfad0 From dda79aed2429bd041f94d4d249eb449370f2a4a0 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Jun 2015 21:31:38 +0100 Subject: Debugging travis build --- tests/functionaltests/test_rooms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functionaltests/test_rooms.c b/tests/functionaltests/test_rooms.c index f8234ee1..4691fea3 100644 --- a/tests/functionaltests/test_rooms.c +++ b/tests/functionaltests/test_rooms.c @@ -28,7 +28,7 @@ rooms_query(void **state) prof_input("/rooms"); // assert_true(prof_output_exact("chatroom@conference.localhost, (A chat room)")); - assert_true(prof_output_exact("hangout@conference.localhost, (Another chat room)")); + assert_true(prof_output_regex("hangout@conference\\.localhost, \\(Another chat room\\)")); // assert_true(prof_output_regex( // "chatroom@conference.localhost, \\(A chat room\\)" -- cgit 1.4.1-2-gfad0 From 6e04ce8e137c223445205bb1c49cccbfe7f38753 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Jun 2015 21:37:18 +0100 Subject: Output test log in travis build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 417fbce6..8cbbf416 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,4 +33,4 @@ install: - cd .. - rm -rf stabber - ./bootstrap.sh -script: ./configure && make && make check +script: ./configure && make && make check && cat test-suite.log -- cgit 1.4.1-2-gfad0 From eb676262f98cb554cf0b8dc032e2c65e98a44800 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Jun 2015 22:02:10 +0100 Subject: Travis build fix --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8cbbf416..1b5c9a62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,4 +33,5 @@ install: - cd .. - rm -rf stabber - ./bootstrap.sh -script: ./configure && make && make check && cat test-suite.log +script: ./configure && make && make check +after_script: cat test-suite.log -- cgit 1.4.1-2-gfad0 From 82ff85c329dca6105bfa9add9cb1424ecc2ae334 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Jun 2015 22:13:01 +0100 Subject: Revert back to original rooms test --- tests/functionaltests/test_rooms.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/functionaltests/test_rooms.c b/tests/functionaltests/test_rooms.c index 4691fea3..c81ded6b 100644 --- a/tests/functionaltests/test_rooms.c +++ b/tests/functionaltests/test_rooms.c @@ -27,14 +27,8 @@ rooms_query(void **state) prof_input("/rooms"); -// assert_true(prof_output_exact("chatroom@conference.localhost, (A chat room)")); - assert_true(prof_output_regex("hangout@conference\\.localhost, \\(Another chat room\\)")); - -// assert_true(prof_output_regex( -// "chatroom@conference.localhost, \\(A chat room\\)" -// ".+" -// "hangout@conference.localhost, \\(Another chat room\\)" -// )); + assert_true(prof_output_exact("chatroom@conference.localhost, (A chat room)")); + assert_true(prof_output_exact("hangout@conference.localhost, (Another chat room)")); assert_true(stbbr_last_received( "" -- cgit 1.4.1-2-gfad0 From e50461a897d225a60b08e928074753230fc4ede6 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Jun 2015 23:59:33 +0100 Subject: Set columns when running functional tests --- src/command/commands.c | 69 +++++++++++++++++++++++++------- tests/functionaltests/proftest.c | 27 ++++++++----- tests/functionaltests/start_profanity.sh | 2 + tests/unittests/test_cmd_roster.c | 3 +- 4 files changed, 76 insertions(+), 25 deletions(-) create mode 100755 tests/functionaltests/start_profanity.sh diff --git a/src/command/commands.c b/src/command/commands.c index 35e424b9..5d0f7a16 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1483,13 +1483,13 @@ cmd_roster(gchar **args, struct cmd_help_t help) { jabber_conn_status_t conn_status = jabber_get_connection_status(); - if (conn_status != JABBER_CONNECTED) { - cons_show("You are not currently connected."); - return TRUE; - } - // show roster if (args[0] == NULL) { + if (conn_status != JABBER_CONNECTED) { + cons_show("You are not currently connected."); + return TRUE; + } + GSList *list = roster_get_contacts(); cons_show_roster(list); g_slist_free(list); @@ -1497,6 +1497,11 @@ cmd_roster(gchar **args, struct cmd_help_t help) // show roster, only online contacts } else if(g_strcmp0(args[0], "online") == 0){ + if (conn_status != JABBER_CONNECTED) { + cons_show("You are not currently connected."); + return TRUE; + } + GSList *list = roster_get_contacts_online(); cons_show_roster(list); g_slist_free(list); @@ -1514,7 +1519,7 @@ cmd_roster(gchar **args, struct cmd_help_t help) if (res) { prefs_set_roster_size(intval); cons_show("Roster screen size set to: %d%%", intval); - if (prefs_get_boolean(PREF_ROSTER)) { + if (conn_status == JABBER_CONNECTED && prefs_get_boolean(PREF_ROSTER)) { wins_resize_all(); } return TRUE; @@ -1529,17 +1534,23 @@ cmd_roster(gchar **args, struct cmd_help_t help) if (args[1] == NULL) { cons_show("Roster enabled."); prefs_set_boolean(PREF_ROSTER, TRUE); - ui_show_roster(); + if (conn_status == JABBER_CONNECTED) { + ui_show_roster(); + } return TRUE; } else if (g_strcmp0(args[1], "offline") == 0) { cons_show("Roster offline enabled"); prefs_set_boolean(PREF_ROSTER_OFFLINE, TRUE); - rosterwin_roster(); + if (conn_status == JABBER_CONNECTED) { + rosterwin_roster(); + } return TRUE; } else if (g_strcmp0(args[1], "resource") == 0) { cons_show("Roster resource enabled"); prefs_set_boolean(PREF_ROSTER_RESOURCE, TRUE); - rosterwin_roster(); + if (conn_status == JABBER_CONNECTED) { + rosterwin_roster(); + } return TRUE; } else { cons_show("Usage: %s", help.usage); @@ -1549,17 +1560,23 @@ cmd_roster(gchar **args, struct cmd_help_t help) if (args[1] == NULL) { cons_show("Roster disabled."); prefs_set_boolean(PREF_ROSTER, FALSE); - ui_hide_roster(); + if (conn_status == JABBER_CONNECTED) { + ui_hide_roster(); + } return TRUE; } else if (g_strcmp0(args[1], "offline") == 0) { cons_show("Roster offline disabled"); prefs_set_boolean(PREF_ROSTER_OFFLINE, FALSE); - rosterwin_roster(); + if (conn_status == JABBER_CONNECTED) { + rosterwin_roster(); + } return TRUE; } else if (g_strcmp0(args[1], "resource") == 0) { cons_show("Roster resource disabled"); prefs_set_boolean(PREF_ROSTER_RESOURCE, FALSE); - rosterwin_roster(); + if (conn_status == JABBER_CONNECTED) { + rosterwin_roster(); + } return TRUE; } else { cons_show("Usage: %s", help.usage); @@ -1570,17 +1587,23 @@ cmd_roster(gchar **args, struct cmd_help_t help) if (g_strcmp0(args[1], "group") == 0) { cons_show("Grouping roster by roster group"); prefs_set_string(PREF_ROSTER_BY, "group"); - rosterwin_roster(); + if (conn_status == JABBER_CONNECTED) { + rosterwin_roster(); + } return TRUE; } else if (g_strcmp0(args[1], "presence") == 0) { cons_show("Grouping roster by presence"); prefs_set_string(PREF_ROSTER_BY, "presence"); - rosterwin_roster(); + if (conn_status == JABBER_CONNECTED) { + rosterwin_roster(); + } return TRUE; } else if (g_strcmp0(args[1], "none") == 0) { cons_show("Roster grouping disabled"); prefs_set_string(PREF_ROSTER_BY, "none"); - rosterwin_roster(); + if (conn_status == JABBER_CONNECTED) { + rosterwin_roster(); + } return TRUE; } else { cons_show("Usage: %s", help.usage); @@ -1588,6 +1611,10 @@ cmd_roster(gchar **args, struct cmd_help_t help) } // add contact } else if (strcmp(args[0], "add") == 0) { + if (conn_status != JABBER_CONNECTED) { + cons_show("You are not currently connected."); + return TRUE; + } char *jid = args[1]; if (jid == NULL) { cons_show("Usage: %s", help.usage); @@ -1599,6 +1626,10 @@ cmd_roster(gchar **args, struct cmd_help_t help) // remove contact } else if (strcmp(args[0], "remove") == 0) { + if (conn_status != JABBER_CONNECTED) { + cons_show("You are not currently connected."); + return TRUE; + } char *jid = args[1]; if (jid == NULL) { cons_show("Usage: %s", help.usage); @@ -1609,6 +1640,10 @@ cmd_roster(gchar **args, struct cmd_help_t help) // change nickname } else if (strcmp(args[0], "nick") == 0) { + if (conn_status != JABBER_CONNECTED) { + cons_show("You are not currently connected."); + return TRUE; + } char *jid = args[1]; if (jid == NULL) { cons_show("Usage: %s", help.usage); @@ -1639,6 +1674,10 @@ cmd_roster(gchar **args, struct cmd_help_t help) // remove nickname } else if (strcmp(args[0], "clearnick") == 0) { + if (conn_status != JABBER_CONNECTED) { + cons_show("You are not currently connected."); + return TRUE; + } char *jid = args[1]; if (jid == NULL) { cons_show("Usage: %s", help.usage); diff --git a/tests/functionaltests/proftest.c b/tests/functionaltests/proftest.c index 78a82c11..613c2c7a 100644 --- a/tests/functionaltests/proftest.c +++ b/tests/functionaltests/proftest.c @@ -123,12 +123,16 @@ _cleanup_dirs(void) void prof_start(void) { - fd = exp_spawnl("./profanity", "./profanity", "-l", "DEBUG", NULL); + // helper script sets terminal columns, avoids assertions failing + // based on the test runner terminal size + fd = exp_spawnl("sh", + "sh", + "-c", + "./tests/functionaltests/start_profanity.sh", + NULL); FILE *fp = fdopen(fd, "r+"); - if (fp == NULL) { - assert_true(FALSE); - } + assert_true(fp != NULL); setbuf(fp, (char *)0); } @@ -155,15 +159,20 @@ init_prof_test(void **state) _create_logs_dir(); prof_start(); - prof_output_exact("Profanity"); + assert_true(prof_output_exact("Profanity")); + // set UI options to make expect assertions faster and more reliable prof_input("/inpblock timeout 5"); - prof_output_exact("Input blocking set to 5 milliseconds"); + assert_true(prof_output_exact("Input blocking set to 5 milliseconds")); prof_input("/inpblock dynamic off"); - prof_output_exact("Dynamic input blocking disabled"); - + assert_true(prof_output_exact("Dynamic input blocking disabled")); prof_input("/notify message off"); - prof_output_exact("Message notifications disabled"); + assert_true(prof_output_exact("Message notifications disabled")); + prof_input("/wrap off"); + assert_true(prof_output_exact("Word wrap disabled")); + prof_input("/roster hide"); + assert_true(prof_output_exact("Roster disabled")); + prof_input("/time off"); } void diff --git a/tests/functionaltests/start_profanity.sh b/tests/functionaltests/start_profanity.sh new file mode 100755 index 00000000..58ceadd7 --- /dev/null +++ b/tests/functionaltests/start_profanity.sh @@ -0,0 +1,2 @@ +export COLUMNS=300 +./profanity -l DEBUG diff --git a/tests/unittests/test_cmd_roster.c b/tests/unittests/test_cmd_roster.c index a7160cf5..dc1b612e 100644 --- a/tests/unittests/test_cmd_roster.c +++ b/tests/unittests/test_cmd_roster.c @@ -16,12 +16,13 @@ static void test_with_connection_status(jabber_conn_status_t status) { CommandHelp *help = malloc(sizeof(CommandHelp)); + gchar *args[] = { NULL }; will_return(jabber_get_connection_status, status); expect_cons_show("You are not currently connected."); - gboolean result = cmd_roster(NULL, *help); + gboolean result = cmd_roster(args, *help); assert_true(result); free(help); -- cgit 1.4.1-2-gfad0