On 2 Aug 2001, Andreas Marcel Riechert wrote:

> In Thread [Re: [MacPerl] Progress Report + System Requirements]
> Chris Nandor <[EMAIL PROTECTED]> writes:
>  
> > BTW, please please please test as much as you can in the app, and with
> > Mac:: toolbox modules, and submit bug reports.  The app and the Mac::
> > modules are probably 90 percent of what is left.
> 
> Okay, I tested parts of Mac::Fonts.t (see script bellow).
> 
> [1] Results
> The script runs fine in the MrC and MCW Application 
> (alpha4). In MPW, MPW crashes with Error 3. Actually it 
> crashes on "use Mac::Fonts;". Adding "use Mac::Quickdraw" 
> doesn't change anything. 
>  
> [2] Test Script Fonts.t
> This test script allows testing without user interference. Because
> it is a pure "Mac::Fonts" test script some functions could not be
> tested (in a safe and/or meaningful way). As a reminder to the tester
> all non tested functions will printed out.
> 
> [3] Further Thoughts
> Maybe we should have two ".t" scripts/ script-folders  for the "Mac::" 
> modules. One should allow testing the functions (as much as possible)
> without user interference (aka automatically from the tests.cmd); the
> other ".t" files like the old "Mac::*.t" files (which are not in the 
> alpha4 distribution) will need manual testing (Some but not all GUI stuff
> needs manual testing). 
> 
> Any thoughts? remarks?

If you would like to follow the example of VMS one approach would be to
put the new test script off in the separate macos/ directory then have the
Mac specific Makefile copy it into :t:lib:Fonts.t before running the
tests.  In other words have the 'test' target depend on :t:lib:Fonts.t.
Oddly in recent bleedperl kits VMS has started running more unit tests
(about 26 k) that Unix does (Tru64 about 25k) even though VMS has to skip
many tests since they are unix specific and do not easily port to VMS.
The difference is the greater number of VMS specific tests for certain VMS
specific modules (e.g. VMS::Stdio and VMS::DCLSym which add extensions to
IO and the environment that are quite useful on VMS).

HTH.

BTW I hope to be able to finish a script that will make a copy of every
test in t/*/*.t with the C<@INC = '../lib';> assignments commented out
into a new ivp/t/*.t directory tree that will hopefully make for a
quasi-file-system-portable and zip-able version of perl's regression
tests.  An early alpha version of makeivp may appear as an attachment to
this email and I would appreciate hearing from anyone who can spot Mac OS
porting problems with it.  Thank you.


Peter Prymmer

#!./perl

BEGIN {
    require 5.004;
    # just the sort of thing we intend to get rid of:
    chdir '..' if !-d 'lib' and -d '..\lib';
    @INC = 'lib';
    $ENV{PERL5LIB} = 'lib';
}

use strict;
my ($Is_VMS, $Is_W32, $Is_OS2, $Is_Cygwin, $Is_NetWare); # platforms
my ($dostrip, $silent, $verbose, $nonono); # options
#use vars qw /$depth/;
$verbose = 1;
$nonono = 0;

BEGIN {
    $Is_VMS = $^O eq 'VMS';
    $Is_W32 = $^O eq 'MSWin32';
    $Is_OS2 = $^O eq 'os2';
    $Is_Cygwin = $^O eq 'cygwin';
    if ($Is_VMS) { eval 'use VMS::Filespec;' }
}

# my $scr_ext = ($Is_VMS ? '.Com' : $Is_W32 ? '.bat' : '');

use File::Find;
use File::Compare;
use File::Copy ();
use File::Path ();
use File::Spec::Functions qw(catdir catfile);
#use ExtUtils::Packlist;
#use Config;
#use subs qw(unlink link chmod);

# override the ones in the rest of the script
sub mkpath {
    File::Path::mkpath(@_) unless $nonono;
}
sub copy {
    my($src) = shift;
    my($dst) = shift;
    if ( compare($src,$dst) ) {
        File::Copy::copy($src,$dst) unless $nonono;
    }
}
# Copy a *.t file making sure to comment out any @INC assignments 
# (assumes slurping of *.t files is ok everywhere).
# Note that this will not catch the bad old practice of:
#     push(@INC,'../lib');  # <- but you aren't supposed to use this anyway.
# Note also that the following would be turned into a syntax error:
#     if ($^O eq 'MacOS') {
#         @INC = ':::lib:'; }
# Hence that would be better written to place the closing } on a separate line:
#     if ($^O eq 'MacOS') {
#    #     @INC = ':::lib:';  # the leading # won't incur the wrath of unmatched {}
#     }
sub ivp_copy {
    my($src) = shift;
    my($dst) = shift;

    open(SRC,"<$src") or warn "could not open ${src}: $!";
    my @src = (<SRC>);
    close(SRC);
    my $src_flat = join('',@src);
    my $file_altered = 0;
    # comment out simple @INC assignments:
    if ( $src_flat =~ s/^(\s*\@INC\s*=)/#$1/mg ) {
        $file_altered = 1;
    }
    # comment out simple $ENV{PERL5LIB} assignments:
    if ( $src_flat =~ s/^(\s*\$ENV\{PERL5LIB\}\s*=)/#$1/mg ) {
        $file_altered = 1;
    }

#    if ( ( !$file_altered && compare($src,$dst) ) && ! $nonono ) {
    if ( ! $nonono ) {
        open(DST,">$dst") or warn "could not open $dst for output: $!";
        print DST $src_flat;
        close(DST);
    }
}

my %ivp_test = ();
my %ivp_file = ();
my %ivp_path = ();

# Recurse through t/ tests and build hashes
find(sub
{
    if (-d $_) {
        # prepend 'ivp' to make dir tree copy
        my $dir_path = catdir('ivp',$File::Find::dir,$_);
        # remember directory
        $ivp_path{"$dir_path"} = 1;
    }
    else {
        # Not a directory
        my($path, $filename) = ($File::Find::dir,$_);

        # reconstitute canonical file path spec 
        my $file_path = catfile($path,$filename);

        # ivp dir name (using "/" - sic)
        my $ivp_path = catfile('ivp',$path,$filename);

        # remember it
        # If it is a test or harness or TestInit.pm
        # we need to scan it for @INC assignments, so stuff it into %ivp_test
        if ( $filename =~ m{\.t$} || 
             ( $path =~ /t$/ && $filename =~ m{^harness} ) ) { # on vms $filename is 
'harness.'
            $ivp_test{$ivp_path} = $file_path;
        }
        # other stuff can simply be copied over - stuff into %ivp_file
        else {
            $ivp_file{$ivp_path} = $file_path;
        }
    }
}, 't');

# make new "ivp/t" destination directory tree 
# (assumes no directory depth problem in adding one extra dir to a t/* type path)
for (sort keys %ivp_path) {
    print "mkpath $_\n" if $verbose;
    mkpath ( $_ ) unless $nonono;
}
print "-------------------\n" if $verbose;
# Use ivp_copy to take tests and harness over but comment out @INC assignments
# (assumes all files are slurpable).
for (sort keys %ivp_test) {
    print "ivp_copy $ivp_test{$_} -> $_\n" if $verbose;
    ivp_copy ( $ivp_test{$_} , $_ );
}
print "-------------------\n" if $verbose;
# Copy remaining files over
# (assumes File::Copy::copy()'s block reads are ok everywhere)
for (sort( keys %ivp_file)) {
    print "copy $ivp_file{$_} -> $_\n" if $verbose;
    copy( $ivp_file{$_}, $_ );
}
# make special psuedo MANIFEST so that harness does not complain:
my $file = catfile('ivp','MANIFEST');
print "creat $file\n" if $verbose;
if ( $nonono ) {
    exit;
}
else {
    open(MAN,">$file") or warn "could not open $file: $!";
    print MAN "blurfle\n";
    close(MAN);
}


Reply via email to