diff options
Diffstat (limited to 'NetWare/t/NWScripts.pl')
-rw-r--r-- | NetWare/t/NWScripts.pl | 199 |
1 files changed, 145 insertions, 54 deletions
diff --git a/NetWare/t/NWScripts.pl b/NetWare/t/NWScripts.pl index 36ca8ecb25..dc43ddef22 100644 --- a/NetWare/t/NWScripts.pl +++ b/NetWare/t/NWScripts.pl @@ -9,99 +9,188 @@ use File::Copy; chdir '/perl/scripts/'; $DirName = "t"; - # These scripts have problems (either abend or hang) as of now (11 May 2001). # So, they are commented out in the corresponding auto scripts, io.pl and lib.pl -@ScriptsNotUsed = ("t/io/argv.t", "t/io/openpid.t", "t/lib/filehand.t"); +@ScriptsNotUsed = ("t/io/argv.t", "t/io/openpid.t", "t/lib/filehandle.t"); +opendir(DIR, $DirName); +@Dirs = readdir(DIR); +close(DIR); +foreach $DirItem(@Dirs) +{ + $DirItem1 = $DirName."/".$DirItem; + push @DirNames, $DirItem1; # All items under $DirName folder is copied into an array. -print "Generating t/auto.pl ...\n\n\n"; + if(-d $DirItem1) + { # If an item is a folder, then open it further. -open(FHWA, "> t/auto.pl") or die "Unable to open the file, t/auto.pl for writing.\n"; -seek(FHWA, 0 ,0); -flock(FHWA, LOCK_EX); # Lock the file for safety purposes. + # Intemediary automated script like base.pl, lib.pl, cmd.pl etc. + $IntAutoScript = "t/".$DirItem.".pl"; -$version = sprintf("%vd",$^V); -print FHWA "\n\nprint \"Automated Unit Testing of Perl$version\\n\\n\\n\"\;\n\n\n"; + # Open once in write mode since later files are opened in append mode, + # and if there already exists a file with the same name, all further opens + # will append to that file!! + open(FHW, "> $IntAutoScript") or die "Unable to open the file, $IntAutoScript for writing.\n"; + seek(FHW, 0, 0); # seek to the beginning of the file. + close FHW; # close the file. + } +} -opendir(DIR, $DirName) or die "Unable to open the directory, $DirName for reading.\n"; -@Dirs = readdir(DIR); +print "Generating t/nwauto.pl ...\n\n\n"; + +open(FHWA, "> t/nwauto.pl") or die "Unable to open the file, t/nwauto.pl for writing.\n"; +seek(FHWA, 0, 0); # seek to the beginning of the file. +flock(FHWA, LOCK_EX); # Lock the file for safety purposes. + +$version = sprintf("%vd",$^V); +print FHWA "\n\nprint \"Automated Unit Testing of Perl$version for NetWare\\n\\n\\n\"\;\n\n\n"; -foreach $DirItem(@Dirs) -{ - $DirItem = $DirName."/".$DirItem; - push @DirNames, $DirItem; # All items under $DirName directory is copied into an array. -} foreach $FileName(@DirNames) { + $index = 0; if(-d $FileName) - { # If an item is a directory, then open it further. + { # If an item is a folder, then open it further. - opendir(SUBDIR, $FileName) or die "Unable to open the directory, $FileName for reading.\n"; - @SubDirs = readdir(SUBDIR); - close(SUBDIR); - - - $base = basename($FileName); # Get the base name - $dir = dirname($FileName); # Get the directory name - ($base, $dir, $ext) = fileparse($FileName, '\..*'); # Get the extension of the file passed. - - # Intemediary automated script like base.pl, lib.pl, cmd.pl etc. - $IntAutoScript = "t/".$base.".pl"; + $dir = dirname($FileName); # Get the folder name + foreach $DirItem1(@Dirs) + { + $DirItem2 = $DirItem1; + if($FileName =~ m/$DirItem2/) + { + $DirItem = $DirItem1; - # Write into auto.pl - print FHWA "print \`perl $IntAutoScript\`\;\n"; - print FHWA "print \"\\n\\n\\n\"\;\n\n"; + # Intemediary automated script like base.pl, lib.pl, cmd.pl etc. + $IntAutoScript = "t/".$DirItem.".pl"; + } + } - - print "Generating $IntAutoScript...\n"; # Write into the intermediary auto script. - open(FHW, "> $IntAutoScript") or die "Unable to open the file, $IntAutoScript for writing.\n"; - seek(FHW, 0 ,0); + open(FHW, ">> $IntAutoScript") or die "Unable to open the file, $IntAutoScript for appending.\n"; + seek(FHW, 0, 2); # seek to the end of the file. flock(FHW, LOCK_EX); # Lock the file for safety purposes. - print FHW "\n\nprint \"Testing $base directory:\\n\\n\\n\"\;\n\n\n"; - + $pos = tell(FHW); + if($pos <= 0) + { + print "Generating $IntAutoScript...\n"; + print FHW "\n\nprint \"Testing $DirItem folder:\\n\\n\\n\"\;\n\n\n"; + } + opendir(SUBDIR, $FileName); + @SubDirs = readdir(SUBDIR); + close(SUBDIR); foreach $SubFileName(@SubDirs) { + $SubFileName = $FileName."/".$SubFileName; if(-d $SubFileName) { - $SubFileName = $FileName."/".$SubFileName; - push @DirNames, $SubFileName; # If sub-directory, push it into the array. + push @DirNames, $SubFileName; # If sub-folder, push it into the array. } else { - $SubFileName = $FileName."/".$SubFileName; &Process_File($SubFileName); # If file, process it. } - } - # Write into the intermediary auto script. - print FHW "\nprint \"Testing of $base directory done!\\n\\n\"\;\n\n"; + $index++; + } flock(FHW, LOCK_UN); # unlock the file. close FHW; # close the file. - print "$IntAutoScript Done!\n\n"; + + if($index <= 0) + { + # The folder is empty and delete the corresponding '.pl' file. + unlink($IntAutoScript); + print "Deleted $IntAutoScript since it corresponded to an empty folder.\n"; + } + else + { + if($pos <= 0) + { # This logic to make sure that it is written only once. + # Only if something is written into the intermediary auto script, + # only then make an entry of the intermediary auto script in nwauto.pl + print FHWA "print \`perl $IntAutoScript\`\;\n"; + print FHWA "print \"\\n\\n\\n\"\;\n\n"; + } + } + } + else + { + if(-f $FileName) + { + $dir = dirname($FileName); # Get the folder name + $base = basename($FileName); # Get the base name + ($base, $dir, $ext) = fileparse($FileName, '\..*'); # Get the extension of the file passed. + + # Do the processing only if the file has '.t' extension. + if($ext eq '.t') + { + print FHWA "print \`perl $FileName\`\;\n"; + print FHWA "print \"\\n\\n\\n\"\;\n\n"; + } + } } } + +## Below adds the ending comments into all the intermediary auto scripts: + +opendir(DIR, $DirName); +@Dirs = readdir(DIR); close(DIR); +foreach $DirItem(@Dirs) +{ + $index = 0; + + $FileName = $DirName."/".$DirItem; + if(-d $FileName) + { # If an item is a folder, then open it further. + opendir(SUBDIR, $FileName); + @SubDirs = readdir(SUBDIR); + close(SUBDIR); -# Write into auto.pl -print FHWA "\nprint \"Automated Unit Testing of Perl$version done!\\n\\n\"\;\n\n"; + # To not to write into the file if the corresponding folder was empty. + foreach $SubDir(@SubDirs) + { + $index++; + } + + if($index > 0) + { + # The folder not empty. + + # Intemediary automated script like base.pl, lib.pl, cmd.pl etc. + $IntAutoScript = "t/".$DirItem.".pl"; + + # Write into the intermediary auto script. + open(FHW, ">> $IntAutoScript") or die "Unable to open the file, $IntAutoScript for appending.\n"; + seek(FHW, 0, 2); # seek to the end of the file. + flock(FHW, LOCK_EX); # Lock the file for safety purposes. + + # Write into the intermediary auto script. + print FHW "\nprint \"Testing of $DirItem folder done!\\n\\n\"\;\n\n"; + + flock(FHW, LOCK_UN); # unlock the file. + close FHW; # close the file. + } + } +} + + +# Write into nwauto.pl +print FHWA "\nprint \"Automated Unit Testing of Perl$version for NetWare done!\\n\\n\"\;\n\n"; flock(FHWA, LOCK_UN); # unlock the file. close FHWA; # close the file. -print "\nt/auto.pl Done!\n\n"; +print "\n\nGeneration of t/nwauto.pl Done!\n\n"; +print "\nGeneration of automated scripts for NetWare DONE!\n"; -print "\nGeneration of automated scripts for NetWare DONE!\n"; @@ -112,23 +201,25 @@ sub Process_File local($Script) = 0; local($HeadCut) = 0; - - $base1 = basename($FileToProcess); # Get the base name - $dir1 = dirname($FileToProcess); # Get the directory name - ($base1, $dir1, $ext1) = fileparse($FileToProcess, '\..*'); # Get the extension of the file passed. - + ## For example: ## If the value of $FileToProcess is '/perl/scripts/t/pragma/warnings.t', then ## $dir1 = '/perl/scripts/t/pragma/' ## $base1 = 'warnings' ## $ext1 = '.t' - + $dir1 = dirname($FileToProcess); # Get the folder name + $base1 = basename($FileToProcess); # Get the base name + ($base1, $dir1, $ext1) = fileparse($FileToProcess, '\..*'); # Get the extension of the file passed. # Do the processing only if the file has '.t' extension. if($ext1 eq '.t') { foreach $Script(@ScriptsNotUsed) { - if($Script eq $FileToProcess) + # The variables are converted to lower case before they are compared. + # This is done to remove the case-sensitive comparison done by 'eq'. + $Script1 = lc($Script); + $FileToProcess1 = lc($FileToProcess); + if($Script1 eq $FileToProcess1) { $HeadCut = 1; } |