Closed
Bug 783414
Opened 12 years ago
Closed 12 years ago
Make nsIFile non-builtinclass
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: hiro, Unassigned)
Details
Attachments
(1 file, 1 obsolete file)
(deleted),
patch
|
benjamin
:
review-
|
Details | Diff | Splinter Review |
So we can write Test-Double of nsIFile in xpcshell test.
An example of those Test-Double is attached in bug 674742 comment #45.
Reporter | ||
Comment 1•12 years ago
|
||
I am sorry for the previous wrong patch.
Attachment #652620 -
Attachment is obsolete: true
Attachment #652638 -
Flags: review?(benjamin)
Comment 2•12 years ago
|
||
Comment on attachment 652638 [details] [diff] [review]
Fix
Given what I know so far about this bug, this is definitely not a good idea. We cast nsIFile* to nsLocalFile* internally in a bunch of places, and I can't understand why you'd need to mock nsIFile in a test when you could just use it directly.
Attachment #652638 -
Flags: review?(benjamin) → review-
Reporter | ||
Comment 3•12 years ago
|
||
(In reply to Benjamin Smedberg [:bsmedberg] [away 27-July until 7-Aug] from comment #2)
> Comment on attachment 652638 [details] [diff] [review]
> Fix
>
> Given what I know so far about this bug, this is definitely not a good idea.
> We cast nsIFile* to nsLocalFile* internally in a bunch of places, and I
> can't understand why you'd need to mock nsIFile in a test when you could
> just use it directly.
Because I could not. How can we write test cases that nsIFile.moveTo (or other methods) fails without such mock?
Comment 4•12 years ago
|
||
You make a read-only directory and try to move a file into it?
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WONTFIX
Reporter | ||
Comment 5•12 years ago
|
||
(In reply to Benjamin Smedberg [:bsmedberg] from comment #4)
> You make a read-only directory and try to move a file into it?
That's a good idea in general but can be used in the case of bug 674742 due to NS_ERROR_FILE_ACCESS_DENIED before moveTo.
I will reopen this bug when I implement another example.
Reporter | ||
Comment 6•12 years ago
|
||
Reopening.
I've post another example in bug 784872, and a new Test-Double implementation of nsIFile in bug 784870.
The new implementation can be used in most cases. In bug 784872 case, the Test-Double returns a fake size if nsIFile.fileSize is invoked.
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
Reporter | ||
Comment 7•12 years ago
|
||
Benjamin, what do you think of non-builtinclass only for test build (i.e. --enable-tests option for configure)? Though I do not have any idea how to do it yet.
Comment 8•12 years ago
|
||
We should test what actually shipped.
Moreover, some feature may depend on the builtinclass-ness. For example, see bug 784436.
Reporter | ||
Comment 9•12 years ago
|
||
(In reply to Masatoshi Kimura [:emk] from comment #8)
> We should test what actually shipped.
> Moreover, some feature may depend on the builtinclass-ness. For example, see
> bug 784436.
Thanks for the info.
Do you have any other idea to implement test for failure cases of nsIFile method such as bug 784870?
Comment 10•12 years ago
|
||
(In reply to Hiroyuki Ikezoe (:hiro) from comment #7)
> Benjamin, what do you think of non-builtinclass only for test build (i.e.
> --enable-tests option for configure)? Though I do not have any idea how to
> do it yet.
--enable-tests is the default, and we ship our release builds that way, FYI.
Comment 11•12 years ago
|
||
In bug 784870, it appears that you're re-implementing nsIFile in C++, so why do you need builtinclass at all? Although note that still isn't safe because of internal nsIFile* -> nsLocalFile* casts, so depending on which localfile methods you call you might just crash. In any case, I do not agree with the basic premise of this bug. You'll have to find a different way to test your code.
Status: REOPENED → RESOLVED
Closed: 12 years ago → 12 years ago
Resolution: --- → WONTFIX
Reporter | ||
Comment 12•12 years ago
|
||
(In reply to Benjamin Smedberg [:bsmedberg] from comment #11)
> In bug 784870, it appears that you're re-implementing nsIFile in C++, so why
> do you need builtinclass at all?
Woohoo!!!! Thank you, Benjamin! You reminds me to add 'builtinclass' flag to a child of nsILocalFile. Now we can write stubs of nsIFile.
Thanks a lot!
You need to log in
before you can comment on or make changes to this bug.
Description
•