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

File Contents

# User Rev Content
1 williamc 1.1 #
2     # BuildSetup.pm test suite
3     #
4    
5     package BuildSystem::test::test_Build;
6     require 5.001;
7     use BuildSystem::Build;
8     use Configuration::ConfigArea;
9    
10     @ISA=qw(Utilities::TestClass); #methods both from the test class
11    
12     sub init {
13     my $self=shift;
14     $self->{testfile}=$self->datadir()."/BuildFileDoc";
15     $self->{arch}="testarch";
16     $ENV{SCRAM_ARCH}=$self->{arch};
17     $ENV{INTwork}="tmp/".$ENV{SCRAM_ARCH};
18     $ENV{TOOL_HOME}=$ENV{SCRAM_HOME}."/src";
19    
20     $self->{path}=$self->{arch}."/src";
21     # -- make a release area
22     $self->{configareadir}="TestConfiguration";
23     $self->{testareadir}=$self->temparea()."/BuildSetup";
24     $self->{testarea}=Configuration::ConfigArea->new();
25     $self->{testarea}->name("BuildSetup");
26     $self->{testarea}->version("test");
27     $self->{testarea}->configurationdir($self->{configareadir});
28     $self->{testarea}->setup($self->{testareadir});
29    
30     AddDir::copydir($self->{datadir}."/testsrcs/src",
31     $self->{testarea}->location()."/src");
32    
33    
34     # -- Build System Test Configuration
35     $self->{configarea}=$self->{testarea}->location()."/"
36     .$self->{testarea}->configurationdir();
37     AddDir::copydir($self->{datadir}."/".$self->{configareadir}
38     ,$self->{configarea});
39    
40    
41     # -- make a dummy developer area
42     $self->{testdevareadir}=$self->temparea()."/BuildDevArea";
43     $self->{testdevarea}=$self->{testarea}->satellite(
44     $self->{testdevareadir});
45     $self->{devconfigarea}=$self->{testdevarea}->location()."/"
46     .$self->{testdevarea}->configurationdir();
47     AddDir::copydir($self->{datadir}."/".$self->{configareadir}
48     ,$self->{devconfigarea});
49     print "Initiatisation Complete\n";
50    
51     }
52    
53     sub test {
54     my $self=shift;
55     $self->newtest("Initiation test - Release Area");
56     $self->newobject($self->{testarea});
57     $self->testinterface("verbosity",1);
58    
59     # -- perform all basic build operations
60     $self->_basicbuildoperations($self->{testareadir});
61    
62     # -- specific release behaviour tests
63    
64     $self->newtest("Initiation test - Development Area");
65     $self->newobject($self->{testdevarea});
66     $self->testinterface("verbosity",1);
67    
68     $self->_basicbuildoperations($self->{testdevareadir});
69    
70     $self->newtest("Change local configuration");
71     $self->testfail("not implemented");
72    
73     $self->newtest("Add new src files");
74     $self->testfail("not implemented");
75     }
76    
77     # -- support routines
78    
79     sub _basicbuildoperations {
80     my $self=shift;
81     my $topdir=shift;
82     my $report;
83    
84     # -- build from invalid directory
85     $self->newtest("build from invalid directory");
86     $report=$self->testinterface("build",$self->{configurationareadir});
87     $self->testswitch($report->pass(),"Build Returned OK",
88     "Build Returned Fail as expected");
89    
90     # -- default build from twig in src tree
91     $self->newtest("default build from twig - configuration setup");
92     my $twig="src/sub/twig";
93     $report=$self->testinterface("build",$twig);
94     $self->_buildOKtest($report);
95     if ( ! $self->_twigupdated("twig1") ) {
96     $self->testfail("Failed to build twig1");
97     }
98     else {
99     $self->_analysetwig("twig1");
100     }
101     if ( ! $self->_twigupdated("twig2") ) {
102     $self->testfail("Failed to build twig2");
103     }
104     else {
105     $self->_analysetwig("twig2");
106     }
107    
108     # -- specific build from twig
109     $self->newtest("alternative build from twig");
110     $report=$self->testinterface("build",$twig,"alternative");
111     $self->_buildOKtest($report);
112    
113     # -- remove some source files
114     $self->newtest("partial src file removal");
115     $self->testfail("not implemented");
116    
117     # -- date change on src files
118     $self->newtest("date change on src files");
119     $self->testfail("not implemented");
120    
121     # -- build from sub - recursive
122     $self->newtest("build from sublevel");
123     $self->testfail("not implemented");
124     }
125    
126     sub _buildOKtest {
127     my $self=shift;
128     my $report=shift;
129    
130     my @errors=$report->error();
131     $self->testswitch($report->pass(),"Build Returned OK",
132     "Build Returned Fail (@errors)");
133     }
134    
135     sub _twigupdated {
136     my $self=shift;
137     my $name=shift;
138    
139     my $updated=0;
140     if ( ! exists $twigfile ) {
141     $self->testfail("$twigfile not created - test failed");
142     }
143     else {
144     # -- get twig datestamp
145     my $twigdatestamp=(stat($file))[9];
146     if ( defined $self->{twigs}{$name} ) {
147     if ($self->{twigs}{$name} ne $twigdatestamp ) {
148     $updated=1;
149     }
150     }
151     else {
152     # twig must be new
153     $updated=1;
154     }
155     $self->{twigs}{$name}=$twigdatestamp;
156     }
157     return $update;
158     }
159    
160     #
161     # expects an array of array pairs
162     # ((file,"update"),(file,"no-update")
163     sub _ananlysetwigdates {
164     my $self=shift;
165    
166     my $twigfile=shift;
167     my $twig=BuildSystem::test::twigmaker->new($twigfile);
168    
169     # -- check input dates
170     foreach $file ( @_ ) {
171     # -- do we want it updated
172     if ( $file[1]=~/^update/i ) {
173     if ( ( defined $self->{twigfiles}{$file[0]} ) &&
174     ( $twig->filedate($file[0]) eq $self->{twigfiles}{$file[0]} )) {
175     $self->testfail($file[0]." not updated - test failed");
176     }
177     $self->{twigfiles}{$file[0]}=$twig->filedate($file[0]);
178     }
179     else {
180     if ( ( ! defined $self->{twigfiles}{$file[0]} ) ||
181     ( $twig->filedate($file[0]) ne $self->{twigfiles}{$file[0]} )) {
182     $self->testfail($file[0]." updated - test failed");
183     }
184     }
185     $self->{twigfiles}{$file[0]}=$twig->filedate($file[0]);
186     }
187     }
188    
189     # === dummy routines