- Added Process.getPid() and Terminal.isTerminal().

- Added a test command-line app.
This commit is contained in:
Adam Murdoch
2012-07-29 17:05:06 +10:00
parent 1d56f93e64
commit c009527afa
12 changed files with 141 additions and 25 deletions

View File

@@ -0,0 +1,52 @@
package net.rubygrapefruit.platform
import spock.lang.Specification
import org.junit.Rule
import org.junit.rules.TemporaryFolder
class PosixFileTest extends Specification {
@Rule TemporaryFolder tmpDir
final PosixFile file = Platform.get(PosixFile.class)
def "can set mode on a file"() {
def testFile = tmpDir.newFile("test.txt")
when:
file.setMode(testFile, 0740)
then:
file.getMode(testFile) == 0740
}
def "can set mode on a file with unicode in its name"() {
def testFile = tmpDir.newFile("test\u03b1.txt")
when:
file.setMode(testFile, 0740)
then:
file.getMode(testFile) == 0740
}
def "throws exception on failure to set mode"() {
def file = new File(tmpDir.root, "unknown")
when:
this.file.setMode(file, 0660)
then:
NativeException e = thrown()
e.message == "Could not set UNIX mode on $file. Errno is 2."
}
def "throws exception on failure to get mode"() {
def file = new File(tmpDir.root, "unknown")
when:
this.file.getMode(file)
then:
NativeException e = thrown()
e.message == "Could not get UNIX mode on $file. Errno is 2."
}
}