2006-10-25 20:40:15 +00:00
|
|
|
#!/usr/bin/perl
|
2014-10-28 22:04:03 +00:00
|
|
|
|
|
|
|
# This script makes mochitest test case templates. See
|
|
|
|
# https://developer.mozilla.org/en-US/docs/Mochitest#Test_templates
|
|
|
|
#
|
|
|
|
# It takes two arguments:
|
2006-10-25 20:40:15 +00:00
|
|
|
#
|
2014-10-28 22:04:03 +00:00
|
|
|
# -b: a bugnumber
|
|
|
|
# -type: template type. One of {html|xhtml|xul|th|chrome|chromexul}.
|
|
|
|
# Defaults to html.
|
2006-10-25 20:40:15 +00:00
|
|
|
#
|
2014-10-28 22:04:03 +00:00
|
|
|
# For example, this command:
|
2006-11-07 00:56:50 +00:00
|
|
|
#
|
|
|
|
# perl gen_template.pl -b 345876 -type xul
|
2006-10-25 20:40:15 +00:00
|
|
|
#
|
2014-10-28 22:04:03 +00:00
|
|
|
# writes a XUL test case template for bug 345876 to stdout.
|
|
|
|
|
2006-11-08 19:19:19 +00:00
|
|
|
use FindBin;
|
2006-11-07 00:56:50 +00:00
|
|
|
use Getopt::Long;
|
|
|
|
GetOptions("b=i"=> \$bug_number,
|
|
|
|
"type:s"=> \$template_type);
|
2006-10-25 20:40:15 +00:00
|
|
|
|
2006-11-08 07:07:44 +00:00
|
|
|
if ($template_type eq "xul") {
|
2006-11-08 19:19:19 +00:00
|
|
|
$template_type = "$FindBin::RealBin/static/xul.template.txt";
|
2006-11-08 07:07:44 +00:00
|
|
|
} elsif ($template_type eq "xhtml") {
|
2006-11-08 19:19:19 +00:00
|
|
|
$template_type = "$FindBin::RealBin/static/xhtml.template.txt";
|
2010-01-13 16:37:54 +00:00
|
|
|
} elsif ($template_type eq "chrome") {
|
|
|
|
$template_type = "$FindBin::RealBin/static/chrome.template.txt";
|
2014-08-05 17:56:43 +00:00
|
|
|
} elsif ($template_type eq "chromexul") {
|
|
|
|
$template_type = "$FindBin::RealBin/static/chromexul.template.txt";
|
2012-12-02 08:59:36 +00:00
|
|
|
} elsif ($template_type eq "th") {
|
|
|
|
$template_type = "$FindBin::RealBin/static/th.template.txt";
|
2006-11-07 00:56:50 +00:00
|
|
|
} else {
|
2006-11-08 19:19:19 +00:00
|
|
|
$template_type = "$FindBin::RealBin/static/test.template.txt";
|
2006-11-07 00:56:50 +00:00
|
|
|
}
|
2006-10-25 20:40:15 +00:00
|
|
|
|
2006-11-07 00:56:50 +00:00
|
|
|
open(IN,$template_type) or die("Failed to open myfile for reading.");
|
2006-10-25 20:40:15 +00:00
|
|
|
while((defined(IN)) && ($line = <IN>)) {
|
|
|
|
$line =~ s/{BUGNUMBER}/$bug_number/g;
|
|
|
|
print STDOUT $line;
|
|
|
|
}
|
|
|
|
close(IN);
|