File Coverage

blib/lib/TaskForest/Release.pm
Criterion Covered Total %
statement 19 38 50.0
branch 0 16 0.0
condition 0 3 0.0
subroutine 7 9 77.7
pod 1 2 50.0
total 27 68 39.7


line stmt bran cond sub pod time code
1             ################################################################################
2             #
3             # $Id: Release.pm 269 2010-02-12 04:43:10Z aijaz $
4             #
5             ################################################################################
6              
7             =head1 NAME
8              
9             TaskForest::Release - Functions related to releasing all dependencies of a job.
10              
11             =head1 SYNOPSIS
12              
13             use TaskForest::Release;
14              
15             &TaskForest::Release::release($family_name, $job_name, $log_dir, $cascade, $dependents_only, $family_dir)
16              
17             =head1 DOCUMENTATION
18              
19             If you're just looking to use the taskforest application, the only
20             documentation you need to read is that for TaskForest. You can do this
21             either of the two ways:
22              
23             perldoc TaskForest
24              
25             OR
26              
27             man TaskForest
28              
29             =head1 DESCRIPTION
30              
31             This is a simple package that provides a location for the release
32             function, so that it can be used in the test scripts as well.
33              
34             =head1 METHODS
35              
36             =cut
37              
38             package TaskForest::Release;
39 9     9   8039 use strict;
  9         18  
  9         303  
40 9     9   45 use warnings;
  9         19  
  9         222  
41 9     9   45 use Carp;
  9         17  
  9         1205  
42 9     9   52 use File::Copy;
  9         15  
  9         452  
43 9     9   3300 use TaskForest::Family;
  9         23  
  9         562  
44              
45             BEGIN {
46 9     9   77 use vars qw($VERSION);
  9         16  
  9         389  
47 9     9   3870 $VERSION = '1.34';
48             }
49              
50              
51             # ------------------------------------------------------------------------------
52             =pod
53              
54             =over 4
55              
56             =item release()
57              
58             Usage : release($family_name, $job_name, $log_dir)
59             Purpose : Release the specified job as success or failure. This job
60             creates a special file that's used to override the logic that
61             determines whether or not a job is ready to run.
62             Returns : Nothing
63             Arguments : $family_name - the family name
64             $job_name - the job name
65             $log_dir - the root log directory
66             Throws : Nothing
67              
68             =back
69              
70             =cut
71              
72             # ------------------------------------------------------------------------------
73             sub release {
74 0     0 1   my ($family_name, $job_name, $log_dir, $family_dir, $quiet) = @_;
75              
76 0           my $jobs;
77              
78              
79 0 0         $ENV{TF_JOB_DIR} = 'unnecessary' unless $ENV{TF_JOB_DIR};
80 0 0         $ENV{TF_RUN_WRAPPER} = 'unnecessary' unless $ENV{TF_RUN_WRAPPER};
81 0 0         $ENV{TF_LOG_DIR} = $log_dir unless $ENV{TF_LOG_DIR};
82 0 0         $ENV{TF_FAMILY_DIR} = $family_dir unless $ENV{TF_FAMILY_DIR};
83            
84 0           my $family = TaskForest::Family->new(name => $family_name);
85 0           $family->getCurrent();
86            
87 0 0 0       if ($family->{jobs}->{$job_name} && ($family->{jobs}->{$job_name}->{status} eq 'Waiting')) {
88 0           releaseHelp($family_name, $job_name, $log_dir, $quiet);
89             }
90             else {
91 0           die "Cannot release job ${family_name}::$job_name since it is not in the 'Waiting' or 'Hold' state - it's in the ".
92             $family->{jobs}->{$job_name}->{status}.
93             " state.\n";
94             }
95            
96            
97             }
98              
99              
100             sub releaseHelp {
101 0     0 0   my ($family_name, $job_name, $log_dir, $quiet) = @_;
102              
103 0 0         print "Releasing all dependencies on job $family_name","::","$job_name\n" unless $quiet;
104            
105 0           my $release_file = "$log_dir/$family_name.$job_name.release";
106            
107              
108 0 0         if (-e $release_file) {
109 0           carp("$family_name.$job_name is already released. Not doing anything.");
110             }
111             else {
112 0 0         open (F, ">$release_file") || croak "Cannot touch file $release_file";
113            
114 0           print F "\n";;
115            
116 0           close F;
117             }
118            
119             }
120              
121             1;