/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6968063 7127924
* @summary provide examples of code that generate diagnostics
* @build ArgTypeCompilerFactory Example HTMLWriter RunExamples
*/
/*
* See CR 7127924 for info on why othervm is used.
*/
/**
* Utility to run selected or all examples, writing results to
* stdout, a plain text file or an HTML file. This program can be
* run standalone, or as a jtreg test.
*
* Options:
* -examples dir directory of examples. Defaults to ${test.src}/examples
* -raw run examples with -XDrawDiagnostics
* -showFiles include text of source files in the output
* -verbose verbose output
* -o file write output to file: format will be HTML if
* file has .html extension; otherwise it will be plain text.
* default is to stdout
* -title string specify a title, only applies to HTML output
*/
public class RunExamples {
if (jtreg) {
// use standard jtreg scratch directory: the current directory
} else {
RunExamples.class.getName()
}
RunExamples r = new RunExamples();
try {
return;
} finally {
/* VERY IMPORTANT NOTE. In jtreg mode, tmpDir is set to the
* jtreg scratch directory, which is the current directory.
* In case someone is faking jtreg mode, make sure to only
* clean tmpDir when it is reasonable to do so.
*/
if (tmpDir.isDirectory() &&
}
}
if (jtreg)
else
}
boolean raw = false;
boolean showFiles = false;
boolean verbose = false;
boolean argTypes = false;
raw = true;
showFiles = true;
verbose = true;
argTypes = true;
return false;
} else {
i++;
}
}
}
// special mode to show message keys and the types of the args that
// are used.
if (argTypes)
for (String k: selectedKeys) {
if (e.getDeclaredKeys().contains(k))
continue nextKey;
}
}
} else {
if (selectedExamples.isEmpty())
}
try {
Runner r;
else
r.run(selectedExamples);
r.close();
} catch (IOException e) {
error("Error writing output: " + e);
}
return (errors == 0);
}
/**
* Get the complete set of examples to be checked.
*/
if (isValidExample(f))
}
return results;
}
}
/**
* Report an error.
*/
errors++;
}
static boolean jtreg;
int errors;
/**
* Clean the contents of a directory.
*/
boolean ok = true;
if (f.isDirectory())
}
return ok;
}
static abstract class Runner {
}
startExample(e);
if (showFiles) {
showFiles(e, e.srcPathFiles);
showFiles(e, e.supportFiles);
}
run(e);
}
}
showFile(e, f);
}
try {
} finally {
}
}
protected boolean showFiles;
protected boolean raw;
protected boolean verbose;
}
throws IOException {
}
throws IOException {
}
void close() {
}
}
try {
} catch (IOException ex) {
}
if (m.matches()) {
} else {
}
}
// only show Output: header if also showing files
if (showFiles)
}
}
}
throws IOException {
}
+ " padding: 3px; border: thin solid silver; }");
+ " padding: 3px; border: thin solid silver; }");
+ " var item = document.getElementById(id);\n"
+ " if (item) {\n"
+ " item.className=(item.className=='hidden')?'unhidden':'hidden';\n"
+ " }\n"
+ "}");
}
}
}
}
for (String k: e.getDeclaredKeys()) {
if (s == null)
s.add(e);
}
}
if (INDEX_HEADER != null) {
}
} else {
}
}
int row = 0;
sep = ", ";
}
}
}
}
}
try {
} catch (IOException ex) {
}
}
} else
legalHeader = null;
} else
infoHeader = null;
if (legalHeader != null) {
//html.writeEntity("©");
sep = ", ";
}
if (infoHeader != null) {
sep = ", ";
}
}
if (legalHeader != null) {
}
if (infoHeader != null) {
}
}
// only show Output: header if also showing files
if (showFiles) {
}
}
}
return "id" + (nextId++);
}
int nextId;
}
}