mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
8081472: Add a mode to the tests for class-file attributes which dumps in-memory sources to disk
Reviewed-by: ksrini
This commit is contained in:
parent
96f1486b0a
commit
b403bd3715
4 changed files with 27 additions and 7 deletions
|
@ -44,6 +44,7 @@ import com.sun.tools.classfile.ConstantPoolException;
|
|||
public class TestBase {
|
||||
|
||||
public static final String LINE_SEPARATOR = System.lineSeparator();
|
||||
public static final boolean isDumpOfSourceEnabled = Boolean.getBoolean("dump.src");
|
||||
|
||||
private <S> InMemoryFileManager compile(
|
||||
List<String> options,
|
||||
|
@ -176,7 +177,9 @@ public class TestBase {
|
|||
* @throws ConstantPoolException if constant pool error occurs
|
||||
*/
|
||||
public ClassFile readClassFile(File file) throws IOException, ConstantPoolException {
|
||||
return readClassFile(new FileInputStream(file));
|
||||
try (InputStream is = new FileInputStream(file)) {
|
||||
return readClassFile(is);
|
||||
}
|
||||
}
|
||||
|
||||
public void assertEquals(Object actual, Object expected, String message) {
|
||||
|
@ -215,6 +218,14 @@ public class TestBase {
|
|||
}
|
||||
}
|
||||
|
||||
public void writeToFileIfEnabled(Path path, String source) throws IOException {
|
||||
if (isDumpOfSourceEnabled) {
|
||||
writeToFile(path, source);
|
||||
} else {
|
||||
System.err.println("Source dumping disabled. To enable, run the test with '-Ddump.src=true'");
|
||||
}
|
||||
}
|
||||
|
||||
public File getSourceDir() {
|
||||
return new File(System.getProperty("test.src", "."));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue