From 14327f318d17fc4882a4144de9fb0a5f8a6c852b Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Thu, 18 Oct 2007 12:01:15 +0000 Subject: [PATCH] Move tests from testsuite/tests/ghc-regress/lib/Directory --- tests/Makefile | 7 +++++++ tests/all.T | 9 +++++++++ tests/currentDirectory001.hs | 20 ++++++++++++++++++++ tests/currentDirectory001.hs~ | 20 ++++++++++++++++++++ tests/currentDirectory001.stdout | 1 + tests/directory001.hs | 17 +++++++++++++++++ tests/directory001.stdout | 1 + tests/doesDirectoryExist001.hs | 4 ++++ tests/doesDirectoryExist001.stdout | 1 + tests/getDirContents001.hs | 13 +++++++++++++ tests/getDirContents001.stdout | 10 ++++++++++ .../getDirContents001.stdout-i386-unknown-mingw32 | 10 ++++++++++ tests/getPermissions001.hs | 13 +++++++++++++ tests/getPermissions001.stdout | 3 +++ tests/getPermissions001.stdout-alpha-dec-osf3 | 3 +++ .../getPermissions001.stdout-i386-unknown-freebsd | 3 +++ .../getPermissions001.stdout-i386-unknown-openbsd | 3 +++ tests/getPermissions001.stdout-mingw | 3 +++ ...getPermissions001.stdout-x86_64-unknown-openbsd | 3 +++ 19 files changed, 144 insertions(+) create mode 100644 tests/Makefile create mode 100644 tests/all.T create mode 100644 tests/currentDirectory001.hs create mode 100644 tests/currentDirectory001.hs~ create mode 100644 tests/currentDirectory001.stdout create mode 100644 tests/directory001.hs create mode 100644 tests/directory001.stdout create mode 100644 tests/doesDirectoryExist001.hs create mode 100644 tests/doesDirectoryExist001.stdout create mode 100644 tests/getDirContents001.hs create mode 100644 tests/getDirContents001.stdout create mode 100644 tests/getDirContents001.stdout-i386-unknown-mingw32 create mode 100644 tests/getPermissions001.hs create mode 100644 tests/getPermissions001.stdout create mode 100644 tests/getPermissions001.stdout-alpha-dec-osf3 create mode 100644 tests/getPermissions001.stdout-i386-unknown-freebsd create mode 100644 tests/getPermissions001.stdout-i386-unknown-openbsd create mode 100644 tests/getPermissions001.stdout-mingw create mode 100644 tests/getPermissions001.stdout-x86_64-unknown-openbsd diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..6a0abcf --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,7 @@ +# 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 diff --git a/tests/all.T b/tests/all.T new file mode 100644 index 0000000..526e9ad --- /dev/null +++ b/tests/all.T @@ -0,0 +1,9 @@ +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']) diff --git a/tests/currentDirectory001.hs b/tests/currentDirectory001.hs new file mode 100644 index 0000000..bcf9b96 --- /dev/null +++ b/tests/currentDirectory001.hs @@ -0,0 +1,20 @@ +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 diff --git a/tests/currentDirectory001.hs~ b/tests/currentDirectory001.hs~ new file mode 100644 index 0000000..bcf9b96 --- /dev/null +++ b/tests/currentDirectory001.hs~ @@ -0,0 +1,20 @@ +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 diff --git a/tests/currentDirectory001.stdout b/tests/currentDirectory001.stdout new file mode 100644 index 0000000..1ddd42b --- /dev/null +++ b/tests/currentDirectory001.stdout @@ -0,0 +1 @@ +Okay diff --git a/tests/directory001.hs b/tests/directory001.hs new file mode 100644 index 0000000..c04a015 --- /dev/null +++ b/tests/directory001.hs @@ -0,0 +1,17 @@ +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" diff --git a/tests/directory001.stdout b/tests/directory001.stdout new file mode 100644 index 0000000..1ddd42b --- /dev/null +++ b/tests/directory001.stdout @@ -0,0 +1 @@ +Okay diff --git a/tests/doesDirectoryExist001.hs b/tests/doesDirectoryExist001.hs new file mode 100644 index 0000000..be26ec0 --- /dev/null +++ b/tests/doesDirectoryExist001.hs @@ -0,0 +1,4 @@ +-- !!! "/" was not recognised as a directory in 6.0.x +import System.Directory +main = doesDirectoryExist "/" >>= print + diff --git a/tests/doesDirectoryExist001.stdout b/tests/doesDirectoryExist001.stdout new file mode 100644 index 0000000..0ca9514 --- /dev/null +++ b/tests/doesDirectoryExist001.stdout @@ -0,0 +1 @@ +True diff --git a/tests/getDirContents001.hs b/tests/getDirContents001.hs new file mode 100644 index 0000000..1c0e3f8 --- /dev/null +++ b/tests/getDirContents001.hs @@ -0,0 +1,13 @@ +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) diff --git a/tests/getDirContents001.stdout b/tests/getDirContents001.stdout new file mode 100644 index 0000000..87a875c --- /dev/null +++ b/tests/getDirContents001.stdout @@ -0,0 +1,10 @@ +getDirContents001 +getDirContents001.comp.stderr +getDirContents001.hi +getDirContents001.hs +getDirContents001.o +getDirContents001.run.stderr +getDirContents001.run.stdout +getDirContents001.stdout +getDirContents001.stdout-i386-unknown-mingw32 + diff --git a/tests/getDirContents001.stdout-i386-unknown-mingw32 b/tests/getDirContents001.stdout-i386-unknown-mingw32 new file mode 100644 index 0000000..89deae1 --- /dev/null +++ b/tests/getDirContents001.stdout-i386-unknown-mingw32 @@ -0,0 +1,10 @@ +getDirContents001.comp.stderr +getDirContents001.exe +getDirContents001.hi +getDirContents001.hs +getDirContents001.o +getDirContents001.run.stderr +getDirContents001.run.stdout +getDirContents001.stdout +getDirContents001.stdout-i386-unknown-mingw32 + diff --git a/tests/getPermissions001.hs b/tests/getPermissions001.hs new file mode 100644 index 0000000..0c435df --- /dev/null +++ b/tests/getPermissions001.hs @@ -0,0 +1,13 @@ +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 diff --git a/tests/getPermissions001.stdout b/tests/getPermissions001.stdout new file mode 100644 index 0000000..1e18354 --- /dev/null +++ b/tests/getPermissions001.stdout @@ -0,0 +1,3 @@ +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} diff --git a/tests/getPermissions001.stdout-alpha-dec-osf3 b/tests/getPermissions001.stdout-alpha-dec-osf3 new file mode 100644 index 0000000..8b030e2 --- /dev/null +++ b/tests/getPermissions001.stdout-alpha-dec-osf3 @@ -0,0 +1,3 @@ +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} diff --git a/tests/getPermissions001.stdout-i386-unknown-freebsd b/tests/getPermissions001.stdout-i386-unknown-freebsd new file mode 100644 index 0000000..8b030e2 --- /dev/null +++ b/tests/getPermissions001.stdout-i386-unknown-freebsd @@ -0,0 +1,3 @@ +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} diff --git a/tests/getPermissions001.stdout-i386-unknown-openbsd b/tests/getPermissions001.stdout-i386-unknown-openbsd new file mode 100644 index 0000000..8b030e2 --- /dev/null +++ b/tests/getPermissions001.stdout-i386-unknown-openbsd @@ -0,0 +1,3 @@ +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} diff --git a/tests/getPermissions001.stdout-mingw b/tests/getPermissions001.stdout-mingw new file mode 100644 index 0000000..4dcaba5 --- /dev/null +++ b/tests/getPermissions001.stdout-mingw @@ -0,0 +1,3 @@ +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} diff --git a/tests/getPermissions001.stdout-x86_64-unknown-openbsd b/tests/getPermissions001.stdout-x86_64-unknown-openbsd new file mode 100644 index 0000000..8b030e2 --- /dev/null +++ b/tests/getPermissions001.stdout-x86_64-unknown-openbsd @@ -0,0 +1,3 @@ +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} -- 1.7.10.4