"Fossies" - the Fresh Open Source Software Archive

Member "Module-Build-0.4224/t/test_type.t" (30 May 2017, 1442 Bytes) of package /linux/privat/Module-Build-0.4224.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl -w
    2 
    3 BEGIN {
    4     if ($^O eq 'VMS') {
    5         print '1..0 # Child test output confuses harness';
    6         exit;
    7     }
    8 }
    9 
   10 use strict;
   11 use lib 't/lib';
   12 use MBTest tests => 7;
   13 
   14 blib_load('Module::Build');
   15 
   16 my $tmp = MBTest->tmpdir;
   17 
   18 use DistGen;
   19 
   20 my $dist = DistGen->new( dir => $tmp );
   21 
   22 
   23 $dist->add_file('t/special_ext.st', <<'---' );
   24 #!perl
   25 use Test::More tests => 2;
   26 ok(1, 'first test in special_ext');
   27 ok(1, 'second test in special_ext');
   28 ---
   29 
   30 $dist->regen;
   31 
   32 $dist->chdir_in;
   33 
   34 #########################
   35 
   36 # Here we make sure we can define an action that will test a particular type
   37 $::x = 0;
   38 my $mb = Module::Build->subclass(
   39     code => q#
   40         sub ACTION_testspecial {
   41             $::x++;
   42             shift->generic_test(type => 'special');
   43         }
   44     #
   45 )->new(
   46     module_name => $dist->name,
   47     test_types  => { special => '.st' }
   48 );
   49 
   50 ok $mb;
   51 
   52 $mb->dispatch('testspecial');
   53 is($::x, 1, "called once");
   54 
   55 
   56 $mb->add_to_cleanup('save_out');
   57 # Use uc() so we don't confuse the current test output
   58 my $verbose_output = uc(stdout_of(
   59     sub {$mb->dispatch('testspecial', verbose => 1)}
   60 ));
   61 
   62 like($verbose_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m);
   63 like($verbose_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m);
   64 
   65 is( $::x, 2, "called again");
   66 
   67 my $output = uc(stdout_of(
   68     sub {$mb->dispatch('testspecial', verbose => 0)}
   69 ));
   70 like($output, qr/\.\. ?OK/);
   71 
   72 is($::x, 3, "called a third time");
   73 
   74 # vim:ts=4:sw=4:et:sta