Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfs committed Feb 4, 2019
1 parent 6acf1ea commit 54716c9
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.gradle.api.file.FileVisitor
import org.gradle.test.fixtures.file.TestNameTestDirectoryProvider
import org.gradle.util.UsesNativeServices
import org.junit.Rule
import spock.lang.Issue
import spock.lang.Specification

@UsesNativeServices
Expand Down Expand Up @@ -66,15 +67,30 @@ class DefaultSingletonFileTreeTest extends Specification {
new FileTreeAdapter(directoryTree).files == [f] as Set
}

@Issue("https://github.com/gradle/gradle/issues/8394")
def "convert filtered tree to empty file trees"() {
File f = temporaryFolder.file('test-file')
f.createNewFile()
DefaultSingletonFileTree singletonFileTree = new DefaultSingletonFileTree(f)
def tree = new FileTreeAdapter(singletonFileTree).filter { it.name == 'different' }
File rootFile = temporaryFolder.file('test-file')
rootFile.createNewFile()
DefaultSingletonFileTree singletonFileTree = new DefaultSingletonFileTree(rootFile)
def tree = new FileTreeAdapter(singletonFileTree).matching {
it.include 'different'
}

when:
def fileTrees = tree.getAsFileTrees()
then:
fileTrees.size() == 0
}

def "contains delegates correctly"() {
File rootFile = temporaryFolder.file('test-file')
rootFile.createNewFile()
DefaultSingletonFileTree singletonFileTree = new DefaultSingletonFileTree(rootFile)
def tree = new FileTreeAdapter(singletonFileTree)

expect:
tree.contains(rootFile)
!tree.contains(temporaryFolder.file('test-file-new'))
!tree.matching { it.include 'different' }.contains(rootFile)
}
}

0 comments on commit 54716c9

Please sign in to comment.