-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmake-pl-out
executable file
·54 lines (44 loc) · 1.23 KB
/
make-pl-out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl
#
# Runs each of the .pl scripts in source/code and captures the output into a
# .pl-out file.
#
# The script first chdir's into the source/code directory so that the scripts
# can simply assume any .xml file is in the current directory.
#
use 5.010;
use strict;
use warnings;
use autodie;
chdir('source/code');
my $out_dir = '../_output';
mkdir($out_dir) unless -d $out_dir;
my $zip_file = "$out_dir/perl-libxml-examples.zip";
my $rezip = ! -e $zip_file;
say "Running example scripts";
foreach my $script (sort glob '*.pl') {
my $out_file = "$out_dir/$script-out";
if(-e $out_file) {
my $script_age = -M $script;
my $output_age = -M $out_file;
next if $script_age > $output_age;
}
say " $script > $out_dir/$script-out 2> $out_dir/$script-err";
system("./$script > $out_dir/$script-out 2> $out_dir/$script-err") == 0
or exit $? >> 8;
}
$rezip ||= zip_is_stale();
if($rezip) {
say "Creating perl-libxml-examples.zip";
unlink($zip_file) if -e $zip_file;
system("zip $zip_file *") == 0
or exit $? >> 8;
}
exit;
sub zip_is_stale {
my $zip_age = -M $zip_file;
foreach my $file (glob '*') {
return 1 if $zip_age > -M $file;
}
return 0;
}