From 426a5736d9e30254b4905698851092baaf577187 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Fri, 5 Sep 2014 13:13:44 +0000 Subject: [PATCH] test: list index files on failure git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1622693 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/lucene/index/TestIndexWriter.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java index 3316372e55a..19c10b52b0c 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java @@ -1166,6 +1166,7 @@ public class TestIndexWriter extends LuceneTestCase { } catch (Throwable t) { log.println("thread " + id + " FAILED; unexpected exception"); t.printStackTrace(log); + listIndexFiles(log, dir); failed = true; break; } @@ -1194,6 +1195,7 @@ public class TestIndexWriter extends LuceneTestCase { failed = true; log.println("thread " + id + ": CheckIndex FAILED: unexpected exception"); e.printStackTrace(log); + listIndexFiles(log, dir); } try { IndexReader r = DirectoryReader.open(dir); @@ -1203,6 +1205,7 @@ public class TestIndexWriter extends LuceneTestCase { failed = true; log.println("thread " + id + ": DirectoryReader.open FAILED: unexpected exception"); e.printStackTrace(log); + listIndexFiles(log, dir); } } try { @@ -1218,6 +1221,16 @@ public class TestIndexWriter extends LuceneTestCase { throw new RuntimeException("thread " + id, e); } } + + private void listIndexFiles(PrintStream log, Directory dir) { + try { + log.println("index files: " + Arrays.toString(dir.listAll())); + } catch (IOException ioe) { + // Suppress + log.println("failed to index files:"); + ioe.printStackTrace(log); + } + } } public void testThreadInterruptDeadlock() throws Exception { @@ -1730,7 +1743,6 @@ public class TestIndexWriter extends LuceneTestCase { Arrays.fill(chars, 'x'); Document doc = new Document(); final String bigTerm = new String(chars); - final BytesRef bigTermBytesRef = new BytesRef(bigTerm); // This contents produces a too-long term: String contents = "abc xyz x" + bigTerm + " another term";