1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Debugging expect test

This commit is contained in:
James Booth 2015-07-16 23:53:26 +01:00
parent 4027968b4c
commit ba50414ac2
4 changed files with 38 additions and 8 deletions

View File

@ -57,10 +57,12 @@ int main(int argc, char* argv[]) {
init_prof_test, init_prof_test,
close_prof_test), close_prof_test),
*/ */
unit_test(expect_test),
/*
unit_test_setup_teardown(presence_online, unit_test_setup_teardown(presence_online,
init_prof_test, init_prof_test,
close_prof_test), close_prof_test),
/*
unit_test_setup_teardown(presence_online_with_message, unit_test_setup_teardown(presence_online_with_message,
init_prof_test, init_prof_test,
close_prof_test), close_prof_test),
@ -117,7 +119,7 @@ int main(int argc, char* argv[]) {
unit_test_setup_teardown(new_session_when_message_received_from_different_fulljid, unit_test_setup_teardown(new_session_when_message_received_from_different_fulljid,
init_prof_test, init_prof_test,
close_prof_test), close_prof_test),
*/
unit_test_setup_teardown(send_enable_carbons, unit_test_setup_teardown(send_enable_carbons,
init_prof_test, init_prof_test,
close_prof_test), close_prof_test),
@ -127,6 +129,7 @@ int main(int argc, char* argv[]) {
unit_test_setup_teardown(send_disable_carbons, unit_test_setup_teardown(send_disable_carbons,
init_prof_test, init_prof_test,
close_prof_test), close_prof_test),
*/
}; };
return run_tests(all_tests); return run_tests(all_tests);

View File

@ -1,5 +1,6 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <glib.h> #include <glib.h>
#include "glib/gstdio.h"
#include <setjmp.h> #include <setjmp.h>
#include <stdarg.h> #include <stdarg.h>
@ -130,6 +131,10 @@ prof_start(void)
Tcl_Init(interp); Tcl_Init(interp);
Expect_Init(interp); Expect_Init(interp);
FILE *logp = fopen("./expout.log", "a");
g_chmod("./expout.log", S_IRUSR | S_IWUSR);
exp_debugfile = logp;
// helper script sets terminal columns, avoids assertions failing // helper script sets terminal columns, avoids assertions failing
// based on the test runner terminal size // based on the test runner terminal size
fd = exp_spawnl("sh", fd = exp_spawnl("sh",
@ -137,6 +142,7 @@ prof_start(void)
"-c", "-c",
"./tests/functionaltests/start_profanity.sh", "./tests/functionaltests/start_profanity.sh",
NULL); NULL);
FILE *fp = fdopen(fd, "r+"); FILE *fp = fdopen(fd, "r+");
assert_true(fp != NULL); assert_true(fp != NULL);
@ -179,7 +185,10 @@ init_prof_test(void **state)
assert_true(prof_output_exact("Word wrap disabled")); assert_true(prof_output_exact("Word wrap disabled"));
prof_input("/roster hide"); prof_input("/roster hide");
assert_true(prof_output_exact("Roster disabled")); assert_true(prof_output_exact("Roster disabled"));
prof_input("/time off"); prof_input("/time statusbar off");
assert_true(prof_output_exact("Status bar time display disabled"));
prof_input("/time main off");
assert_true(prof_output_exact("Time display disabled"));
} }
void void
@ -203,10 +212,18 @@ close_prof_test(void **state)
void void
prof_input(char *input) prof_input(char *input)
{ {
GString *inp_str = g_string_new(input); int i = 0;
g_string_append(inp_str, "\r"); for (i = 0; i < strlen(input); i++) {
write(fd, inp_str->str, inp_str->len); write(fd, &input[i], 1);
g_string_free(inp_str, TRUE); }
prof_output_exact(input);
char *newline = "\r";
write(fd, newline, 1);
// GString *inp_str = g_string_new(input);
// g_string_append(inp_str, "\r");
// write(fd, inp_str->str, inp_str->len);
// g_string_free(inp_str, TRUE);
} }
int int

View File

@ -11,6 +11,13 @@
#include "proftest.h" #include "proftest.h"
void
expect_test(void **state)
{
init_prof_test(state);
prof_input("0123456789");
}
void void
presence_online(void **state) presence_online(void **state)
{ {
@ -23,8 +30,10 @@ presence_online(void **state)
"<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>"
"</presence>" "</presence>"
)); ));
//
// assert_true(prof_output_exact("Status set to online (priority 0)"));
assert_true(prof_output_exact("Status set to online (priority 0)")); assert_true(1);
} }
void void

View File

@ -1,3 +1,4 @@
void expect_test(void **state);
void presence_away(void **state); void presence_away(void **state);
void presence_away_with_message(void **state); void presence_away_with_message(void **state);
void presence_online(void **state); void presence_online(void **state);