Permalink
Browse files

Merge branch 'perl-tester'

  • Loading branch information...
nelhage committed Jun 17, 2010
2 parents 68e5464 + 95414bf commit dec60b4b6511273a5cf1e7bab8423390256e15da
Showing with 124 additions and 106 deletions.
  1. +0 −1 .gitignore
  2. +3 −10 Makefile.am
  3. +1 −1 barnowl
  4. +32 −0 global.c
  5. +1 −31 owl.c
  6. +0 −36 perl_tester.c
  7. +3 −1 perlconfig.c
  8. +6 −1 runtests.sh
  9. +1 −1 t/00-core-tests.t
  10. +2 −17 t/mock.pl
  11. +1 −0 tester
  12. +74 −7 tester.c
View
@@ -34,5 +34,4 @@ perlglue.c
perlwrap.c
pm_to_blib
stamp-h1
-tester
varstubs.c
View
@@ -11,7 +11,7 @@ endif
zcrypt_SOURCES = zcrypt.c filterproc.c
-check_PROGRAMS = tester perl_tester
+check_PROGRAMS = tester.bin
barnowl_bin_SOURCES = $(BASE_SRCS) \
owl.h owl_perl.h config.h \
@@ -20,19 +20,12 @@ barnowl_bin_SOURCES = $(BASE_SRCS) \
barnowl_bin_LDADD = libfaim/libfaim.a
-tester_SOURCES = $(BASE_SRCS) \
+tester_bin_SOURCES = $(BASE_SRCS) \
owl.h owl_perl.h config.h \
$(GEN_C) $(GEN_H) \
tester.c
-tester_LDADD = libfaim/libfaim.a
-
-perl_tester_SOURCES = $(BASE_SRCS) \
- owl.h owl_perl.h config.h \
- $(GEN_C) $(GEN_H) \
- perl_tester.c
-
-perl_tester_LDADD = libfaim/libfaim.a
+tester_bin_LDADD = libfaim/libfaim.a
TESTS=runtests.sh
View
@@ -4,7 +4,7 @@
# binary.
SRCDIR=`dirname "${0}"`
-EXE="$SRCDIR/barnowl.bin"
+EXE="$0.bin"
if ! test -x "$EXE"; then
echo "Cannot find barnowl.bin" >&2
View
@@ -1031,3 +1031,35 @@ void owl_global_set_interrupted(owl_global *g) {
void owl_global_unset_interrupted(owl_global *g) {
g->interrupted = 0;
}
+
+void owl_global_setup_default_filters(owl_global *g)
+{
+ int i;
+ static const struct {
+ const char *name;
+ const char *desc;
+ } filters[] = {
+ { "personal",
+ "private ^true$ and ( not type ^zephyr$ or "
+ "( class ^message and ( instance ^personal$ or instance ^urgent$ ) ) )" },
+ { "trash",
+ "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )" },
+ { "wordwrap", "not ( type ^admin$ or type ^zephyr$ )" },
+ { "ping", "opcode ^ping$" },
+ { "auto", "opcode ^auto$" },
+ { "login", "not login ^none$" },
+ { "reply-lockout", "class ^noc or class ^mail$" },
+ { "out", "direction ^out$" },
+ { "aim", "type ^aim$" },
+ { "zephyr", "type ^zephyr$" },
+ { "none", "false" },
+ { "all", "true" },
+ { NULL, NULL }
+ };
+
+ owl_function_debugmsg("startup: creating default filters");
+
+ for (i = 0; filters[i].name != NULL; i++)
+ owl_global_add_filter(g, owl_filter_new_fromstring(filters[i].name,
+ filters[i].desc));
+}
View
32 owl.c
@@ -148,36 +148,6 @@ void owl_start_curses(void) {
owl_start_color();
}
-static void owl_setup_default_filters(void)
-{
- int i;
- static const struct {
- const char *name;
- const char *desc;
- } filters[] = {
- { "personal",
- "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message ) )" },
- { "trash",
- "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )" },
- { "wordwrap", "not ( type ^admin$ or type ^zephyr$ )" },
- { "ping", "opcode ^ping$" },
- { "auto", "opcode ^auto$" },
- { "login", "not login ^none$" },
- { "reply-lockout", "class ^noc or class ^mail$" },
- { "out", "direction ^out$" },
- { "aim", "type ^aim$" },
- { "zephyr", "type ^zephyr$" },
- { "none", "false" },
- { "all", "true" },
- { NULL, NULL }
- };
-
- owl_function_debugmsg("startup: creating default filters");
-
- for (i = 0; filters[i].name != NULL; i++)
- owl_global_add_filter(&g, owl_filter_new_fromstring(filters[i].name,
- filters[i].desc));
-}
/*
* Process a new message passed to us on the message queue from some
@@ -562,7 +532,7 @@ int main(int argc, char **argv, char **env)
owl_global_complete_setup(&g);
- owl_setup_default_filters();
+ owl_global_setup_default_filters(&g);
/* set the current view */
owl_function_debugmsg("startup: setting the current view");
View
@@ -1,36 +0,0 @@
-#define OWL_PERL
-#include "owl.h"
-
-owl_global g;
-
-extern XS(boot_BarnOwl);
-extern XS(boot_DynaLoader);
-/* extern XS(boot_DBI); */
-
-static void owl_perl_xs_init(pTHX)
-{
- const char *file = __FILE__;
- dXSUB_SYS;
- {
- newXS("BarnOwl::bootstrap", boot_BarnOwl, file);
- newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
- }
-}
-
-static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
-
-int main(int argc, char **argv, char **env)
-{
- /* Code from perldoc perlembed */
- PERL_SYS_INIT3(&argc,&argv,&env);
- my_perl = perl_alloc();
- perl_construct(my_perl);
- PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
- perl_parse(my_perl, owl_perl_xs_init, argc, argv, (char **)NULL);
- perl_run(my_perl);
- perl_destruct(my_perl);
- perl_free(my_perl);
- PERL_SYS_TERM();
- return 0;
-}
-
View
@@ -11,7 +11,7 @@ extern XS(boot_BarnOwl);
extern XS(boot_DynaLoader);
/* extern XS(boot_DBI); */
-static void owl_perl_xs_init(pTHX)
+void owl_perl_xs_init(pTHX) /* noproto */
{
const char *file = __FILE__;
dXSUB_SYS;
@@ -362,6 +362,8 @@ char *owl_perlconfig_initperl(const char * file, int *Pargc, char ***Pargv, char
owl_global_set_perlinterp(&g, p);
perl_construct(p);
+ PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
+
owl_global_set_no_have_config(&g);
ret=perl_parse(p, owl_perl_xs_init, 2, (char **)args, NULL);
View
@@ -1,2 +1,7 @@
#!/bin/sh
-HARNESS_PERL=./perl_tester exec prove t/
+SRCDIR=`dirname "${0}"`
+
+export BARNOWL_DATA_DIR="$SRCDIR/perl/"
+export BARNOWL_BIN_DIR="$SRCDIR/"
+
+HARNESS_PERL=./tester exec prove t/
View
@@ -1,3 +1,3 @@
#!/usr/bin/env perl
use File::Basename;
-system(dirname($0) . "/../tester");
+system(dirname($0) . "/../tester", "--builtin");
View
@@ -1,25 +1,10 @@
-use File::Basename;
-use lib (dirname($0) . '/../perl/lib');
-
package BarnOwl;
use strict;
use warnings;
-use Carp;
-
-sub get_data_dir {"."}
-sub get_config_dir {"."}
-sub create_style {}
-sub debug {
+no warnings 'redefine';
+sub debug($) {
warn "[DEBUG] ", shift, "\n" if $ENV{TEST_VERBOSE};
}
-sub BarnOwl::Internal::new_command {}
-sub BarnOwl::Internal::new_variable_bool {}
-sub BarnOwl::Internal::new_variable_int {}
-sub BarnOwl::Internal::new_variable_string {}
-sub BarnOwl::Editwin::save_excursion(&) {}
-
-use BarnOwl;
-
1;
View
1 tester
View
@@ -1,27 +1,99 @@
+#define OWL_PERL
+#define WINDOW FAKE_WINDOW
#include "owl.h"
+#undef WINDOW
+
#include <unistd.h>
#include <stdlib.h>
+#undef instr
+#include <curses.h>
+
owl_global g;
int numtests;
+int owl_regtest(void);
int owl_util_regtest(void);
int owl_dict_regtest(void);
int owl_variable_regtest(void);
int owl_filter_regtest(void);
int owl_obarray_regtest(void);
int owl_editwin_regtest(void);
+extern void owl_perl_xs_init(pTHX);
+
int main(int argc, char **argv, char **env)
{
+ FILE *rnull;
+ FILE *wnull;
+ char *perlerr;
+ int status = 0;
+
+ if (argc <= 1) {
+ fprintf(stderr, "Usage: %s --builtin|TEST.t|-le CODE\n", argv[0]);
+ return 1;
+ }
+
/* initialize a fake ncurses, detached from std{in,out} */
- FILE *rnull = fopen("/dev/null", "r");
- FILE *wnull = fopen("/dev/null", "w");
+ wnull = fopen("/dev/null", "w");
+ rnull = fopen("/dev/null", "r");
newterm("xterm", wnull, rnull);
/* initialize global structures */
owl_global_init(&g);
+ perlerr = owl_perlconfig_initperl(NULL, &argc, &argv, &env);
+ if (perlerr) {
+ endwin();
+ fprintf(stderr, "Internal perl error: %s\n", perlerr);
+ status = 1;
+ goto out;
+ }
+
+ owl_global_complete_setup(&g);
+ owl_global_setup_default_filters(&g);
+
+ owl_view_create(owl_global_get_current_view(&g), "main",
+ owl_global_get_filter(&g, "all"),
+ owl_global_get_style_by_name(&g, "default"));
+
+ owl_function_firstmsg();
+
+ ENTER;
+ SAVETMPS;
+
+ if (strcmp(argv[1], "--builtin") == 0) {
+ status = owl_regtest();
+ } else if (strcmp(argv[1], "-le") == 0 && argc > 2) {
+ /*
+ * 'prove' runs its harness perl with '-le CODE' to get some
+ * information out.
+ */
+ moreswitches("l");
+ eval_pv(argv[2], true);
+ } else {
+ sv_setpv(get_sv("0", false), argv[1]);
+ sv_setpv(get_sv("main::test_prog", TRUE), argv[1]);
+
+ eval_pv("do $main::test_prog; die($@) if($@)", true);
+ }
+
+ status = 0;
+
+ FREETMPS;
+ LEAVE;
+
+ out:
+ perl_destruct(owl_global_get_perlinterp(&g));
+ perl_free(owl_global_get_perlinterp(&g));
+ /* probably not necessary, but tear down the screen */
+ endwin();
+ fclose(rnull);
+ fclose(wnull);
+ return status;
+}
+
+int owl_regtest(void) {
numtests = 0;
int numfailures=0;
/*
@@ -38,11 +110,6 @@ int main(int argc, char **argv, char **env)
}
printf("1..%d\n", numtests);
- /* probably not necessary, but tear down the screen */
- endwin();
- fclose(rnull);
- fclose(wnull);
-
return(numfailures);
}

0 comments on commit dec60b4

Please sign in to comment.