|
1 #!/usr/bin/perl |
|
2 # |
|
3 # gen_template.pl |
|
4 # Makes test case templates. |
|
5 # Takes two arguments: |
|
6 # |
|
7 # -b : a bugnumber |
|
8 # -type : template type. {html|xhtml|xul|th}. defaults to html. |
|
9 # |
|
10 # perl gen_template.pl -b 345876 -type xul |
|
11 # |
|
12 # sends a test case template for bug 345876 to stdout |
|
13 use FindBin; |
|
14 use Getopt::Long; |
|
15 GetOptions("b=i"=> \$bug_number, |
|
16 "type:s"=> \$template_type); |
|
17 |
|
18 if ($template_type eq "xul") { |
|
19 $template_type = "$FindBin::RealBin/static/xul.template.txt"; |
|
20 } elsif ($template_type eq "xhtml") { |
|
21 $template_type = "$FindBin::RealBin/static/xhtml.template.txt"; |
|
22 } elsif ($template_type eq "chrome") { |
|
23 $template_type = "$FindBin::RealBin/static/chrome.template.txt"; |
|
24 } elsif ($template_type eq "th") { |
|
25 $template_type = "$FindBin::RealBin/static/th.template.txt"; |
|
26 } else { |
|
27 $template_type = "$FindBin::RealBin/static/test.template.txt"; |
|
28 } |
|
29 |
|
30 open(IN,$template_type) or die("Failed to open myfile for reading."); |
|
31 while((defined(IN)) && ($line = <IN>)) { |
|
32 $line =~ s/{BUGNUMBER}/$bug_number/g; |
|
33 print STDOUT $line; |
|
34 } |
|
35 close(IN); |