You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Ryan Ernst (JIRA)" <ji...@apache.org> on 2014/11/23 20:15:12 UTC

[jira] [Commented] (LUCENE-6072) Use mock filesystem in tests

    [ https://issues.apache.org/jira/browse/LUCENE-6072?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14222467#comment-14222467 ] 

Ryan Ernst commented on LUCENE-6072:
------------------------------------

This looks great! It would be cool if this could replace the windows virus checker mocking that was done recently?

+1 to the patch. My only thought is to rename "sop" in VerboseFS to something like "log" or "notify".

> Use mock filesystem in tests
> ----------------------------
>
>                 Key: LUCENE-6072
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6072
>             Project: Lucene - Core
>          Issue Type: Test
>            Reporter: Robert Muir
>         Attachments: LUCENE-6072.patch, LUCENE-6072.patch, LUCENE-6072.patch
>
>
> We went through the trouble to convert to NIO.2, but we don't take advantage of it in tests...
> Since everything boils down to LuceneTestCase's temp dir (which is just Path), we can wrap the filesystem with useful stuff:
> * detect file handle leaks (better than mockdir: not just index files)
> * act like windows (don't delete open files, case-insensitivity, etc)
> * verbosity (add what is going on to infostream for debugging)
> I prototyped some of this in a patch. Currently it makes a chain like this:
> {code}
>   private FileSystem initializeFileSystem() {
>     FileSystem fs = FileSystems.getDefault();
>     if (LuceneTestCase.VERBOSE) {
>       fs = new VerboseFS(fs,
>                 new PrintStreamInfoStream(System.out)).getFileSystem(null);
>     }
>     fs = new LeakFS(fs).getFileSystem(null);
>     fs = new WindowsFS(fs).getFileSystem(null);
>     return fs.provider().getFileSystem(URI.create("file:///"));
>   }
> {code}
> Some things to figure out:
> * I don't think we want to wrap all the time (worry about hiding bugs)
> * its currently a bit lenient (e.g. these filesystems allow calling toFile, which can "escape" and allow you to do broken things). But only 2 or 3 tests really need File, so we could fix that.
> * its currently complicated and messy (i blame the jdk api here, but maybe we can simplify it)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org