提交 f7336dab authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Do not write each SQL error three times in TestScript

上级 f3ac8c41
...@@ -464,6 +464,17 @@ public abstract class TestBase { ...@@ -464,6 +464,17 @@ public abstract class TestBase {
throw new AssertionError(string); throw new AssertionError(string);
} }
/**
* Log an error message.
*
* @param s the message
*/
public static void logErrorMessage(String s) {
System.out.flush();
System.err.println("ERROR: " + s + "------------------------------");
logThrowable(s, null);
}
/** /**
* Log an error message. * Log an error message.
* *
...@@ -478,6 +489,10 @@ public abstract class TestBase { ...@@ -478,6 +489,10 @@ public abstract class TestBase {
System.err.println("ERROR: " + s + " " + e.toString() System.err.println("ERROR: " + s + " " + e.toString()
+ " ------------------------------"); + " ------------------------------");
e.printStackTrace(); e.printStackTrace();
logThrowable(null, e);
}
private static void logThrowable(String s, Throwable e) {
// synchronize on this class, because file locks are only visible to // synchronize on this class, because file locks are only visible to
// other JVMs // other JVMs
synchronized (TestBase.class) { synchronized (TestBase.class) {
...@@ -494,9 +509,14 @@ public abstract class TestBase { ...@@ -494,9 +509,14 @@ public abstract class TestBase {
} }
// append // append
FileWriter fw = new FileWriter("error.txt", true); FileWriter fw = new FileWriter("error.txt", true);
PrintWriter pw = new PrintWriter(fw); if (s != null) {
e.printStackTrace(pw); fw.write(s);
pw.close(); }
if (e != null) {
PrintWriter pw = new PrintWriter(fw);
e.printStackTrace(pw);
pw.close();
}
fw.close(); fw.close();
// unlock // unlock
lock.release(); lock.release();
......
...@@ -172,7 +172,7 @@ public class TestScript extends TestBase { ...@@ -172,7 +172,7 @@ public class TestScript extends TestBase {
conn.close(); conn.close();
out.close(); out.close();
if (errors.length() > 0) { if (errors.length() > 0) {
throw new Exception("errors:\n" + errors.toString()); throw new Exception("errors found");
} }
// new File(outFile).delete(); // new File(outFile).delete();
} }
...@@ -445,7 +445,7 @@ public class TestScript extends TestBase { ...@@ -445,7 +445,7 @@ public class TestScript extends TestBase {
if (e != null) { if (e != null) {
TestBase.logError("script", e); TestBase.logError("script", e);
} }
TestBase.logError(errors.toString(), null); TestBase.logErrorMessage(errors.toString());
if (failFast) { if (failFast) {
conn.close(); conn.close();
System.exit(1); System.exit(1);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论