/*
* 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 7022337
* @summary repeated warnings about bootclasspath not set
* @library ../lib
* @build JavacTestingAbstractProcessor TestWarnErrorCount
* @run main TestWarnErrorCount
*/
}
/**
* Type of errors to generate in test case.
*/
enum ErrorKind {
/** No errors. */
NONE,
/** Source code errors. */
JAVA,
/** Errors reported to Messager. */
/** Error as a result of using -Werror. */
}
/**
* Frequency of warnings in test case.
*/
enum WarnKind {
/** No warnings. */
NONE {
},
/** Generate a warning if round count is a multiple of 2. */
},
/** Generate a warning if round count is a multiple of 3. */
},
/** Generate a warning every round. */
ALL {
};
/** whether to generate a warning in round 'round'. */
/** number of warnings generated in a range of rounds, inclusive. */
}
/**
* Run test.
* @param args provide ability to specify particular test cases for debugging.
*/
stopOnError = true;
} else
throw new IllegalArgumentException(arg);
}
run ();
if (errors > 0)
}
/**
* Run test.
*/
}
}
}
}
boolean stopOnError;
/**
* Run a test case.
* @param ek The type of errors to generate
* @param mwk The frequency of Messager warnings to generate
* @param jwk The frequency of Java warnings to generate
*/
testNum++;
return;
"-XDrawDiagnostics",
"-processor", myName,
// "-XprintRounds",
"-Xlint:all,-path",
"-AerrKind=" + ek,
"-AmsgrWarnKind=" + mwk,
"-AjavaWarnKind=" + jwk));
int errsFound = 0;
int errsReported = 0;
int warnsFound = 0;
int warnsReported = 0;
// Scan the output looking for messages of interest.
errsFound++;
warnsFound++;
}
}
// Compute the expected number of errors and warnings, based on
// the test case parameters.
// This is highly specific to the annotation processor below, and to
// the files it generates.
// Generally, the rules are:
// -- errors stop annotation processing, allowing for one extra "last round"
// -- messager warnings are immediate
// -- javac warnings are not shown before the final compilation
// (FIXME? -Werror does not stop processing for java warnings)
int errsExpected;
int msgrWarnsExpected;
int javaWarnsExpected;
switch (ek) {
case NONE:
errsExpected = 0;
break;
case MESSAGER:
errsExpected = 1;
javaWarnsExpected = 0;
break;
case JAVA:
errsExpected = 2;
javaWarnsExpected = 0;
break;
case WERROR:
switch (mwk) {
case NONE:
msgrWarnsExpected = 0;
? 0
: 1; // this is surprising: javac only reports warning in first file
break;
case EVERY_TWO:
javaWarnsExpected = 0;
break;
case EVERY_THREE:
javaWarnsExpected = 0;
break;
case ALL:
javaWarnsExpected = 0;
break;
default:
throw new IllegalStateException();
}
break;
default:
throw new IllegalStateException();
}
+ ", jwk: " + javaWarnsExpected
+ ", total: " + warnsExpected);
boolean ok;
if (ok)
}
if (rc != 0)
return out;
}
}
errors++;
}
// ----- Annotation processor -----
round++;
"Round " + round
return true;
}
try {
try {
+ "}\n");
} finally {
}
} catch (IOException e) {
throw new Error(e);
}
}
}