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

Add >> syntax for SQL tests

上级 d604dce4
...@@ -389,6 +389,26 @@ public class TestScript extends TestBase { ...@@ -389,6 +389,26 @@ public class TestScript extends TestBase {
head[i] = label; head[i] = label;
} }
rs.close(); rs.close();
String line = readLine();
putBack = line;
if (line != null && line.startsWith(">> ")) {
switch (result.size()) {
case 0:
writeResult(sql, "<no result>", null, ">> ");
return;
case 1:
String[] row = result.get(0);
if (row.length == 1) {
writeResult(sql, row[0], null, ">> ");
} else {
writeResult(sql, "<row with " + row.length + " values>", null, ">> ");
}
return;
default:
writeResult(sql, "<" + result.size() + " rows>", null, ">> ");
return;
}
}
writeResult(sql, format(head, max), null); writeResult(sql, format(head, max), null);
writeResult(sql, format(null, max), null); writeResult(sql, format(null, max), null);
String[] array = new String[result.size()]; String[] array = new String[result.size()];
...@@ -433,10 +453,13 @@ public class TestScript extends TestBase { ...@@ -433,10 +453,13 @@ public class TestScript extends TestBase {
writeResult(sql, "exception", e); writeResult(sql, "exception", e);
} }
private void writeResult(String sql, String s, SQLException e) private void writeResult(String sql, String s, SQLException e) throws Exception {
throws Exception { writeResult(sql, s, e, "> ");
}
private void writeResult(String sql, String s, SQLException e, String prefix) throws Exception {
assertKnownException(sql, e); assertKnownException(sql, e);
s = ("> " + s).trim(); s = (prefix + s).trim();
String compare = readLine(); String compare = readLine();
if (compare != null && compare.startsWith(">")) { if (compare != null && compare.startsWith(">")) {
if (!compare.equals(s)) { if (!compare.equals(s)) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论