Permalink
Browse files

Merge perl_tester and tester.

  • Loading branch information...
1 parent de18326 commit 5aa33fd73dce2c8d6c88559e62cd1ae78ef4a36d @nelhage committed May 19, 2010
Showing with 52 additions and 64 deletions.
  1. +1 −8 Makefile.am
  2. +0 −36 perl_tester.c
  3. +3 −1 perlconfig.c
  4. +1 −1 runtests.sh
  5. +2 −17 t/mock.pl
  6. +45 −1 tester.c
View
@@ -10,7 +10,7 @@ endif
zcrypt_SOURCES = zcrypt.c filterproc.c
-check_PROGRAMS = tester.bin perl_tester
+check_PROGRAMS = tester.bin
barnowl_bin_SOURCES = $(BASE_SRCS) \
owl.h owl_perl.h config.h \
@@ -26,13 +26,6 @@ tester_bin_SOURCES = $(BASE_SRCS) \
tester_bin_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
-
TESTS=runtests.sh
CPPFLAGS = -I$(top_srcdir)/ \
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
@@ -4,4 +4,4 @@ SRCDIR=`dirname "${0}"`
export BARNOWL_DATA_DIR="$SRCDIR/perl/"
export BARNOWL_BIN_DIR="$SRCDIR/"
-HARNESS_PERL=./perl_tester exec prove t/
+HARNESS_PERL=./tester exec prove t/
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,7 +1,14 @@
+#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;
@@ -14,6 +21,8 @@ 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)
{
/* initialize a fake ncurses, detached from std{in,out} */
@@ -34,9 +43,44 @@ int main(int argc, char **argv, char **env)
}
owl_global_complete_setup(&g);
- status = owl_regtest();
+ if (argc > 1) {
+ char *code;
+ FILE *f;
+
+ if (strcmp(argv[1], "-le") == 0 && argc > 2) {
+ /*
+ * 'prove' runs its harness perl with '-le CODE' to get some
+ * information out.
+ */
+ moreswitches("l");
+ code = argv[2];
+ } else {
+ f = fopen(argv[1], "r");
+ if (!f) {
+ perror(argv[1]);
+ status = 1;
+ goto out;
+ }
+ code = owl_slurp(f);
+ sv_setpv(get_sv("0", false), argv[1]);
+ }
+
+ ENTER;
+ SAVETMPS;
+
+ eval_pv(code, true);
+
+ status = 0;
+
+ FREETMPS;
+ LEAVE;
+ } else {
+ status = owl_regtest();
+ }
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);

0 comments on commit 5aa33fd

Please sign in to comment.