[Lxr-commits] CVS: lxr/tests AllTests.pm,NONE,1.1 ConfigTest.pm,NONE,1.1 lxr.conf,NONE,1.1 test-vers
Brought to you by:
ajlittoz
|
From: Malcolm B. <mb...@us...> - 2002-03-04 15:11:30
|
Update of /cvsroot/lxr/lxr/tests In directory usw-pr-cvs1:/tmp/cvs-serv19986 Added Files: AllTests.pm ConfigTest.pm lxr.conf test-versions Log Message: Add automatic test framework and first tests to LXR. This depends on the Test::Unit suite from http://sf.net/projects/perlunit for the basic framework. Currently an "AllTests" module is defined that should run all the tests currently available, as well as a ConfigTest module that makes a start on testing the LXR::Config.pm module. Additional tests are planned and this should grow into a complete, easy to run and maintain test suite that lets us catch regressions. In future I plan to add a test to this suite for each bug reported, before fixing it. This (a) proves the bug exists and (b) makes it easy to see when it has been fixed. And it catches regressions when bugs come back. To use this, you will need to: 1) Install Class::Inner from CPAN 2) Install Error from CPAN 3) Download the latest CVS version of Test::Unit from the URL above 4) Build and install Test::Unit from the CVS sources --- NEW FILE: AllTests.pm --- package AllTests; use ConfigTest; use Test::Unit::TestRunner; use Test::Unit::TestSuite; sub new { my $class = shift; return bless {}, $class; } sub suite { my $class = shift; my $suite = Test::Unit::TestSuite->empty_new("LXR Tests"); $suite->add_test(Test::Unit::TestSuite->new("ConfigTest")); return $suite; } 1; --- NEW FILE: ConfigTest.pm --- # Test cases for the LXR::Config module # Uses the associated lxr.conf file package ConfigTest; use strict; use Test::Unit; use lib ".."; use lib "../lib"; use LXR::Config; use base qw(Test::Unit::TestCase); sub new { my $self = shift()->SUPER::new(@_); $self->{config} = 0; return $self; } # define tests # test that the config object was created successfully sub test_creation { my $self = shift; $self->assert(defined($self->{config}), "Config init failed"); } # Access some of the values to check what is found sub test_access { my $self = shift; $self->assert($self->{config}->swishindex eq '/test/lxr/bin/swish-e', "swishindex read failed"); $self->assert($self->{config}->baseurl eq 'http://test/lxr', "Config accessed wrong baseurl"); } # test access to the variables section sub test_variables { my $self = shift; $self->assert($self->{config}->variable('v') == '1.0.6', "Variable default not correct"); $self->assert(($self->{config}->varrange('v'))[1] =~ /hi hippy/, "Variable value missing"); } sub test_allvariables { my $self = shift; my @vars = $self->{config}->allvariables(); $self->assert(grep {$_ eq 'v'} @vars, "allvariables didn't return v"); $self->assert(grep {$_ eq 'a'} @vars, "allvariables didn't return a"); $self->assert($#vars == 2, "Too many variables returned"); } # set_up and tear_down are used to # prepare and release resources need for testing # Prepare a config object sub set_up { my $self = shift; $self->{config} = new LXR::Config("http://test/lxr", "./lxr.conf"); } sub tear_down { my $self = shift; $self->{config} = undef; } 1; --- NEW FILE: lxr.conf --- # -*- mode: perl -*- # Configuration file for Test suite # ( { # Global configuration # Path to glimpse executable. # Define this OR the swish-e variables depending which search engine you want to use. 'glimpsebin' => '/test/lxr/bin/glimpse', # Location of SWISH-E indexer binary 'swishindex' => '/test/lxr/bin/swish-e', # Location of SWISH-E search binary 'swishsearch' => '/test/lxr/bin/swish-e', # Path to Exuberant Ctags executable 'ectagsbin' => '/test/lxr/bin/ctags', # Place where lxr can write temporary files 'tmpdir' => '/tmp', # Location of the Generic.pm config file 'genericconf' => '../lib/LXR/Lang/generic.conf' }, { # Configuration for http://192.168.1.3/lxr. # baseurl is used to select configuration block. 'baseurl' => 'http://test/lxr', # Put your URL here 'virtroot' => '/lxr', # The bit after the / above 'variables' => { # Define typed variable "v". This is the list of versions to index. 'v' => {'name' => 'Version', # This can come from a file, a function or be explicitly # ennumerated. # From a file: 'range' => [ readfile('test-versions') ], # Explicitly: # 'range' => [qw(v1 v2 v3.1 v4 experimental)], # If files within a tree can have different versions, # e.g in a CVS tree, 'range' can be specified as a # function to call for each file: #'range' => sub { return # ($files->allreleases($LXR::Common::pathname), # $files->allrevisions($LXR::Common::pathname)) # }, # deferred function call. # The default version to display 'default' => '1.0.6'}, # Define typed variable "a". First value is default. 'a' => {'name' => 'Architecture', 'range' => [qw(i386 alpha arm m68k mips ppc sparc sparc64)]}, }, # These do funky things to paths in the system - you probably don't need them. 'maps' => { '/include/asm[^\/]*/' => '/include/asm-$a/', '/arch/[^\/]+/' => '/arch/$a/', }, # Templates used for headers and footers 'htmlhead' => 'html-head.html', 'htmltail' => 'html-tail.html', 'htmldir' => 'html-dir.html', 'htmlident' => 'html-ident.html', 'sourcehead' => 'html-head.html', 'sourcedirhead' => 'html-head.html', 'stylesheet' => 'lxr.css', # sourceroot - where to get the source files from # For ordinary directories, this specifies a directory which has each version as a # subdirectory e.g. # indexed-src/version1/... # indexed-src/version2/... # The names of the version directories must match the values for the Version # variable above. 'sourceroot' => '/home/malcolm/indexed-src', # Alternatively, this can specify a CVS repository by setting the value to "cvs:" # followed by the path to the repository. Note this must be file accessible - remote # server access does NOT work. # 'sourceroot' => 'cvs:/hom/karsk/a/CVSROOT/linux', # The name to display for this source tree 'sourcerootname' => 'Example', # The DBI identifier for the database to use # For mysql, the format is dbi:mysql:dbname=<name> # for Postgres, it is dbi:Pg:dbname=<name> # for Oracle, it is dbi:Oracle:host=localhost;sid=DEVMMS;port=1521 'dbname' => 'dbi:mysql:dbname=lxr', # If you need to specify the username or password for the database connection, # uncomment the following two lines # 'dbpass' => 'foo', # 'dbuser' => 'lxr', # For using glimpse, the directory to store the .glimpse files in is required 'glimpsedir' => '/path/to/glimpse/databases', # Location of swish-e index database files if using swish-e 'swishdir' => '/a/directory/here/', # where to look for include files inside the sourcetree. This is used to hyperlink # to included files. 'incprefix' => ['/include', '/include/linux'], # Which extensions to treat as images when browsing. If a file is an image, # it is displayed. 'graphicfile' => '(?i)\.(gif|jpg|jpeg|pjpg|pjpeg|xbm|png)$', #' # How to map files to languages # Note that the string for the key and the first entry in the # array MUST match 'filetype' => { # Format is # Language name, filepatten regexp, module to invoke, # (optional )tabwidth # Note that to have another language supported by Generic.pm, # you must ensure that: # a) exuberant ctags supports it # b) generic.conf is updated to specify information about the language # c) the name of the language given here matches the entry in generic.conf 'C' => ['C', '\.c$' #' , 'LXR::Lang::Generic', '8'], 'C++' => ['C++', '\.C$|((?i)\.c\+\+$|\.cc$|\.cpp$|\.cxx$|\.h$|\.hh$|\.hpp$|\.hxx$|\.h\+\+$)' #' , 'LXR::Lang::Generic', '8'], # Some languages are commented out until the relevant entries in generic.conf are made # The list here is the set supported by ctags 5.0.1 # ['Beta', '(?i)\.bet$' #' # , 'LXR::Lang::Generic'], # ['Cobol', '(?i)\.cob$' #' # , 'LXR::Lang::Generic'], # ['Eiffel', '(?i)\.e$' #' # , 'LXR::Lang::Generic'], # ['Fortran', '(?i)\.f$|\.for$|\.ftn$|\.f77$|\.f90$|\.f95$' #' # , 'LXR::Lang::Generic'], 'Java' => ['Java', '(?i)\.java$' #' , 'LXR::Lang::Java', '4'], # ['Lisp', '(?i)\.cl$|\.clisp$|\.el$|\.l$|\.lisp$|\.lsp$|\.ml$' #' # , 'LXR::Lang::Generic'], # No tabwidth specified here as an example 'Make' => ['Make', '(?i)\.mak$|makefile*' #' , 'LXR::Lang::Generic'], # ['Pascal', '(?i)\.p$|\.pas$' #' # , 'LXR::Lang::Generic'], 'Perl' => ['Perl', '(?i)\.pl$|\.pm$|\.perl$' #' , 'LXR::Lang::Generic', '4'], 'php' => ['php', '(?i)\.php$|\.php3$|\.phtml$' #' , 'LXR::Lang::Generic', '2'], 'Python' => ['Python', '(?i)\.py$|\.python$' #' , 'LXR::Lang::Generic', '4'], # ['rexx', '(?i)\.cmd$|\.rexx$|\.rx$' #' # , 'LXR::Lang::Generic'], # ['ruby', '(?i)\.rb$' #' # , 'LXR::Lang::Generic'], # ['scheme', '(?i)\.sch$|\.scheme$|\.scm$|\.sm$' #' # , 'LXR::Lang::Generic'], # ['shell', '(?i)\.sh$|\.bsh$|\.bash$|\.ksh$|\.zsh$' #' # , 'LXR::Lang::Generic'], # ['s-Lang', '(?i)\.sl$' #' # , 'LXR::Lang::Generic'], # ['tcl', '(?i)\.tcl$|\.wish$' #' # , 'LXR::Lang::Generic'], }, # Maps interpreter names to languages. The format is: # regexp => langname # regexp is matched against the part after #! on the first line of a file # langname must match one of the keys in filetype above. # # This mapping is only used if the filename doesn't match a pattern above, so # a shell script called shell.c will be recognised as a C file, not a shell file. 'interpreters' => { 'perl' => 'Perl', # 'bash' => 'shell', # 'csh' => 'shell', 'python' => 'Python', }, }) --- NEW FILE: test-versions --- 1.0.6 hi hippy wibble |