- Changed Native.get() to cache integration instances.
- Extracted DefaultSystemInfo out of a couple of separate places.
This commit is contained in:
@@ -8,6 +8,11 @@ class FileSystemsTest extends Specification {
|
||||
@Rule TemporaryFolder tmpDir
|
||||
final FileSystems fileSystems = Native.get(FileSystems.class)
|
||||
|
||||
def "caches file systems instance"() {
|
||||
expect:
|
||||
Native.get(FileSystems.class) == fileSystems
|
||||
}
|
||||
|
||||
def "can query filesystem details"() {
|
||||
expect:
|
||||
fileSystems.fileSystems.collect() { it.mountPoint }.containsAll(File.listRoots())
|
||||
|
||||
@@ -11,6 +11,11 @@ class PosixFileTest extends Specification {
|
||||
@Rule TemporaryFolder tmpDir
|
||||
final PosixFile file = Native.get(PosixFile.class)
|
||||
|
||||
def "caches file instance"() {
|
||||
expect:
|
||||
Native.get(PosixFile.class) == file
|
||||
}
|
||||
|
||||
def "can set mode on a file"() {
|
||||
def testFile = tmpDir.newFile("test.txt")
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@ class ProcessTest extends Specification {
|
||||
@Rule TemporaryFolder tmpDir
|
||||
final Process process = Native.get(Process.class)
|
||||
|
||||
def "caches process instance"() {
|
||||
expect:
|
||||
Native.get(Process.class) == process
|
||||
}
|
||||
|
||||
def "can get PID"() {
|
||||
expect:
|
||||
process.getProcessId() != 0
|
||||
|
||||
@@ -8,6 +8,11 @@ class SystemInfoTest extends Specification {
|
||||
@Rule TemporaryFolder tmpDir
|
||||
final SystemInfo systemInfo = Native.get(SystemInfo.class)
|
||||
|
||||
def "caches system info instance"() {
|
||||
expect:
|
||||
Native.get(SystemInfo.class) == systemInfo
|
||||
}
|
||||
|
||||
def "can query OS details"() {
|
||||
expect:
|
||||
systemInfo.kernelName
|
||||
|
||||
@@ -8,18 +8,23 @@ import spock.lang.IgnoreIf
|
||||
|
||||
class TerminalsTest extends Specification {
|
||||
@Rule TemporaryFolder tmpDir
|
||||
final Terminals terminal = Native.get(Terminals.class)
|
||||
final Terminals terminals = Native.get(Terminals.class)
|
||||
|
||||
def "caches terminals instance"() {
|
||||
expect:
|
||||
Native.get(Terminals.class) == terminals
|
||||
}
|
||||
|
||||
def "can check if attached to terminal"() {
|
||||
expect:
|
||||
!terminal.isTerminal(Terminals.Output.Stdout);
|
||||
!terminal.isTerminal(Terminals.Output.Stderr);
|
||||
!terminals.isTerminal(Terminals.Output.Stdout);
|
||||
!terminals.isTerminal(Terminals.Output.Stderr);
|
||||
}
|
||||
|
||||
@IgnoreIf({Platform.current().windows})
|
||||
def "cannot access posix terminal from a test"() {
|
||||
when:
|
||||
terminal.getTerminal(Terminals.Output.Stdout)
|
||||
terminals.getTerminal(Terminals.Output.Stdout)
|
||||
|
||||
then:
|
||||
NativeException e = thrown()
|
||||
@@ -29,7 +34,7 @@ class TerminalsTest extends Specification {
|
||||
@IgnoreIf({!Platform.current().windows})
|
||||
def "cannot access windows console from a test"() {
|
||||
when:
|
||||
terminal.getTerminal(Terminals.Output.Stdout)
|
||||
terminals.getTerminal(Terminals.Output.Stdout)
|
||||
|
||||
then:
|
||||
NativeException e = thrown()
|
||||
|
||||
Reference in New Issue
Block a user