summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2016-10-24 20:19:51 +0200
committerAraq <rumpf_a@web.de>2016-10-24 20:19:51 +0200
commit1d191831c0c41536efc1a57be48f38b0746bd40f (patch)
tree7932d6fbb0a59b77d3c9a3dc8a576bd4f13a2bff
parentbad35a2709105c8d5d8925c8fdb3d847673d132c (diff)
parenta85e954b5d690b0305d2abaff04cd6d4098029f1 (diff)
downloadNim-1d191831c0c41536efc1a57be48f38b0746bd40f.tar.gz
Merge branch 'rudis-devel' into devel
-rw-r--r--tests/stdlib/tgetfileinfo.nim40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/stdlib/tgetfileinfo.nim b/tests/stdlib/tgetfileinfo.nim
index 8a0538a5f..1c897b702 100644
--- a/tests/stdlib/tgetfileinfo.nim
+++ b/tests/stdlib/tgetfileinfo.nim
@@ -1,5 +1,5 @@
 discard """
-  output: ""
+  output: "pcDir\npcFile\npcLinkToDir\npcLinkToFile\n"
 """
 
 import os, strutils
@@ -93,4 +93,42 @@ proc testGetFileInfo =
       discard
       #echo("Handle : Invalid File : Success")
 
+  # Test kind for files, directories and symlinks.
+  block:
+    let
+      tmp = getTempDir()
+      dirPath      = tmp / "test-dir"
+      filePath     = tmp / "test-file"
+      linkDirPath  = tmp / "test-link-dir"
+      linkFilePath = tmp / "test-link-file"
+
+    createDir(dirPath)
+    writeFile(filePath, "")
+    when defined(posix):
+      createSymlink(dirPath, linkDirPath)
+      createSymlink(filePath, linkFilePath)
+
+    let
+      dirInfo = getFileInfo(dirPath)
+      fileInfo = getFileInfo(filePath)
+    when defined(posix):
+      let
+        linkDirInfo = getFileInfo(linkDirPath, followSymlink = false)
+        linkFileInfo = getFileInfo(linkFilePath, followSymlink = false)
+
+    echo dirInfo.kind
+    echo fileInfo.kind
+    when defined(posix):
+      echo linkDirInfo.kind
+      echo linkFileInfo.kind
+    else:
+      echo pcLinkToDir
+      echo pcLinkToFile
+
+    removeDir(dirPath)
+    removeFile(filePath)
+    when defined(posix):
+      removeFile(linkDirPath)
+      removeFile(linkFilePath)
+
 testGetFileInfo()