2006-10-26 00:40:15 +04:00
|
|
|
#!/usr/bin/perl
|
2014-10-29 01:04:03 +03: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-26 00:40:15 +04:00
|
|
|
#
|
2014-10-29 01:04:03 +03:00
|
|
|
# -b: a bugnumber
|
2015-01-30 22:38:45 +03:00
|
|
|
# -type: template type. One of {plain|xhtml|xul|th|chrome|chromexul}.
|
|
|
|
# Defaults to th (testharness.js).
|
2006-10-26 00:40:15 +04:00
|
|
|
#
|
2014-10-29 01:04:03 +03:00
|
|
|
# For example, this command:
|
2006-11-07 03:56:50 +03:00
|
|
|
#
|
|
|
|
# perl gen_template.pl -b 345876 -type xul
|
2006-10-26 00:40:15 +04:00
|
|
|
#
|
2014-10-29 01:04:03 +03:00
|
|
|
# writes a XUL test case template for bug 345876 to stdout.
|
|
|
|
|
2006-11-08 22:19:19 +03:00
|
|
|
use FindBin;
|
2006-11-07 03:56:50 +03:00
|
|
|
use Getopt::Long;
|
|
|
|
GetOptions("b=i"=> \$bug_number,
|
|
|
|
"type:s"=> \$template_type);
|
2006-10-26 00:40:15 +04:00
|
|
|
|
2006-11-08 10:07:44 +03:00
|
|
|
if ($template_type eq "xul") {
|
2006-11-08 22:19:19 +03:00
|
|
|
$template_type = "$FindBin::RealBin/static/xul.template.txt";
|
2006-11-08 10:07:44 +03:00
|
|
|
} elsif ($template_type eq "xhtml") {
|
2006-11-08 22:19:19 +03:00
|
|
|
$template_type = "$FindBin::RealBin/static/xhtml.template.txt";
|
2010-01-13 19:37:54 +03:00
|
|
|
} elsif ($template_type eq "chrome") {
|
|
|
|
$template_type = "$FindBin::RealBin/static/chrome.template.txt";
|
2014-08-05 21:56:43 +04:00
|
|
|
} elsif ($template_type eq "chromexul") {
|
|
|
|
$template_type = "$FindBin::RealBin/static/chromexul.template.txt";
|
2015-01-30 22:38:45 +03:00
|
|
|
} elsif ($template_type eq "plain") {
|
2006-11-08 22:19:19 +03:00
|
|
|
$template_type = "$FindBin::RealBin/static/test.template.txt";
|
2015-01-30 22:38:45 +03:00
|
|
|
} else {
|
|
|
|
$template_type = "$FindBin::RealBin/static/th.template.txt";
|
2006-11-07 03:56:50 +03:00
|
|
|
}
|
2006-10-26 00:40:15 +04:00
|
|
|
|
2006-11-07 03:56:50 +03:00
|
|
|
open(IN,$template_type) or die("Failed to open myfile for reading.");
|
2006-10-26 00:40:15 +04:00
|
|
|
while((defined(IN)) && ($line = <IN>)) {
|
|
|
|
$line =~ s/{BUGNUMBER}/$bug_number/g;
|
|
|
|
print STDOUT $line;
|
|
|
|
}
|
|
|
|
close(IN);
|