mirror of https://github.com/apache/lucene.git
LUCENE-6078: disable this test if get WindowsFS
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1641902 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dac24dd151
commit
cc21116c18
|
@ -2620,6 +2620,10 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
assumeFalse("this test can't run on Windows", Constants.WINDOWS);
|
||||
|
||||
MockDirectoryWrapper dir = newMockDirectory();
|
||||
if (TestUtil.isWindowsFS(dir)) {
|
||||
dir.close();
|
||||
assumeFalse("this test can't run on Windows", true);
|
||||
}
|
||||
|
||||
// don't act like windows either, or the test won't simulate the condition
|
||||
dir.setEnableVirusScanner(false);
|
||||
|
|
|
@ -172,4 +172,14 @@ public class FilterFileSystem extends FileSystem {
|
|||
public WatchService newWatchService() throws IOException {
|
||||
return delegate.newWatchService();
|
||||
}
|
||||
|
||||
/** Returns the {@code FileSystem} we wrap. */
|
||||
public FileSystem getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
/** Returns the {@code FilterFileSystemProvider} sent to this on init. */
|
||||
public FileSystemProvider getParent() {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.PrintStream;
|
|||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
|
@ -81,12 +82,16 @@ import org.apache.lucene.index.SegmentReader;
|
|||
import org.apache.lucene.index.Terms;
|
||||
import org.apache.lucene.index.TermsEnum;
|
||||
import org.apache.lucene.index.TieredMergePolicy;
|
||||
import org.apache.lucene.mockfile.FilterFileSystem;
|
||||
import org.apache.lucene.mockfile.WindowsFS;
|
||||
import org.apache.lucene.search.FieldDoc;
|
||||
import org.apache.lucene.search.FilteredQuery.FilterStrategy;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
import org.apache.lucene.search.ScoreDoc;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.FSDirectory;
|
||||
import org.apache.lucene.store.FilterDirectory;
|
||||
import org.apache.lucene.store.NoLockFactory;
|
||||
import org.junit.Assert;
|
||||
import com.carrotsearch.randomizedtesting.generators.RandomInts;
|
||||
|
@ -1142,6 +1147,35 @@ public final class TestUtil {
|
|||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns true if this is an FSDirectory backed by {@link WindowsFS}. */
|
||||
public static boolean isWindowsFS(Directory dir) {
|
||||
// First unwrap directory to see if there is an FSDir:
|
||||
while (true) {
|
||||
if (dir instanceof FSDirectory) {
|
||||
return isWindowsFS(((FSDirectory) dir).getDirectory());
|
||||
} else if (dir instanceof FilterDirectory) {
|
||||
dir = ((FilterDirectory) dir).getDelegate();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns true if this Path is backed by {@link WindowsFS}. */
|
||||
public static boolean isWindowsFS(Path path) {
|
||||
FileSystem fs = path.getFileSystem();
|
||||
while (true) {
|
||||
if (fs instanceof FilterFileSystem) {
|
||||
if (((FilterFileSystem) fs).getParent() instanceof WindowsFS) {
|
||||
return true;
|
||||
}
|
||||
fs = ((FilterFileSystem) fs).getDelegate();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** List of characters that match {@link Character#isWhitespace} */
|
||||
public static final char[] WHITESPACE_CHARACTERS = new char[] {
|
||||
|
|
Loading…
Reference in New Issue