--- /dev/null
+# This Makefile runs the tests using GHC's testsuite framework. It
+# assumes the package is part of a GHC build tree with the testsuite
+# installed in ../../../testsuite.
+
+TOP=../../../testsuite
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
--- /dev/null
+test('currentDirectory001', normal, compile_and_run, [''])
+test('directory001', normal, compile_and_run, [''])
+test('doesDirectoryExist001', normal, compile_and_run, [''])
+
+# This test is a bit bogus. Disable for GHCi.
+test('getDirContents001', omit_ways(['ghci']), compile_and_run, ['-fno-gen-manifest'])
+
+# Depends on binary from previous run, which gets removed by the driver way=ghci
+test('getPermissions001', omit_ways(['ghci']), compile_and_run, ['-cpp'])
--- /dev/null
+import Directory (getCurrentDirectory, setCurrentDirectory,
+ createDirectory, removeDirectory, getDirectoryContents)
+
+main = do
+ oldpwd <- getCurrentDirectory
+ createDirectory "foo"
+ setCurrentDirectory "foo"
+ ~[n1, n2] <- getDirectoryContents "."
+ if dot n1 && dot n2
+ then do
+ setCurrentDirectory oldpwd
+ removeDirectory "foo"
+ putStr "Okay\n"
+ else
+ ioError (userError "Oops")
+
+dot :: String -> Bool
+dot "." = True
+dot ".." = True
+dot _ = False
--- /dev/null
+import Directory (getCurrentDirectory, setCurrentDirectory,
+ createDirectory, removeDirectory, getDirectoryContents)
+
+main = do
+ oldpwd <- getCurrentDirectory
+ createDirectory "foo"
+ setCurrentDirectory "foo"
+ ~[n1, n2] <- getDirectoryContents "."
+ if dot n1 && dot n2
+ then do
+ setCurrentDirectory oldpwd
+ removeDirectory "foo"
+ putStr "Okay\n"
+ else
+ ioError (userError "Oops")
+
+dot :: String -> Bool
+dot "." = True
+dot ".." = True
+dot _ = False
--- /dev/null
+import IO
+
+import Directory
+
+main = do
+ createDirectory "foo"
+ h <- openFile "foo/bar" WriteMode
+ hPutStr h "Okay\n"
+ hClose h
+ renameFile "foo/bar" "foo/baz"
+ renameDirectory "foo" "bar"
+ h <- openFile "bar/baz" ReadMode
+ stuff <- hGetContents h
+ putStr stuff
+-- hClose h -- an error !
+ removeFile "bar/baz"
+ removeDirectory "bar"
--- /dev/null
+-- !!! "/" was not recognised as a directory in 6.0.x
+import System.Directory
+main = doesDirectoryExist "/" >>= print
+
--- /dev/null
+import Directory (getDirectoryContents)
+import List (sort, isPrefixOf, isSuffixOf)
+
+main = do
+ names <- getDirectoryContents "."
+ putStrLn (unlines (sort (filter ok names)))
+
+ok name = "getDirContents" `isPrefixOf` name
+ && not ("bak" `isSuffixOf` name)
+ && not ("prof" `isSuffixOf` name)
+ && not ("hp" `isSuffixOf` name)
+ && not ("ps" `isSuffixOf` name)
+ && not ("aux" `isSuffixOf` name)
--- /dev/null
+getDirContents001
+getDirContents001.comp.stderr
+getDirContents001.hi
+getDirContents001.hs
+getDirContents001.o
+getDirContents001.run.stderr
+getDirContents001.run.stdout
+getDirContents001.stdout
+getDirContents001.stdout-i386-unknown-mingw32
+
--- /dev/null
+getDirContents001.comp.stderr\r
+getDirContents001.exe\r
+getDirContents001.hi\r
+getDirContents001.hs\r
+getDirContents001.o\r
+getDirContents001.run.stderr\r
+getDirContents001.run.stdout\r
+getDirContents001.stdout\r
+getDirContents001.stdout-i386-unknown-mingw32\r
+\r
--- /dev/null
+import Directory
+
+main = do
+ p <- getPermissions "."
+ print p
+ p <- getPermissions "getPermissions001.hs"
+ print p
+#ifndef i386_unknown_mingw32
+ p <- getPermissions "getPermissions001"
+#else
+ p <- getPermissions "getPermissions001.exe"
+#endif
+ print p
--- /dev/null
+Permissions {readable = True, writable = True, executable = False, searchable = True}
+Permissions {readable = True, writable = True, executable = False, searchable = False}
+Permissions {readable = True, writable = True, executable = True, searchable = False}
--- /dev/null
+Permissions {readable = True, writable = True, executable = False, searchable = True}
+Permissions {readable = True, writable = True, executable = False, searchable = False}
+Permissions {readable = True, writable = False, executable = True, searchable = False}
--- /dev/null
+Permissions {readable = True, writable = True, executable = False, searchable = True}
+Permissions {readable = True, writable = True, executable = False, searchable = False}
+Permissions {readable = True, writable = False, executable = True, searchable = False}
--- /dev/null
+Permissions {readable = True, writable = True, executable = False, searchable = True}
+Permissions {readable = True, writable = True, executable = False, searchable = False}
+Permissions {readable = True, writable = False, executable = True, searchable = False}
--- /dev/null
+Permissions {readable = True, writable = True, executable = True, searchable = True}
+Permissions {readable = True, writable = True, executable = True, searchable = True}
+Permissions {readable = True, writable = True, executable = True, searchable = True}
--- /dev/null
+Permissions {readable = True, writable = True, executable = False, searchable = True}
+Permissions {readable = True, writable = True, executable = False, searchable = False}
+Permissions {readable = True, writable = False, executable = True, searchable = False}