Changes in tester.c [95414bf:3f6555d]
Legend:
- Unmodified
- Added
- Removed
-
tester.c
r95414bf r3f6555d 1 #define OWL_PERL2 #define WINDOW FAKE_WINDOW3 1 #include "owl.h" 4 #undef WINDOW5 6 2 #include <unistd.h> 7 3 #include <stdlib.h> 8 4 9 #undef instr10 #include <curses.h>11 12 5 owl_global g; 13 6 14 7 int numtests; 15 8 16 int owl_regtest(void);17 9 int owl_util_regtest(void); 18 10 int owl_dict_regtest(void); … … 22 14 int owl_editwin_regtest(void); 23 15 24 extern void owl_perl_xs_init(pTHX);25 26 16 int main(int argc, char **argv, char **env) 27 17 { 28 FILE *rnull;29 FILE *wnull;30 char *perlerr;31 int status = 0;32 33 if (argc <= 1) {34 fprintf(stderr, "Usage: %s --builtin|TEST.t|-le CODE\n", argv[0]);35 return 1;36 }37 38 18 /* initialize a fake ncurses, detached from std{in,out} */ 39 wnull = fopen("/dev/null", "w");40 rnull = fopen("/dev/null", "r");19 FILE *rnull = fopen("/dev/null", "r"); 20 FILE *wnull = fopen("/dev/null", "w"); 41 21 newterm("xterm", wnull, rnull); 42 22 /* initialize global structures */ 43 23 owl_global_init(&g); 44 24 45 perlerr = owl_perlconfig_initperl(NULL, &argc, &argv, &env);46 if (perlerr) {47 endwin();48 fprintf(stderr, "Internal perl error: %s\n", perlerr);49 status = 1;50 goto out;51 }52 53 owl_global_complete_setup(&g);54 owl_global_setup_default_filters(&g);55 56 owl_view_create(owl_global_get_current_view(&g), "main",57 owl_global_get_filter(&g, "all"),58 owl_global_get_style_by_name(&g, "default"));59 60 owl_function_firstmsg();61 62 ENTER;63 SAVETMPS;64 65 if (strcmp(argv[1], "--builtin") == 0) {66 status = owl_regtest();67 } else if (strcmp(argv[1], "-le") == 0 && argc > 2) {68 /*69 * 'prove' runs its harness perl with '-le CODE' to get some70 * information out.71 */72 moreswitches("l");73 eval_pv(argv[2], true);74 } else {75 sv_setpv(get_sv("0", false), argv[1]);76 sv_setpv(get_sv("main::test_prog", TRUE), argv[1]);77 78 eval_pv("do $main::test_prog; die($@) if($@)", true);79 }80 81 status = 0;82 83 FREETMPS;84 LEAVE;85 86 out:87 perl_destruct(owl_global_get_perlinterp(&g));88 perl_free(owl_global_get_perlinterp(&g));89 /* probably not necessary, but tear down the screen */90 endwin();91 fclose(rnull);92 fclose(wnull);93 return status;94 }95 96 int owl_regtest(void) {97 25 numtests = 0; 98 26 int numfailures=0; … … 105 33 numfailures += owl_variable_regtest(); 106 34 numfailures += owl_filter_regtest(); 107 numfailures += owl_obarray_regtest();108 35 numfailures += owl_editwin_regtest(); 109 36 if (numfailures) { … … 111 38 } 112 39 printf("1..%d\n", numtests); 40 41 /* probably not necessary, but tear down the screen */ 42 endwin(); 43 fclose(rnull); 44 fclose(wnull); 113 45 114 46 return(numfailures); … … 368 300 } 369 301 370 371 int owl_obarray_regtest(void) {372 int numfailed = 0;373 const char *p,*p2;374 375 owl_obarray oa;376 owl_obarray_init(&oa);377 378 printf("# BEGIN testing owl_obarray\n");379 380 p = owl_obarray_insert(&oa, "test");381 FAIL_UNLESS("returned string is equal", p && !strcmp(p, "test"));382 p2 = owl_obarray_insert(&oa, "test");383 FAIL_UNLESS("returned string is equal", p2 && !strcmp(p2, "test"));384 FAIL_UNLESS("returned the same string", p2 && p == p2);385 386 p = owl_obarray_insert(&oa, "test2");387 FAIL_UNLESS("returned string is equal", p && !strcmp(p, "test2"));388 p2 = owl_obarray_find(&oa, "test2");389 FAIL_UNLESS("returned the same string", p2 && !strcmp(p2, "test2"));390 391 p = owl_obarray_find(&oa, "nothere");392 FAIL_UNLESS("Didn't find a string that isn't there", p == NULL);393 394 printf("# END testing owl_obarray (%d failures)\n", numfailed);395 396 return numfailed;397 }398 399 302 int owl_editwin_regtest(void) { 400 303 int numfailed = 0;
Note: See TracChangeset
for help on using the changeset viewer.