From 49b295296e5145abacfd4babac5edaa8b73dffd8 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Sat, 4 Nov 2017 13:17:49 +0000 Subject: [PATCH] SQL: Fail on trailing test specs (elastic/x-pack-elasticsearch#2836) If you wrote a test at the end of one of SQL's test spec files that was just a name without a body then the parser would throw the test away. Now it fails to intiaize the class with an error message telling you which file is broken. Original commit: elastic/x-pack-elasticsearch@023a942ca3235ff2063c3bf3ca9928b8d9ce8aca --- .../xpack/qa/sql/jdbc/SpecBaseIntegrationTestCase.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/jdbc/SpecBaseIntegrationTestCase.java b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/jdbc/SpecBaseIntegrationTestCase.java index 6aafa4ddb0b..3b8ff080c23 100644 --- a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/jdbc/SpecBaseIntegrationTestCase.java +++ b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/jdbc/SpecBaseIntegrationTestCase.java @@ -147,8 +147,7 @@ public abstract class SpecBaseIntegrationTestCase extends JdbcIntegrationTestCas testName = Strings.capitalize(line); testNames.put(testName, Integer.valueOf(lineNumber)); } - } - else { + } else { Object result = parser.parse(line); // only if the parser is ready, add the object - otherwise keep on serving it lines if (result != null) { @@ -156,10 +155,12 @@ public abstract class SpecBaseIntegrationTestCase extends JdbcIntegrationTestCas testName = null; } } - // NOCOMMIT be more careful on the last line } lineNumber++; } + if (testName != null) { + throw new IllegalStateException("Read a test without a body at the end of [" + fileName + "]."); + } } assertNull("Cannot find spec for test " + testName, testName); @@ -174,4 +175,4 @@ public abstract class SpecBaseIntegrationTestCase extends JdbcIntegrationTestCas public static InputStream readFromJarUrl(URL source) throws IOException { return source.openStream(); } -} \ No newline at end of file +}