ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/test/twigmaker
Revision: 1.1
Committed: Tue Sep 12 13:00:28 2000 UTC (24 years, 8 months ago) by williamc
Branch: MAIN
Log Message:
add basic test infrastructure

File Contents

# User Rev Content
1 williamc 1.1 #
2     # twigmaker - a substitue compiler for testing make rules
3     # use :
4     # perl twigmaker outfile infiles
5     #
6    
7     package BuildSystem::test::twigmaker;
8     use FileHandle;
9    
10     $self={};
11     bless $self;
12    
13     $self->maketwig(@ARGV);
14    
15     sub new {
16     my $class=shift;
17     my $self={};
18     bless $self, $class;
19     my $file=shift;
20     $self->_loadtwig($file);
21     return $self;
22     }
23    
24     sub maketwig {
25     my $self=shift;
26     my $out=shift;
27    
28     undef $self->{dates};
29     # -- open file for output
30     my $fh=FileHandle->new();
31     $fh->open(">".$out) || die "Unable to open $out $!";
32    
33     # -- compile a list of all files with their datestamps
34     foreach $file ( @_ ) {
35     if ( -f $file ) {
36     $date=(stat($file))[9];
37     }
38     else {
39     $date="not_file";
40     }
41     print $fh $file." ".$date."\n";
42     $self->{dates}{$file}=$date;
43     }
44    
45     undef $fh;
46     }
47    
48     sub filedate {
49     my $self=shift;
50     my $file=shift;
51    
52     return $self->{dates}{$file};
53     }
54    
55     sub _loadtwig {
56     my $self=shift;
57     my $infile=shift;
58    
59     my $fh=FileHandle->new();
60     $fh->open("<".$infile) || die "Unable to open $infile $!";
61     while (<$fh>) {
62     chomp;
63     ($file,$date)=split / /;
64     $self->{dates}{$file}=$date;
65     }
66     undef $fh;
67     }