[TEST] FileDirectoryTests
Anthony Adachi
adachipro at yahoo.com
Wed May 21 05:17:41 UTC 2003
Stephane Ducasse wrote:
> Could you send your tests as changeset plus put
[TEST] (marcus is it
> correct?) so that marcus collect them?
Stephen Pair wrote about his test:
> That's correct...this test passes on Unix and
Windows systems, but fails
> on Mac OSX (and apparently 9.1 as well). There is a
bug in the Mac
> implementation that should be corrected. That was
why I wrote the test
> and posted the message. The problem is that the Mac
implementation of
> the primitive FilePlugin>>primitiveDirectoryLookup
(dir_lookup() is the
> platform specific C function) is simply checking to
see whether there is
> an entry named like the FileDirectory without
regard to whether or not
> the entry is actually a directory. As I mentioned
earlier, I think the
> behavior on Windows and Unix is correct, and the
Mac implementation
> needs to be corrected to conform to the Windows and
Unix implementations.
>
> This test needs to be added to the
FileDirectoryTests so that we can
> make sure this issue doesn't manifest itself again
in the future.
Here's a change set containing the additions and
modifications I added to FileDirectoryTests along
with the test Stephen Pair submitted. I refactored
some of the test code so it is more isolated and gives
more accurate results. Some tests are broken and the
implementation needs to be fixed.
Failing tests:
a. FileDirectory >>testExists -when checking if a
deleted directory exists.
b. FileDirectory >>
testDirectoryExistsWhenLikeNamedFileExists - as
explained above by Stephen.
c. FileDirectory >> testAttemptExistenceCheckWhenFile
- Files are not directories and the 'exists' method
should know that.
'From Squeak3.5 of ''11 April 2003'' [latest update:
#5180] on 21 May 2003 at 1:00:41 am'!
!FileDirectoryTests methodsFor: 'existence tests'
stamp: 'aka 5/20/2003 16:43'!
testAttemptExistenceCheckWhenFile
"How should a FileDirectory instance respond with an
existent file name?"
| directory |
FileDirectory default
forceNewFileNamed: 'aTestFile'.
directory := FileDirectory default
directoryNamed: 'aTestFile'.
self shouldnt: [directory exists]
description: 'Files are not directories.'.! !
!FileDirectoryTests methodsFor: 'existence tests'
stamp: 'aka 5/20/2003 23:33'!
testDirectoryExists
self assert: self myAssuredDirectory exists.
self should: [self myDirectory containingDirectory
directoryExists: self myLocalDirectoryName].
self myDirectory containingDirectory deleteDirectory:
self myLocalDirectoryName.
self shouldnt: [self myDirectory containingDirectory
directoryExists: self myLocalDirectoryName]! !
!FileDirectoryTests methodsFor: 'existence tests'
stamp: 'svp 5/20/2003 17:14'!
testDirectoryExistsWhenLikeNamedFileExists
| testFileName |
[testFileName := self myAssuredDirectory fullNameFor:
'zDirExistsTest.testing'.
(FileStream newFileNamed: testFileName) close.
self should: [FileStream isAFileNamed: testFileName].
self shouldnt: [(FileDirectory on: testFileName)
exists]]
ensure: [self myAssuredDirectory deleteFileNamed:
'zDirExistsTest.testing']
! !
!FileDirectoryTests methodsFor: 'existence tests'
stamp: 'aka 5/20/2003 23:49'!
testExists
self should: [FileDirectory default exists]
description: 'Should know default directory
exists.'.
self should: [self myAssuredDirectory exists]
description: 'Should know created directory
exists.'.
self myDirectory containingDirectory deleteDirectory:
self myLocalDirectoryName.
self shouldnt: [self myDirectory exists]
description: 'Should know that recently deleted
directory no longer exists.'.! !
!FileDirectoryTests methodsFor: 'existence tests'
stamp: 'aka 5/20/2003 14:26'!
testNonExistentDirectory
| directory parentDirectory |
directory _FileDirectory default
directoryNamed: 'nonExistentFolder'.
self shouldnt: [directory exists]
description: 'A FileDirectory instance should know
if it points to a non-existent directory.'.
parentDirectory _FileDirectory default.
self shouldnt: [parentDirectory directoryExists:
'nonExistentFolder']
description: 'A FileDirectory instance should know
when a directory of the given name doesn''t exist'.
! !
!FileDirectoryTests methodsFor: 'create/delete tests'
stamp: 'aka 5/21/2003 00:31'!
testDeleteDirectory
"Test deletion of a directory"
| aContainingDirectory preTestItems |
aContainingDirectory _ self myDirectory
containingDirectory.
preTestItems _ aContainingDirectory
fileAndDirectoryNames.
self assert: self myAssuredDirectory exists.
aContainingDirectory deleteDirectory: self
myLocalDirectoryName.
self shouldnt:
[aContainingDirectory directoryNames
includes: self myLocalDirectoryName ]
description: 'Should successfully delete
directory.'.
self should:
[preTestItems = aContainingDirectory
fileAndDirectoryNames]
description: 'Should only delete the indicated
directory.'.
! !
FileDirectoryTests removeSelector:
#testAttemptCreateInstanceWithFile!
FileDirectoryTests removeSelector:
#testNonExistantDirectory!
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
More information about the Squeak-dev
mailing list
|