From: <jgr...@us...> - 2003-03-25 05:25:27
|
Update of /cvsroot/popfile/engine In directory sc8-pr-cvs1:/tmp/cvs-serv20897 Modified Files: popfile.pl tests.pl Log Message: Make the UI pluggable; make SMTP, NNTP and POP3 modules register and handle their own configuration UI; factor the HTTP code out of the UI and into own class; implement XML-RPC interface; make test suite allow selection of tests to run; change the way POPFile reports its startup; make the version string work Index: popfile.pl =================================================================== RCS file: /cvsroot/popfile/engine/popfile.pl,v retrieving revision 1.207 retrieving revision 1.208 diff -C2 -d -r1.207 -r1.208 *** popfile.pl 14 Mar 2003 23:12:48 -0000 1.207 --- popfile.pl 25 Mar 2003 05:24:51 -0000 1.208 *************** *** 189,192 **** --- 189,194 ---- my ( $directory, $type ) = @_; + print "\n {$type:"; + # Look for all the .pm files in named directory and then see which of them # are POPFile modules indicated by the first line of the file being and *************** *** 212,219 **** $components{$type}{$name} = $mod; ! print " {$name}"; } } } } --- 214,223 ---- $components{$type}{$name} = $mod; ! print " $name"; } } } + + print '} '; } *************** *** 224,227 **** --- 228,236 ---- # + my ( $major_version, $minor_version, $build_version ) = ( 0, 19, 0 ); + my $version_string = "v$major_version.$minor_version.$build_version"; + + print "\nPOPFile Engine $version_string loading\n"; + $SIG{QUIT} = \&aborting; $SIG{ABRT} = \&aborting; *************** *** 239,243 **** # modules, the classifier, the UI (currently HTML based), and the POP3 proxy. ! print " Loading... "; # Look for a module called Platform::<platform> where <platform> is the value of $^O --- 248,252 ---- # modules, the classifier, the UI (currently HTML based), and the POP3 proxy. ! print "\n Loading... "; # Look for a module called Platform::<platform> where <platform> is the value of $^O *************** *** 254,272 **** my $name = $mod->name(); $components{core}{$name} = $mod; ! print " {$name}"; } load_modules( 'POPFile', 'core' ); load_modules( 'Classifier', 'classifier' ); ! load_modules( 'UI', 'ui' ); load_modules( 'Proxy', 'proxy' ); ! # The version number ! ! $components{core}{config}->{major_version} = 0; ! $components{core}{config}->{minor_version} = 19; ! $components{core}{config}->{build_version} = 0; ! ! print "\nPOPFile Engine v$components{core}{config}->{major_version}.$components{core}{config}->{minor_version}.$components{core}{config}->{build_version} starting"; # Link each of the main objects with the configuration object so that they can set their --- 263,275 ---- my $name = $mod->name(); $components{core}{$name} = $mod; ! print "\n {core: $name}"; } load_modules( 'POPFile', 'core' ); load_modules( 'Classifier', 'classifier' ); ! load_modules( 'UI', 'interface' ); load_modules( 'Proxy', 'proxy' ); ! print "\n\nPOPFile Engine $version_string starting"; # Link each of the main objects with the configuration object so that they can set their *************** *** 275,278 **** --- 278,282 ---- foreach my $type (keys %components) { foreach my $name (keys %{$components{$type}}) { + $components{$type}{$name}->version( $version_string ); $components{$type}{$name}->configuration( $components{core}{config} ); $components{$type}{$name}->logger( $components{core}{logger} ) if ( $name ne 'logger' ); *************** *** 280,303 **** } ! # All proxies need access to the classifier and the UI foreach my $name (keys %{$components{proxy}}) { $components{proxy}{$name}->classifier( $components{classifier}{bayes} ); ! $components{proxy}{$name}->ui( $components{ui}{ui} ); } ! # All UI components need access to the classifier ! foreach my $name (keys %{$components{ui}}) { ! $components{ui}{$name}->classifier( $components{classifier}{bayes} ); } ! print "\n Initializing... "; # Tell each module to initialize itself foreach my $type (keys %components) { foreach my $name (keys %{$components{$type}}) { ! print "{$name} "; flush STDOUT; if ( $components{$type}{$name}->initialize() == 0 ) { --- 284,309 ---- } ! # All proxies need access to the classifier and the interface foreach my $name (keys %{$components{proxy}}) { $components{proxy}{$name}->classifier( $components{classifier}{bayes} ); ! $components{proxy}{$name}->ui( $components{interface}{html} ); } ! # All interface components need access to the classifier and the UI ! foreach my $name (keys %{$components{interface}}) { ! $components{interface}{$name}->classifier( $components{classifier}{bayes} ); ! $components{interface}{$name}->ui( $components{interface}{html} ) if ( $name ne 'html' ); } ! print "\n\n Initializing... "; # Tell each module to initialize itself foreach my $type (keys %components) { + print "\n {$type:"; foreach my $name (keys %{$components{$type}}) { ! print " $name"; flush STDOUT; if ( $components{$type}{$name}->initialize() == 0 ) { *************** *** 309,312 **** --- 315,319 ---- $components{$type}{$name}->pipeready( \&pipeready ); } + print '} '; } *************** *** 317,327 **** $components{core}{config}->parse_command_line(); ! print "\n Starting... "; # Now that the configuration is set tell each module to begin operation foreach my $type (keys %components) { foreach my $name (keys %{$components{$type}}) { ! print "{$name} "; flush STDOUT; if ( $components{$type}{$name}->start() == 0 ) { --- 324,335 ---- $components{core}{config}->parse_command_line(); ! print "\n\n Starting... "; # Now that the configuration is set tell each module to begin operation foreach my $type (keys %components) { + print "\n {$type:"; foreach my $name (keys %{$components{$type}}) { ! print " $name"; flush STDOUT; if ( $components{$type}{$name}->start() == 0 ) { *************** *** 329,335 **** } } } ! print "\nPOPFile Engine v$components{core}{config}->{major_version}.$components{core}{config}->{minor_version}.$components{core}{config}->{build_version} running\n"; flush STDOUT; --- 337,344 ---- } } + print '} '; } ! print "\n\nPOPFile Engine $version_string running\n"; flush STDOUT; *************** *** 363,380 **** } ! print " Stopping... "; # Shutdown all the modules foreach my $type (keys %components) { foreach my $name (keys %{$components{$type}}) { ! print "{$name} "; flush STDOUT; $components{$type}{$name}->alive(0); $components{$type}{$name}->stop(); } } ! print "\n Saving configuration\n"; flush STDOUT; --- 372,395 ---- } ! print "\n\nPOPFile Engine $version_string stopping\n"; ! flush STDOUT; ! ! print "\n Stopping... "; # Shutdown all the modules foreach my $type (keys %components) { + print "\n {$type:"; foreach my $name (keys %{$components{$type}}) { ! print " $name"; flush STDOUT; $components{$type}{$name}->alive(0); $components{$type}{$name}->stop(); } + + print '} '; } ! print "\n\n Saving configuration\n"; flush STDOUT; *************** *** 383,387 **** $components{core}{config}->save_configuration(); ! print "POPFile Engine v$components{core}{config}->{major_version}.$components{core}{config}->{minor_version}.$components{core}{config}->{build_version} terminating\n"; # --------------------------------------------------------------------------------------------- --- 398,402 ---- $components{core}{config}->save_configuration(); ! print "\nPOPFile Engine $version_string terminated\n"; # --------------------------------------------------------------------------------------------- Index: tests.pl =================================================================== RCS file: /cvsroot/popfile/engine/tests.pl,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tests.pl 25 Feb 2003 02:04:11 -0000 1.13 --- tests.pl 25 Mar 2003 05:24:52 -0000 1.14 *************** *** 110,115 **** --- 110,125 ---- my @tests = glob 'tests/*.tst'; + # Either match all the possible tests, or take the first argument + # on the command line and use it as a regular expression that must + # match the name of the TST file for the test suite in that file + # to be run + + my $pattern = '.*'; + $pattern = "$ARGV[0].*" if ( $#ARGV == 0 ); + foreach my $test (@tests) { + if ( $test =~ /$pattern/ ) { + # This works by reading the entire suite into the $suite variable # and then changing calls to test_assert_equal so that they include *************** *** 141,145 **** print "ok (" . ( $test_count - $current_test_count ) . " ok)"; } } ! print "\n\n$test_count tests, " . ( $test_count - $test_failures ) . " ok, $test_failures failed\n\n"; \ No newline at end of file --- 151,156 ---- print "ok (" . ( $test_count - $current_test_count ) . " ok)"; } + } } ! print "\n\n$test_count tests, " . ( $test_count - $test_failures ) . " ok, $test_failures failed\n\n"; |