Changeset dec60b4 for tester.c


Ignore:
Timestamp:
Jun 17, 2010, 9:41:41 AM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
3c2c7fc
Parents:
68e5464 (diff), 95414bf (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge branch 'perl-tester'
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester.c

    r3f6555d rdec60b4  
     1#define OWL_PERL
     2#define WINDOW FAKE_WINDOW
    13#include "owl.h"
     4#undef WINDOW
     5
    26#include <unistd.h>
    37#include <stdlib.h>
    48
     9#undef instr
     10#include <curses.h>
     11
    512owl_global g;
    613
    714int numtests;
    815
     16int owl_regtest(void);
    917int owl_util_regtest(void);
    1018int owl_dict_regtest(void);
     
    1422int owl_editwin_regtest(void);
    1523
     24extern void owl_perl_xs_init(pTHX);
     25
    1626int main(int argc, char **argv, char **env)
    1727{
     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
    1838  /* initialize a fake ncurses, detached from std{in,out} */
    19   FILE *rnull = fopen("/dev/null", "r");
    20   FILE *wnull = fopen("/dev/null", "w");
     39  wnull = fopen("/dev/null", "w");
     40  rnull = fopen("/dev/null", "r");
    2141  newterm("xterm", wnull, rnull);
    2242  /* initialize global structures */
    2343  owl_global_init(&g);
    2444
     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 some
     70     * 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
     96int owl_regtest(void) {
    2597  numtests = 0;
    2698  int numfailures=0;
     
    38110  }
    39111  printf("1..%d\n", numtests);
    40 
    41   /* probably not necessary, but tear down the screen */
    42   endwin();
    43   fclose(rnull);
    44   fclose(wnull);
    45112
    46113  return(numfailures);
Note: See TracChangeset for help on using the changeset viewer.