Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / lcov / bin / gendesc
blobf4cfcbc52b9028eeed503d1afc8a7bbd29d821c6
1 #!/usr/bin/perl -w
3 # Copyright (c) International Business Machines Corp., 2002
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or (at
8 # your option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # gendesc
22 # This script creates a description file as understood by genhtml.
23 # Input file format:
25 # For each test case:
26 # <test name><optional whitespace>
27 # <at least one whitespace character (blank/tab)><test description>
29 # Actual description may consist of several lines. By default, output is
30 # written to stdout. Test names consist of alphanumeric characters
31 # including _ and -.
34 # History:
35 # 2002-09-02: created by Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com>
38 use strict;
39 use File::Basename;
40 use Getopt::Long;
43 # Constants
44 our $lcov_version = 'LCOV version 1.10';
45 our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php";
46 our $tool_name = basename($0);
49 # Prototypes
50 sub print_usage(*);
51 sub gen_desc();
52 sub warn_handler($);
53 sub die_handler($);
56 # Global variables
57 our $help;
58 our $version;
59 our $output_filename;
60 our $input_filename;
64 # Code entry point
67 $SIG{__WARN__} = \&warn_handler;
68 $SIG{__DIE__} = \&die_handler;
70 # Prettify version string
71 $lcov_version =~ s/\$\s*Revision\s*:?\s*(\S+)\s*\$/$1/;
73 # Parse command line options
74 if (!GetOptions("output-filename=s" => \$output_filename,
75 "version" =>\$version,
76 "help|?" => \$help
79 print(STDERR "Use $tool_name --help to get usage information\n");
80 exit(1);
83 $input_filename = $ARGV[0];
85 # Check for help option
86 if ($help)
88 print_usage(*STDOUT);
89 exit(0);
92 # Check for version option
93 if ($version)
95 print("$tool_name: $lcov_version\n");
96 exit(0);
100 # Check for input filename
101 if (!$input_filename)
103 die("No input filename specified\n".
104 "Use $tool_name --help to get usage information\n");
107 # Do something
108 gen_desc();
112 # print_usage(handle)
114 # Write out command line usage information to given filehandle.
117 sub print_usage(*)
119 local *HANDLE = $_[0];
121 print(HANDLE <<END_OF_USAGE)
122 Usage: $tool_name [OPTIONS] INPUTFILE
124 Convert a test case description file into a format as understood by genhtml.
126 -h, --help Print this help, then exit
127 -v, --version Print version number, then exit
128 -o, --output-filename FILENAME Write description to FILENAME
130 For more information see: $lcov_url
131 END_OF_USAGE
137 # gen_desc()
139 # Read text file INPUT_FILENAME and convert the contained description to a
140 # format as understood by genhtml, i.e.
142 # TN:<test name>
143 # TD:<test description>
145 # If defined, write output to OUTPUT_FILENAME, otherwise to stdout.
147 # Die on error.
150 sub gen_desc()
152 local *INPUT_HANDLE;
153 local *OUTPUT_HANDLE;
154 my $empty_line = "ignore";
156 open(INPUT_HANDLE, "<", $input_filename)
157 or die("ERROR: cannot open $input_filename!\n");
159 # Open output file for writing
160 if ($output_filename)
162 open(OUTPUT_HANDLE, ">", $output_filename)
163 or die("ERROR: cannot create $output_filename!\n");
165 else
167 *OUTPUT_HANDLE = *STDOUT;
170 # Process all lines in input file
171 while (<INPUT_HANDLE>)
173 chomp($_);
175 if (/^(\w[\w-]*)(\s*)$/)
177 # Matched test name
178 # Name starts with alphanum or _, continues with
179 # alphanum, _ or -
180 print(OUTPUT_HANDLE "TN: $1\n");
181 $empty_line = "ignore";
183 elsif (/^(\s+)(\S.*?)\s*$/)
185 # Matched test description
186 if ($empty_line eq "insert")
188 # Write preserved empty line
189 print(OUTPUT_HANDLE "TD: \n");
191 print(OUTPUT_HANDLE "TD: $2\n");
192 $empty_line = "observe";
194 elsif (/^\s*$/)
196 # Matched empty line to preserve paragraph separation
197 # inside description text
198 if ($empty_line eq "observe")
200 $empty_line = "insert";
205 # Close output file if defined
206 if ($output_filename)
208 close(OUTPUT_HANDLE);
211 close(INPUT_HANDLE);
214 sub warn_handler($)
216 my ($msg) = @_;
218 warn("$tool_name: $msg");
221 sub die_handler($)
223 my ($msg) = @_;
225 die("$tool_name: $msg");