+ $log->log($_) for @output;
+
+ # Need to remove baselines from streams first using rebase (Devstream)
+ $log->msg('Rebasing ' . $test_devstream->name . ' to remove baseline');
+
+ $status += RebaseStream(
+ $test_devstream,
+ ' -dbaseline ' . $test_baseline->name . '@' . $test_baseline->pvob->tag .
+ ' -view ' . $test_devview->name . ' -complete',
+ );
+
+ # Change intstream to not have a recommended baseline
+ $log->msg('Changing ' . $test_intstream->name . ' to remove recommended baseline');
+
+ ($rc, @output) = $test_intstream->nrecommended;
+
+ $status += $rc;
+
+ $log->log($_) for @output;
+
+ $status += DestroyView($test_devview);
+
+ $log->msg('Removing ' . $test_baseline->name);
+
+ ($rc, @output) = $test_baseline->remove;
+
+ $status += $rc;
+
+ $log->log($_) for @output;
+
+ $log->msg('Rebasing ' . $test_intstream->name . ' to remove INITIAL baseline');
+
+ $status += RebaseStream(
+ $test_intstream,
+ ' -dbaseline tc.component_INITIAL' . '@' . $test_intstream->pvob->tag .
+ ' -view ' . $test_intview->name . ' -complete',
+ );
+
+ $log->msg('Removing ' . $test_component->name . ' from ' . $test_project->name);
+
+ ($rc, @output) = $test_project->change(
+ '-dmodcomp ' . $test_component->name . '@' . $test_project->pvob->tag
+ );
+
+ $status += $rc;
+
+ $log->log($_) for @output;
+
+ $log->msg('Removing ' . $test_component->name);
+
+ ($rc, @output) = $test_component->remove;
+
+ $status += $rc;
+
+ $log->log($_) for @output;
+
+ $status += DestroyView($test_intview);
+
+ $log->msg('Removing '. $test_devstream->name);
+
+ ($rc, @output) = $test_devstream->remove;
+
+ $status += $rc;
+
+ $log->log($_) for @output;
+
+ $log->msg('Removing ' . $test_intstream->name);
+
+ ($rc, @output) = $test_intstream->remove;
+
+ $status += $rc;
+
+ $log->log($_) for @output;
+
+ $log->msg('Removing ' . $test_project->name);
+
+ ($rc, @output) = $test_project->remove;
+
+ $status += $rc;
+
+ $log->log($_) for @output;
+
+ $log->msg('Removing ' . $test_folder->name);
+
+ ($rc, @output) = $test_folder->remove;
+
+ $status += $rc;
+
+ $log->log($_) for @output;
+
+ $log->msg('Removing ' . $test_pvob->name);
+
+ ($rc, @output) = DestroyVob($test_pvob);
+
+ $log->log($_) for @output;
+
+ return $status;
+} # CleanupUCM
+
+sub SetupTest($$) {
+ my ($vob_tag, $view_tag) = @_;
+
+ my ($status, @output);
+
+ $log->msg('Setup test environment');
+
+ my $view = Clearcase::View->new($view_tag);
+
+ if ($view->exists) {
+ $log->msg('Removing old view ' . $view_tag);
+
+ ($status, @output) = $view->remove;
+
+ $log->err('Unable to remove old view ' . $view->tag, $status) if $status;
+ } # if
+
+ ($status, $test_view) = CreateView($view_tag);
+
+ return $status if $status != 0;
+
+ $status = $test_view->start;
+
+ my $vob = Clearcase::Vob->new($vob_tag);
+
+ if ($vob->exists) {
+ $log->msg('Removing old vob ' . $vob_tag);
+
+ ($status, @output) = DestroyVob($vob);
+
+ $log->err('Unable to remove old vob '. $vob->tag, $status) if $status;
+ } # if
+
+ ($status, $test_vob) = CreateVob($vob_tag);
+
+ return $status if $status != 0;
+
+ $status = MountVob($test_vob);
+
+ return $status if $status != 0;
+
+ my $dir = $Clearcase::VIEWTAG_PREFIX . '/' . $test_view->tag . $test_vob->tag;
+
+ chdir $dir
+ or $log->err("Unable to chdir to $dir", ++$status);
+
+ ($status, @output) = $Clearcase::CC->execute("cd $dir");
+
+ if ($status != 0) {
+ $log->log($_) for @output;
+ } # if
+
+ return $status;
+} # SetupTest
+
+sub SetupUCMTest() {
+ my $status;
+
+ $log->msg("Creating UCM Pvob $Clearcase::VOBTAG_PREFIX/tc.pvob");
+
+ ($status, $test_pvob) = CreatePvob("$Clearcase::VOBTAG_PREFIX/tc.pvob");
+
+ return $status;
+} # SetupUCMTest
+
+sub CreateUCMProject() {
+ # Get the root folder to put this project into (may create folders later)
+ $test_folder = Clearcase::UCM::Folder->new('tc.folder', $test_pvob);
+
+ $test_project = Clearcase::UCM::Project->new('tc.project', $test_folder, $test_pvob);
+
+ $test_project->remove if $test_project->exists;
+
+ $log->msg('Creating UCM Project tc.project');
+
+ my ($status, @output) = $test_project->create;
+
+ $log->log($_) for @output;
+
+ return $status;
+} # CreateUCMProject
+
+sub CreateUCMIntStream() {
+ $test_intstream = Clearcase::UCM::Stream->new('tc.intstream', $test_pvob);
+
+ $log->msg('Creating UCM Stream tc.intstream');
+
+ my ($status, @output) = $test_intstream->create($test_project, '-integration');
+
+ $log->log($_) for @output;
+
+ return $status;
+} # CreateUCMIntStream
+
+sub CreateUCMDevStream() {
+ $test_devstream = Clearcase::UCM::Stream->new('tc.devstream', $test_pvob);
+
+ $log->msg('Creating UCM Stream tc.devstream');
+
+ my ($status, @output) = $test_devstream->create($test_project);
+
+ $log->log($_) for @output;
+
+ return $status;
+} # CreateUCMDevStream
+
+sub CreateUCMComponent() {
+ $test_component = Clearcase::UCM::Component->new('tc.component', $test_pvob);
+
+ $log->msg('Creating UCM Component tc.component');
+
+ my ($status, @output) = $test_component->create(
+ "$Clearcase::VIEWTAG_PREFIX/" . $test_intview->tag . $test_vob->tag
+ );
+
+ $log->log($_) for @output;
+
+ return $status;
+} # CreateUCMComponent
+
+sub AddModifiableComponent() {
+ my ($status, @output) = $Clearcase::CC->execute(
+ 'chproj -nc -amodcomp ' . $test_component->name . '@' . $test_pvob->tag .
+ ' ' . $test_project->name . '@' . $test_pvob->tag
+ );
+
+ $log->log($_) for @output;
+
+ return $status;
+} # AddModifiableCOmponent
+
+sub CreateUCMIntView() {
+ $log->msg("Creating UCM Int View tc.intview");
+
+ $test_intview = Clearcase::View->new('tc.intview');
+
+ my ($status, @output) = $test_intview->create(
+ $opts{viewhost}, "$opts{viewstore}/tc.intview.vws",
+ '-stream ' . $test_intstream->name . '@' . $test_pvob->tag
+ );
+
+ $log->log($_) for @output;
+
+ $test_intview->start unless $status;
+
+ return $status;
+} # CreateUCMIntView
+
+sub CreateUCMDevView() {
+ $log->msg("Creating UCM Dev View tc.devview");
+
+ $test_devview = Clearcase::View->new('tc.devview');
+
+ my ($status, @output) = $test_devview->create(
+ $opts{viewhost}, "$opts{viewstore}/tc.devview.vws",
+ '-stream ' . $test_devstream->name . '@' . $test_pvob->tag
+ );
+
+ $log->log($_) for @output;
+
+ $test_devview->start unless $status;
+
+ return $status;
+} # CreateUCMDevView
+
+sub CreateUCMBaseline() {
+ $test_baseline = Clearcase::UCM::Baseline->new('tc.baseline', $test_pvob);
+
+ $log->msg('Creating UCM Baseline tc.baseline');
+
+ my ($status, @output) = $test_baseline->create($test_intview, undef, '-identical');
+
+ $log->log($_) for @output;
+
+ return $status;
+} # CreateUCMBaseline
+
+sub CreateUCMActivity() {
+ $test_activity = Clearcase::UCM::Activity->new('tc.activity', $test_pvob);
+
+ $log->msg('Creating UCM Activity tc.activity');
+
+ my ($status, @output) = $test_activity->create($test_devstream, 'A UCM Test Activity');
+
+ $log->log($_) for @output;
+
+ return $status;
+} # CreateUCMActivity
+
+sub RebaseStream($$) {
+ my ($stream, $opts) = @_;
+
+ my ($status, @output) = $stream->rebase($opts);
+
+ $log->log($_) for @output;
+
+ return $status;
+} # RebaseStream
+
+sub RecommendBaseline($$) {
+ my ($stream, $baseline) = @_;
+
+ my ($status, @output) = $stream->recommend($baseline);
+
+ $log->log($_) for @output;
+
+ return $status;
+} # RecommentBaseline
+
+sub RunUCMTests() {
+ my $status = 0;
+
+ $log->msg("$script: Start UCM Clearcase Tests");
+
+ $status += CreateUCMProject;
+ $status += CreateUCMIntStream;
+ $status += CreateUCMDevStream;
+ $status += CreateUCMIntView;
+ $status += CreateUCMDevView;
+ $status += CreateUCMComponent;
+ $status += AddModifiableComponent;
+ $status += RebaseStream($test_intstream, '-baseline tc.component_INITIAL -complete');
+ $status += RecommendBaseline($test_intstream, 'tc.component_INITIAL');
+ $status += CreateUCMBaseline;
+ $status += RebaseStream($test_devstream, '-baseline tc.baseline -complete');
+ $status += RecommendBaseline($test_devstream, 'tc.baseline');
+ $status += CreateUCMActivity;
+
+ $log->msg("$script: End UCM Clearcase Tests");
+
+ return $status;
+} # RunUCMTests
+
+## Main
+my $startTime = time;
+my $conf_file = "$FindBin::Bin/$script.conf";
+my $status = 0;
+
+$opts{base} = 1;
+$opts{clean} = 1;
+
+GetOptions(
+ \%opts,
+ 'verbose' => sub { set_verbose },
+ 'debug' => sub { set_debug },
+ 'usage' => sub { Usage },
+ 'config=s',
+ 'base!',
+ 'ucm!',
+ 'clean!',
+) or Usage;
+
+# Read the config file
+if (-f $conf_file) {
+ %default_opts = GetConfig $conf_file;
+} else {
+ $log->err("Unable to find config file $conf_file", 1);
+} # if
+
+# Overlay default opts if not specified
+for (keys %default_opts) {
+ $opts{$_} = $default_opts{$_} if !$opts{$_};
+} # for
+
+$log->msg("$script: Start");
+
+LogOpts;
+
+# Since we are creating private vobs (to avoid complications with having to
+# know and code the registry password when making public vobs), we'll simply
+# change $Clearcase::VOBTAG_PREFIX
+$Clearcase::VOBTAG_PREFIX = $ENV{TMP} || '/tmp';
+
+if ($opts{base}) {
+ $status = SetupTest "$Clearcase::VOBTAG_PREFIX/tc.vob", 'tc.view';
+
+ if ($status == 0) {
+ $status += RunTests;
+ } else {
+ $log->err('Tests not run. Failure occurred in SetupTest - check logfile');
+ } # if
+
+ # Note if we are doing UCM tests then we need the view and vob here...
+ $status += Cleanup($test_view, $test_vob) if $opts{clean} and !$opts{ucm};
+
+ if ($status != 0) {
+ $log->err("$script: Failed (Base Clearcase)");
+ } else {
+ $log->msg("$script: Passed (Base Clearcase)");
+ } # if
+} # if
+
+if ($opts{ucm}) {
+ $status = SetupUCMTest;
+
+ if ($status == 0) {
+ $status += RunUCMTests;
+ } else {
+ $log->err('UCM Tests not run. Failure occurred in SetupUCMTest - check logfile');
+ } # if
+
+ if ($opts{clean}) {
+ $status += CleanupUCM;
+ $status += Cleanup($test_view, $test_vob);
+ } # if
+
+ if ($status != 0) {
+ $log->err("$script: Failed (UCM Clearcase)");
+ } else {
+ $log->msg("$script: Passed (UCM Clearcase)");
+ } # if
+} # if
+
+display_duration $startTime, $log;
+
+$log->msg("$script: End");
+
+exit $status;
+
+=pod
+
+=head1 CONFIGURATION AND ENVIRONMENT
+
+DEBUG: If set then $debug is set to this level.
+
+VERBOSE: If set then $verbose is set to this level.
+
+TRACE: If set then $trace is set to this level.
+
+=head1 DEPENDENCIES
+
+=head2 Perl Modules
+
+L<Cwd>
+
+L<FindBin>
+
+L<Getopt::Long|Getopt::Long>
+
+L<Term::ANSIColor|Term::ANSIColor>