testing/mochitest/gen_template.pl
author Robert Strong <robert.bugzilla@gmail.com>
Fri, 17 Feb 2017 14:04:46 -0800
changeset 367267 fb4e4e5f4d698e9f55efe5a798615b1cf7ae705f
parent 253947 42efd85dcb7d669da5d2da31a04b233fe995d0e3
permissions -rw-r--r--
Bug 1329692 - Ship updated Firefox system add-on to change app.update.url preference for Websense with new endpoint version check. r=felipc, r=bsmedberg for data, a=jcristau

#!/usr/bin/perl

# This script makes mochitest test case templates. See
# https://developer.mozilla.org/en-US/docs/Mochitest#Test_templates
#
# It takes two arguments:
#
#   -b:     a bugnumber
#   -type:  template type. One of {plain|xhtml|xul|th|chrome|chromexul}.
#           Defaults to th (testharness.js).
#
# For example, this command:
#
#  perl gen_template.pl -b 345876 -type xul
#
# writes a XUL test case template for bug 345876 to stdout.

use FindBin;
use Getopt::Long;
GetOptions("b=i"=> \$bug_number,
           "type:s"=> \$template_type);

if ($template_type eq "xul") {
  $template_type = "$FindBin::RealBin/static/xul.template.txt";
} elsif ($template_type eq "xhtml") {
  $template_type = "$FindBin::RealBin/static/xhtml.template.txt";
} elsif ($template_type eq "chrome") {
  $template_type = "$FindBin::RealBin/static/chrome.template.txt";
} elsif ($template_type eq "chromexul") {
  $template_type = "$FindBin::RealBin/static/chromexul.template.txt";
} elsif ($template_type eq "plain") {
  $template_type = "$FindBin::RealBin/static/test.template.txt";
} else {
  $template_type = "$FindBin::RealBin/static/th.template.txt";
}

open(IN,$template_type) or die("Failed to open myfile for reading.");
while((defined(IN)) && ($line = <IN>)) {
        $line =~ s/{BUGNUMBER}/$bug_number/g;
        print STDOUT $line;
}
close(IN);